Auth - manager¶
This module provides functionality for handling JSON Web Tokens (JWT) for authentication and authorization. It defines the structure and methods required to encode and decode JWTs, as well as manage the claims associated with the tokens.
BaseJWTManager
¶
Bases: ABC
Abstract base class for managing JSON Web Tokens (JWT). This class defines the interface for encoding and decoding JWT (RFC7519).
Info
대부분의 경우 해당 클래스의 하위 구현체를 직접 사용할 필요는 거의 없습니다.
encode
abstractmethod
¶
Encodes the specified claims into a JSON Web Token (JWT).
PARAMETER | DESCRIPTION |
---|---|
claims
|
A dictionary containing the claims to be included in the JWT.
TYPE:
|
secret_key
|
The secret key used to sign the JWT.
TYPE:
|
algorithm
|
The signing algorithm to be used for the JWT.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
A string representation of the encoded JWT.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
NotImplementedError
|
If this method is not implemented in a subclass. |
Source code in webtool/auth/manager.py
decode
abstractmethod
¶
Decodes a JSON Web Token (JWT) and validates its claims.
PARAMETER | DESCRIPTION |
---|---|
token
|
The JWT string to be decoded.
TYPE:
|
secret_key
|
The secret key used to validate the JWT signature.
TYPE:
|
algorithm
|
The signing algorithm used to verify the JWT,
TYPE:
|
at_hash
|
Optional parameter for additional handling of access tokens.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dicy
|
A dictionary containing the claims if the token is valid, or None if the token is invalid or expired.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
NotImplementedError
|
If this method is not implemented in a subclass. |
Source code in webtool/auth/manager.py
JWTManager
¶
Bases: BaseJWTManager
JWT manager for encoding and decoding JSON Web Tokens.
Source code in webtool/auth/manager.py
encode
¶
Encodes the specified claims into a JSON Web Token (JWT) with a specified expiration time.
PARAMETER | DESCRIPTION |
---|---|
claims
|
A dictionary containing the claims to be included in the JWT.
TYPE:
|
secret_key
|
The secret key used to sign the JWT.
TYPE:
|
algorithm
|
The signing algorithm to use for the JWT, defaults to 'ES384'.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
Json Web Token (JWT).
TYPE:
|
Source code in webtool/auth/manager.py
decode
¶
Decodes a JSON Web Token (JWT) and returns the claims if valid.
PARAMETER | DESCRIPTION |
---|---|
token
|
The JWT string to be decoded.
TYPE:
|
secret_key
|
The secret key used to validate the JWT signature.
TYPE:
|
algorithm
|
The signing algorithm used for verification JWT, defaults to 'ES384'.
TYPE:
|
at_hash
|
Optional parameter for additional handling of access tokens.
TYPE:
|
raise_error
|
Optional parameter for additional handling of error messages.
TYPE:
|
options
|
Optional parameters for additional handling of additional errors.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
A dictionary containing the claims if the token is valid, or None if the token is invalid or expired.
TYPE:
|