Jam
Jam
¶
Jam(auth_type: Literal['jwt'], config: dict[str, Any])
Bases: __AbstractInstance
Main instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
auth_type
|
Literal['jwt']
|
Type of auth* |
required |
config
|
dict[str, Any] | str
|
Config for Jam, can use |
required |
Methods:
Name | Description |
---|---|
gen_jwt_token |
Creating a new token. |
make_payload |
Payload maker tool. |
verify_jwt_token |
A method for verifying a token. |
gen_jwt_token
¶
gen_jwt_token(payload: dict[str, Any]) -> str
Creating a new token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload
|
dict[str, Any]
|
Payload with information |
required |
Raises:
Type | Description |
---|---|
EmptySecretKey
|
If the HMAC algorithm is selected, but the secret key is None |
EmtpyPrivateKey
|
If RSA algorithm is selected, but private key None |
make_payload
¶
make_payload(exp: int | None = None, **data) -> dict[str, Any]
Payload maker tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp
|
int | None
|
If none exp = JWTModule.exp |
None
|
**data
|
Custom data |
{}
|
verify_jwt_token
¶
verify_jwt_token(token: str, check_exp: bool = True, check_list: bool = True) -> dict[str, Any]
A method for verifying a token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token
|
str
|
The token to check |
required |
check_exp
|
bool
|
Check for expiration? |
True
|
check_list
|
bool
|
Check if there is a black/white list |
True
|
Raises:
Type | Description |
---|---|
ValueError
|
If the token is invalid. |
EmptySecretKey
|
If the HMAC algorithm is selected, but the secret key is None. |
EmtpyPublicKey
|
If RSA algorithm is selected, but public key None. |
NotFoundSomeInPayload
|
If 'exp' not found in payload. |
TokenLifeTimeExpired
|
If token has expired. |
TokenNotInWhiteList
|
If the list type is white, but the token is not there |
TokenInBlackList
|
If the list type is black and the token is there |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Payload from token |