Provider

class gafaelfawr.providers.base.Provider

Bases: object

Abstract base class for authentication providers.

Methods Summary

create_user_info(code, state, session)

Given the code from an authentication, create the user information.

get_redirect_url(state)

Get the login URL to which to redirect the user.

logout(session)

Log out user.

Methods Documentation

abstract async create_user_info(code, state, session)

Given the code from an authentication, create the user information.

Parameters:
  • code (str) – Code returned by a successful authentication.

  • state (str) – The same random string used for the redirect URL.

  • session (State) – The session state. The provider may also store data used during logout.

Returns:

The user information corresponding to that authentication.

Return type:

TokenUserInfo

Raises:
  • httpx.HTTPError – Raised if an HTTP client error occurred trying to talk to the authentication provider.

  • ProviderError – Raised if the provider responded with an error to a request.

abstract get_redirect_url(state)

Get the login URL to which to redirect the user.

Parameters:

state (str) – A random string used for CSRF protection.

Returns:

The encoded URL to which to redirect the user.

Return type:

str

abstract async logout(session)

Log out user.

The authentication provider may revoke the upstream authentication token or take other action during user logout.

Parameters:

session (State) – The session state before logout.

Return type:

None