Skip to content

AuthXConfig

authx.config.AuthXConfig

Bases: BaseSettings

AuthX Base Configuration Object

PARAMETER DESCRIPTION
BaseSettings

BaseSettings class from Pydantic

TYPE: BaseSettings

RAISES DESCRIPTION
BadConfigurationError

If JWT_ALGORITHM is not supported

BadConfigurationError

If JWT_ALGORITHM requires a key and it is not set

RETURNS DESCRIPTION
AuthXConfig

AuthX Configuration Object

JWT_ACCESS_TOKEN_EXPIRES class-attribute instance-attribute

JWT_ACCESS_TOKEN_EXPIRES = timedelta(minutes=15)

JWT_ALGORITHM class-attribute instance-attribute

JWT_ALGORITHM = 'HS256'

JWT_DECODE_ALGORITHMS class-attribute instance-attribute

JWT_DECODE_ALGORITHMS = Field(default_factory=lambda: ['HS256'])

JWT_DECODE_AUDIENCE class-attribute instance-attribute

JWT_DECODE_AUDIENCE = None

JWT_DECODE_ISSUER class-attribute instance-attribute

JWT_DECODE_ISSUER = None

JWT_DECODE_LEEWAY class-attribute instance-attribute

JWT_DECODE_LEEWAY = 0

JWT_ENCODE_AUDIENCE class-attribute instance-attribute

JWT_ENCODE_AUDIENCE = None

JWT_ENCODE_ISSUER class-attribute instance-attribute

JWT_ENCODE_ISSUER = None

JWT_ENCODE_NBF class-attribute instance-attribute

JWT_ENCODE_NBF = True

JWT_ERROR_MESSAGE_KEY class-attribute instance-attribute

JWT_ERROR_MESSAGE_KEY = 'msg'

JWT_IDENTITY_CLAIM class-attribute instance-attribute

JWT_IDENTITY_CLAIM = 'sub'

JWT_PRIVATE_KEY class-attribute instance-attribute

JWT_PRIVATE_KEY = None

JWT_PUBLIC_KEY class-attribute instance-attribute

JWT_PUBLIC_KEY = None

JWT_REFRESH_TOKEN_EXPIRES class-attribute instance-attribute

JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=20)

JWT_SECRET_KEY class-attribute instance-attribute

JWT_SECRET_KEY = None

JWT_TOKEN_LOCATION class-attribute instance-attribute

JWT_TOKEN_LOCATION = Field(default_factory=lambda: ['headers'])

JWT_HEADER_NAME class-attribute instance-attribute

JWT_HEADER_NAME = 'Authorization'

JWT_HEADER_TYPE class-attribute instance-attribute

JWT_HEADER_TYPE = 'Bearer'
JWT_ACCESS_COOKIE_NAME = 'access_token_cookie'
JWT_ACCESS_COOKIE_PATH = '/'
JWT_COOKIE_CSRF_PROTECT = True
JWT_COOKIE_DOMAIN = None
JWT_COOKIE_MAX_AGE = None
JWT_COOKIE_SAMESITE = 'lax'
JWT_COOKIE_SECURE = True
JWT_REFRESH_COOKIE_NAME = 'refresh_token_cookie'
JWT_REFRESH_COOKIE_PATH = '/'
JWT_SESSION_COOKIE = True
JWT_ACCESS_CSRF_COOKIE_NAME = 'csrf_access_token'
JWT_ACCESS_CSRF_COOKIE_PATH = '/'

JWT_ACCESS_CSRF_FIELD_NAME class-attribute instance-attribute

JWT_ACCESS_CSRF_FIELD_NAME = 'csrf_token'

JWT_ACCESS_CSRF_HEADER_NAME class-attribute instance-attribute

JWT_ACCESS_CSRF_HEADER_NAME = 'X-CSRF-TOKEN'

JWT_CSRF_CHECK_FORM class-attribute instance-attribute

JWT_CSRF_CHECK_FORM = False

JWT_CSRF_IN_COOKIES class-attribute instance-attribute

JWT_CSRF_IN_COOKIES = True

JWT_CSRF_METHODS class-attribute instance-attribute

JWT_CSRF_METHODS = Field(default_factory=lambda: ['POST', 'PUT', 'PATCH', 'DELETE'])
JWT_REFRESH_CSRF_COOKIE_NAME = 'csrf_refresh_token'
JWT_REFRESH_CSRF_COOKIE_PATH = '/'

JWT_REFRESH_CSRF_FIELD_NAME class-attribute instance-attribute

JWT_REFRESH_CSRF_FIELD_NAME = 'csrf_token'

JWT_REFRESH_CSRF_HEADER_NAME class-attribute instance-attribute

JWT_REFRESH_CSRF_HEADER_NAME = 'X-CSRF-TOKEN'

JWT_QUERY_STRING_NAME class-attribute instance-attribute

JWT_QUERY_STRING_NAME = 'token'

JWT_JSON_KEY class-attribute instance-attribute

JWT_JSON_KEY = 'access_token'

JWT_REFRESH_JSON_KEY class-attribute instance-attribute

JWT_REFRESH_JSON_KEY = 'refresh_token'

JWT_IMPLICIT_REFRESH_ROUTE_EXCLUDE class-attribute instance-attribute

JWT_IMPLICIT_REFRESH_ROUTE_EXCLUDE = Field(default_factory=list)

JWT_IMPLICIT_REFRESH_ROUTE_INCLUDE class-attribute instance-attribute

JWT_IMPLICIT_REFRESH_ROUTE_INCLUDE = Field(default_factory=list)

JWT_IMPLICIT_REFRESH_METHOD_EXCLUDE class-attribute instance-attribute

JWT_IMPLICIT_REFRESH_METHOD_EXCLUDE = Field(default_factory=list)

JWT_IMPLICIT_REFRESH_METHOD_INCLUDE class-attribute instance-attribute

JWT_IMPLICIT_REFRESH_METHOD_INCLUDE = Field(default_factory=list)

JWT_IMPLICIT_REFRESH_DELTATIME class-attribute instance-attribute

JWT_IMPLICIT_REFRESH_DELTATIME = timedelta(minutes=10)

is_algo_symmetric property

is_algo_symmetric

Check if the JWT_ALGORITHM is a symmetric encryption algorithm

is_algo_asymmetric property

is_algo_asymmetric

Check if the JWT_ALGORITHM is an asymmetric encryption algorithm

private_key property

private_key

Private key to encode token

public_key property

public_key

Public key to decode token

has_location

has_location(location)

Check if the token location is enabled

PARAMETER DESCRIPTION
location

TYPE: str

Source code in authx/config.py
def has_location(self, location: str) -> bool:
    """Check if the token location is enabled"""
    return location in self.JWT_TOKEN_LOCATION