State#

class gafaelfawr.models.state.State(csrf=None, token=None, github=None, return_url=None, state=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.

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: Optional[str] = None#

CSRF token for form submissions.

github: Optional[str] = None#

GitHub OAuth token if user authenticated via GitHub.

return_url: Optional[str] = None#

Destination URL after completion of login.

state: Optional[str] = None#

State token for OAuth 2.0 and OpenID Connect logins.

token: Optional[Token] = None#

Token if the user is authenticated.

Methods Documentation

Reconstruct state from an encrypted cookie.

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

  • key – The ~cryptography.fernet.Fernet key used to decrypt it.

  • request (Optional[Request], 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