Token

pydantic model phalanx.models.gafaelfawr.Token

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)

Show JSON schema
{
   "title": "Token",
   "description": "An opaque token.\n\nNotes\n-----\nA token consists of two parts, a semi-public key that is used as the Redis\nkey, and a secret that is only present in the token returned to the user\nand the encrypted session in Redis.\n\nThe serialized form of a token always starts with ``gt-``, short for\nGafaelfawr token, to make it easier to identify these tokens in logs.\n\nThe serialized form encodes the secret in URL-safe base64 with the padding\nstripped off (because equal signs can be parsed oddly in cookies).",
   "type": "object",
   "properties": {
      "key": {
         "title": "Key",
         "type": "string"
      },
      "secret": {
         "title": "Secret",
         "type": "string"
      }
   }
}

Fields:
field key: str [Optional]
field secret: str [Optional]
classmethod from_str(token)

Parse a serialized token into a Token.

Parameters:

token (str) – Serialized token.

Returns:

Decoded Token.

Return type:

Token

Raises:

ValueError – The provided string is not a valid token.

classmethod is_token(token)

Determine if a string is a Gafaelfawr token.

Parameters:

token (str) – The string to check.

Returns:

Whether that string looks like a Gafaelfawr token. The token isn’t checked for validity, only format.

Return type:

bool