bartender.user#
Classes#
User model. |
|
JWT decoder. |
Functions#
|
Generate a JSON Web Token (JWT) with the given parameters. |
|
Generate a JSON Web Token (JWT). |
Module Contents#
- class bartender.user.User#
Bases:
pydantic.BaseModelUser model.
- class bartender.user.JwtDecoder(key: jose.backends.base.Key)#
JWT decoder.
- Parameters:
key (jose.backends.base.Key) – The key to use for decoding the JWT token.
- key#
- __call__(apikey: str) User#
Decodes a JWT token and returns a User object.
Raises an JOSE exception if the token is invalid.
- classmethod from_file(public_key: pathlib.Path) JwtDecoder#
Create a JwtDecoder from a public key file.
- Parameters:
public_key (pathlib.Path) – Path to the public key file.
- Returns:
A JwtDecoder object.
- Return type:
- classmethod from_bytes(public_key: bytes) JwtDecoder#
Create a JwtDecoder from a public key.
- Parameters:
public_key (bytes) – The public key.
- Returns:
A JwtDecoder object.
- Return type:
- bartender.user.generate_token_subcommand(private_key: pathlib.Path, username: str, roles: list[str], lifetime: int, issuer: str, oformat: Literal['header', 'plain'] = 'plain') None#
Generate a JSON Web Token (JWT) with the given parameters.
- Parameters:
private_key (pathlib.Path) – Path to the private key file.
username (str) – The username to include in the token.
roles (list[str]) – A list of roles to include in the token.
lifetime (int) – The lifetime of the token in minutes.
issuer (str) – The issuer of the token.
oformat (Literal['header', 'plain']) – The format of the token output. Can be “header” or “plain”.
- Returns:
None
- Return type:
None