JWT

Pydantic model

pydantic model iperon.contrib.jwt.JWT

Show JSON schema
{
   "title": "JWT",
   "type": "object",
   "properties": {
      "exp": {
         "title": "Exp",
         "default": "2022-03-03T20:58:19.426973",
         "type": "string",
         "format": "date-time"
      },
      "iat": {
         "title": "Iat",
         "default": "2022-03-03T20:58:19.426976",
         "type": "string",
         "format": "date-time"
      },
      "payload": {
         "title": "Payload",
         "default": {},
         "type": "object"
      },
      "expires": {
         "title": "Expires",
         "default": 3600,
         "type": "integer"
      },
      "algorithm": {
         "default": "HS256",
         "allOf": [
            {
               "$ref": "#/definitions/Algorithm"
            }
         ]
      }
   },
   "definitions": {
      "Algorithm": {
         "title": "Algorithm",
         "description": "Algorithm selection",
         "enum": [
            "HS256",
            "HS384",
            "HS512"
         ]
      }
   }
}

Fields
field algorithm: iperon.contrib.jwt.Algorithm = Algorithm.HS256
field exp: datetime.datetime = datetime.datetime(2022, 3, 3, 20, 58, 19, 426973)
field expires: int = 3600
field iat: datetime.datetime = datetime.datetime(2022, 3, 3, 20, 58, 19, 426976)
field payload: dict = {}
classmethod decode(jwt_token: str, algorithm: iperon.contrib.jwt.Algorithm = Algorithm.HS256, verify_signature: bool = True) iperon.contrib.jwt.JWT

Decodes a JWT string into an object

Parameters
  • jwt_token (str) – String JWT token

  • algorithm (Algorithm) – Decoding algorithm

  • verify_signature (bool) – Whether to check the token signature

Returns

Return JWT object

Return type

JWT

generate() str

Generates JWT token

Returns

Returns a JWT token in a string

Return type

str

Algorithm

class iperon.contrib.jwt.Algorithm(value)

Algorithm selection

HS256 = 'HS256'
HS384 = 'HS384'
HS512 = 'HS512'