bokeh.server.auth_provider#

Provide a hook for supplying authorization mechanisms to a Bokeh server.

class AuthModule(module_path: PathLike)[source]#

An AuthProvider configured from a Python module.

The following properties return the corresponding values from the module if they exist, or None otherwise:

  • get_login_url,

  • get_user

  • get_user_async

  • login_url

  • logout_url

The login_handler property will return a LoginHandler class from the module, or None otherwise.

The logout_handler property will return a LogoutHandler class from the module, or None otherwise.

Public Data Attributes:

get_user

A function to get the current authenticated user.

get_user_async

An async function to get the current authenticated user.

login_url

A URL to redirect unauthenticated users to for login.

get_login_url

A function that computes a URL to redirect unathenticated users to for login.

login_handler

A request handler class for a login page.

logout_url

A URL to redirect authenticated users to for logout.

logout_handler

A request handler class for a logout page.

Inherited from AuthProvider

endpoints

URL patterns for login/logout endpoints.

get_login_url

A function that computes a URL to redirect unathenticated users to for login.

get_user

A function to get the current authenticated user.

get_user_async

An async function to get the current authenticated user.

login_handler

A request handler class for a login page.

login_url

A URL to redirect unauthenticated users to for login.

logout_handler

A request handler class for a logout page.

logout_url

A URL to redirect authenticated users to for logout.

Public Methods:

__init__(module_path)

Inherited from AuthProvider

__init__()


property get_login_url#

A function that computes a URL to redirect unathenticated users to for login.

This property may return None, if a login_url is supplied instead.

If a function is returned, it should accept a RequestHandler and return a login URL for unathenticated users.

property get_user#

A function to get the current authenticated user.

This property may return None, if a get_user_async function is supplied instead.

If a function is returned, it should accept a RequestHandler and return the current authenticated user.

property get_user_async#

An async function to get the current authenticated user.

This property may return None, if a get_user function is supplied instead.

If a function is returned, it should accept a RequestHandler and return the current authenticated user.

property login_handler#

A request handler class for a login page.

This property may return None, if login_url is supplied instead.

If a class is returned, it must be a subclass of RequestHandler, which will used for the endpoint specified by logout_url

property login_url#

A URL to redirect unauthenticated users to for login.

This proprty may return None, if a get_login_url function is supplied instead.

property logout_handler#

A request handler class for a logout page.

This property may return None.

If a class is returned, it must be a subclass of RequestHandler, which will used for the endpoint specified by logout_url

property logout_url#

A URL to redirect authenticated users to for logout.

This proprty may return None.

class AuthProvider[source]#

Abstract base class for implementing authorization hooks.

Subclasses must supply one of: get_user or get_user_async.

Subclasses must also supply one of login_url or get_login_url.

Optionally, if login_url provides a relative URL, then login_handler may also be supplied.

The properties logout_url and get_logout_handler are analogous to the corresponding login properties, and are optional.

Public Data Attributes:

endpoints

URL patterns for login/logout endpoints.

get_login_url

A function that computes a URL to redirect unathenticated users to for login.

get_user

A function to get the current authenticated user.

get_user_async

An async function to get the current authenticated user.

login_handler

A request handler class for a login page.

login_url

A URL to redirect unauthenticated users to for login.

logout_handler

A request handler class for a logout page.

logout_url

A URL to redirect authenticated users to for logout.

Public Methods:

__init__()


property endpoints: list[tuple[str, Type[RequestHandler]]]#

URL patterns for login/logout endpoints.

property get_login_url: Callable[[HTTPServerRequest], str] | None#

A function that computes a URL to redirect unathenticated users to for login.

This property may return None, if a login_url is supplied instead.

If a function is returned, it should accept a RequestHandler and return a login URL for unathenticated users.

property get_user: Callable[[HTTPServerRequest], User] | None#

A function to get the current authenticated user.

This property may return None, if a get_user_async function is supplied instead.

If a function is returned, it should accept a RequestHandler and return the current authenticated user.

property get_user_async: Callable[[HTTPServerRequest], Awaitable[User]] | None#

An async function to get the current authenticated user.

This property may return None, if a get_user function is supplied instead.

If a function is returned, it should accept a RequestHandler and return the current authenticated user.

property login_handler: Type[RequestHandler] | None#

A request handler class for a login page.

This property may return None, if login_url is supplied instead.

If a class is returned, it must be a subclass of RequestHandler, which will used for the endpoint specified by logout_url

property login_url: str | None#

A URL to redirect unauthenticated users to for login.

This proprty may return None, if a get_login_url function is supplied instead.

property logout_handler: Type[RequestHandler] | None#

A request handler class for a logout page.

This property may return None.

If a class is returned, it must be a subclass of RequestHandler, which will used for the endpoint specified by logout_url

property logout_url: str | None#

A URL to redirect authenticated users to for logout.

This proprty may return None.

class NullAuth[source]#

A default no-auth AuthProvider.

All of the properties of this provider return None.

Public Data Attributes:

get_user

A function to get the current authenticated user.

get_user_async

An async function to get the current authenticated user.

login_url

A URL to redirect unauthenticated users to for login.

get_login_url

A function that computes a URL to redirect unathenticated users to for login.

login_handler

A request handler class for a login page.

logout_url

A URL to redirect authenticated users to for logout.

logout_handler

A request handler class for a logout page.

Inherited from AuthProvider

endpoints

URL patterns for login/logout endpoints.

get_login_url

A function that computes a URL to redirect unathenticated users to for login.

get_user

A function to get the current authenticated user.

get_user_async

An async function to get the current authenticated user.

login_handler

A request handler class for a login page.

login_url

A URL to redirect unauthenticated users to for login.

logout_handler

A request handler class for a logout page.

logout_url

A URL to redirect authenticated users to for logout.

Public Methods:

Inherited from AuthProvider

__init__()


property get_login_url#

A function that computes a URL to redirect unathenticated users to for login.

This property may return None, if a login_url is supplied instead.

If a function is returned, it should accept a RequestHandler and return a login URL for unathenticated users.

property get_user#

A function to get the current authenticated user.

This property may return None, if a get_user_async function is supplied instead.

If a function is returned, it should accept a RequestHandler and return the current authenticated user.

property get_user_async#

An async function to get the current authenticated user.

This property may return None, if a get_user function is supplied instead.

If a function is returned, it should accept a RequestHandler and return the current authenticated user.

property login_handler#

A request handler class for a login page.

This property may return None, if login_url is supplied instead.

If a class is returned, it must be a subclass of RequestHandler, which will used for the endpoint specified by logout_url

property login_url#

A URL to redirect unauthenticated users to for login.

This proprty may return None, if a get_login_url function is supplied instead.

property logout_handler#

A request handler class for a logout page.

This property may return None.

If a class is returned, it must be a subclass of RequestHandler, which will used for the endpoint specified by logout_url

property logout_url#

A URL to redirect authenticated users to for logout.

This proprty may return None.