State#

class gafaelfawr.models.state.State(**data)#

Bases: BaseState, BaseModel

State information stored in a cookie.

Parameters:

data (Any)

Attributes Summary

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Summary

from_cookie(cookie[, request])

Reconstruct state from an encrypted cookie.

to_cookie()

Build an encrypted cookie representation of the state.

Attributes Documentation

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

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