TokenBase

pydantic model gafaelfawr.models.token.TokenBase

Base information about a token common to several representations.

This is the information that’s common to the Redis and database representations of the token.

Parameters:

data (Any)

Show JSON schema
{
   "title": "TokenBase",
   "description": "Base information about a token common to several representations.\n\nThis is the information that's common to the Redis and database\nrepresentations of the token.",
   "type": "object",
   "properties": {
      "username": {
         "description": "User to whom the token was issued",
         "examples": [
            "someuser"
         ],
         "maxLength": 64,
         "minLength": 1,
         "title": "Username",
         "type": "string"
      },
      "token_type": {
         "allOf": [
            {
               "$ref": "#/$defs/TokenType"
            }
         ],
         "examples": [
            "session"
         ],
         "title": "Token type"
      },
      "scopes": {
         "description": "Scopes of the token",
         "examples": [
            [
               "read:all",
               "user:token"
            ]
         ],
         "items": {
            "type": "string"
         },
         "title": "Token scopes",
         "type": "array"
      },
      "created": {
         "description": "Creation timestamp of the token in seconds since epoch",
         "examples": [
            1614986130
         ],
         "format": "date-time",
         "title": "Creation time",
         "type": "string"
      },
      "expires": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Expiration timestamp of the token in seconds since epoch",
         "examples": [
            1616986130
         ],
         "title": "Expiration time"
      }
   },
   "$defs": {
      "TokenType": {
         "description": "The class of token.",
         "enum": [
            "session",
            "user",
            "notebook",
            "internal",
            "service",
            "oidc"
         ],
         "title": "TokenType",
         "type": "string"
      }
   },
   "required": [
      "username",
      "token_type",
      "scopes"
   ]
}

Fields:
Validators:
field created: datetime [Optional]

Creation timestamp of the token in seconds since epoch

field expires: datetime | None = None

Expiration timestamp of the token in seconds since epoch

field scopes: list[str] [Required]

Scopes of the token

Validated by:
field token_type: TokenType [Required]
field username: str [Required]

User to whom the token was issued

Constraints:
  • min_length = 1

  • max_length = 64