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"
            }
         ],
         "description": "Class of token, chosen from:\n\n* `session`: An interactive user web session\n* `user`: A user-generated token that may be used programmatically\n* `notebook`: The token delegated to a Jupyter notebook for the user\n* `internal`: A service-to-service token used for internal sub-calls made as part of processing a user request\n* `service`: A service-to-service token used for internal calls initiated by services, unrelated to a user request\n* `oidc`: Access token for an OpenID Connect client\n",
         "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]#

Class of token, chosen from:

  • session: An interactive user web session

  • user: A user-generated token that may be used programmatically

  • notebook: The token delegated to a Jupyter notebook for the user

  • internal: A service-to-service token used for internal sub-calls made as part of processing a user request

  • service: A service-to-service token used for internal calls initiated by services, unrelated to a user request

  • oidc: Access token for an OpenID Connect client

field username: str [Required]#

User to whom the token was issued

Constraints:
  • min_length = 1

  • max_length = 64

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.