State

class gafaelfawr.models.state.State(csrf=None, token=None, github=None, return_url=None, state=None, login_start=None)

Bases: BaseState

State information stored in a cookie.

Parameters:

Attributes Summary

csrf

CSRF token for form submissions.

github

GitHub OAuth token if user authenticated via GitHub.

login_start

Start time of login process if one is in progress.

return_url

Destination URL after completion of login.

state

State token for OAuth 2.0 and OpenID Connect logins.

token

Token if the user is authenticated.

Methods Summary

from_cookie(cookie[, request])

Reconstruct state from an encrypted cookie.

to_cookie()

Build an encrypted cookie representation of the state.

Attributes Documentation

csrf: str | None = None

CSRF token for form submissions.

github: str | None = None

GitHub OAuth token if user authenticated via GitHub.

login_start: datetime | None = None

Start time of login process if one is in progress.

return_url: str | None = None

Destination URL after completion of login.

state: str | None = None

State token for OAuth 2.0 and OpenID Connect logins.

token: Token | None = None

Token if the user is authenticated.

Methods Documentation

Reconstruct state from an encrypted cookie.

Parameters:
  • cookie (str) – The encrypted cookie value.

  • key – The Fernet key used to decrypt it.

  • request (Request | None, default: None) – The request, used for logging. If not provided (primarily for the test suite), invalid state cookies will not be logged.

Returns:

The state represented by the cookie.

Return type:

State

Build an encrypted cookie representation of the state.

Returns:

The encrypted cookie value.

Return type:

str