TokenUserInfo

pydantic model gafaelfawr.models.token.TokenUserInfo

User metadata stored with the token.

Holds the user metadata generated by the authentication provider or the admin token request and stored with the token, without any supplemental information from LDAP or Firestore. Fields that are set will override any data from extenral sources. Fields set to None will be looked up in LDAP or Firestore.

Parameters:

data (Any)

Show JSON schema
{
   "title": "TokenUserInfo",
   "description": "User metadata stored with the token.\n\nHolds the user metadata generated by the authentication provider or the\nadmin token request and stored with the token, without any supplemental\ninformation from LDAP or Firestore. Fields that are set will override any\ndata from extenral sources. Fields set to `None` will be looked up in LDAP\nor Firestore.",
   "type": "object",
   "properties": {
      "username": {
         "description": "User to whom the token was issued",
         "examples": [
            "someuser"
         ],
         "maxLength": 64,
         "minLength": 1,
         "title": "Username",
         "type": "string"
      },
      "name": {
         "anyOf": [
            {
               "minLength": 1,
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "examples": [
            "Alice Example"
         ],
         "title": "Preferred full name"
      },
      "email": {
         "anyOf": [
            {
               "minLength": 1,
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "examples": [
            "alice@example.com"
         ],
         "title": "Email address"
      },
      "uid": {
         "anyOf": [
            {
               "minimum": 1,
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "examples": [
            4123
         ],
         "title": "UID number"
      },
      "gid": {
         "anyOf": [
            {
               "minimum": 1,
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "GID of primary group. If set, this will also be the GID of one of the groups of which the user is a member.",
         "examples": [
            4123
         ],
         "title": "Primary GID"
      },
      "groups": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/Group"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Groups of which the user is a member",
         "title": "Groups"
      }
   },
   "$defs": {
      "Group": {
         "description": "Information about a single group.",
         "properties": {
            "name": {
               "examples": [
                  "g_special_users"
               ],
               "minLength": 1,
               "pattern": "^[a-zA-Z][a-zA-Z0-9._-]*$",
               "title": "Name of the group",
               "type": "string"
            },
            "id": {
               "examples": [
                  123181
               ],
               "title": "Numeric GID of the group",
               "type": "integer"
            }
         },
         "required": [
            "name",
            "id"
         ],
         "title": "Group",
         "type": "object"
      }
   },
   "required": [
      "username"
   ]
}

Fields:
field email: str | None = None
Constraints:
  • min_length = 1

field gid: int | None = None

GID of primary group. If set, this will also be the GID of one of the groups of which the user is a member.

Constraints:
  • ge = 1

field groups: list[Group] | None = None

Groups of which the user is a member

field name: str | None = None
Constraints:
  • min_length = 1

field uid: int | None = None
Constraints:
  • ge = 1

field username: str [Required]

User to whom the token was issued

Constraints:
  • min_length = 1

  • max_length = 64

to_userinfo_dict()

Convert to a dictionary for logging purposes.

This method converts only the TokenUserInfo portion of a token to a dictionary for logging purposes, excluding the username field (which is logged separately). It’s used when logging creation of new tokens to make a record of the user identity information included in the token (as opposed to retrieved dynamically from other sources such as LDAP or Firestore).

Returns:

Dictionary of information, roughly equivalent to calling dict(exclude_none=True) on the TokenUserInfo object, but ensuring that only its data is included even if called on a subclass such as TokenData.

Return type:

dict