swh.auth.starlette.backends module#

class swh.auth.starlette.backends.BearerTokenAuthBackend(server_url: str, realm_name: str, client_id: str, cache: BaseCache)[source]#

Bases: AuthenticationBackend

Starlette authentication backend using Keycloak OpenID Connect authorization

An Keycloak server, realm and a cache to store access tokens must be provided

  • server_url – Keycloak URL

  • realm_name – Keycloak realm name

  • client_id – Keycloak client ID

  • cache – An aiocache cache instance

async authenticate(conn: HTTPConnection) Tuple[AuthCredentials, SimpleUser] | None[source]#