Token#
- class gafaelfawr.models.token.Token(**data)#
Bases:
BaseModel
An opaque token.
Notes
A token consists of two parts, a semi-public key that is used as the Redis key, and a secret that is only present in the token returned to the user and the encrypted session in Redis.
The serialized form of a token always starts with
gt-
, short for Gafaelfawr token, to make it easier to identify these tokens in logs.The serialized form encodes the secret in URL-safe base64 with the padding stripped off (because equal signs can be parsed oddly in cookies).
- Parameters:
data (
Any
)
Attributes Summary
Configuration for the model, should be a dictionary conforming to [
ConfigDict
][pydantic.config.ConfigDict].Methods Summary
from_str
(token)Parse a serialized token into a
Token
.is_token
(token)Determine if a string is a Gafaelfawr token.
Attributes Documentation
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [
ConfigDict
][pydantic.config.ConfigDict].
Methods Documentation
- classmethod from_str(token)#
Parse a serialized token into a
Token
.- Parameters:
token (
str
) – The serialized token.- Returns:
The decoded
Token
.- Return type:
- Raises:
InvalidTokenError – The provided string is not a valid token.