Auth - service¶
JWTService
¶
JWTService(
cache,
secret_key="",
access_token_expire_time=3600,
refresh_token_expire_time=604800,
jwt_manager=None,
algorithm=None,
)
Bases: BaseJWTService[PayloadT]
, PayloadFactory
, Generic[PayloadT]
generate access token, refresh token
Info
Most cases, the algorithm
parameter is automatically determined based on the secret_key
,
so there is no need to specify the algorithm
.
If using an asymmetric encryption key, providing the secret_key
will automatically use the correct public key.
The secret_key
can be generated using the webtools.utils
package.
Source code in webtool/auth/service.py
refresh_token_expire_time
instance-attribute
¶
create_token
async
¶
Create Access and Refresh Tokens.
PARAMETER | DESCRIPTION |
---|---|
data
|
must include 'sub' field.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
Access, Refresh Token.
TYPE:
|
Source code in webtool/auth/service.py
validate_access_token
async
¶
Validate Access Token.
PARAMETER | DESCRIPTION |
---|---|
access_token
|
Access Token.
TYPE:
|
options
|
Optional parameters for additional handling of additional errors.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[PayloadT]
|
Optional[PayloadType]: Access Token Data |
Source code in webtool/auth/service.py
validate_refresh_token
async
¶
Validate Refresh Token.
PARAMETER | DESCRIPTION |
---|---|
refresh_token
|
Access Token.
TYPE:
|
options
|
Optional parameters for additional handling of additional errors.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[PayloadT]
|
Optional[PayloadType]: Refresh Token Data |
Source code in webtool/auth/service.py
invalidate_token
async
¶
Invalidates the Refresh token and the Access token issued with it .
PARAMETER | DESCRIPTION |
---|---|
refresh_token
|
Access Token.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
Returns
TYPE:
|
Source code in webtool/auth/service.py
update_token
async
¶
Invalidates the Refresh token and the Access token issued with it and issue New Access and Refresh Tokens.
PARAMETER | DESCRIPTION |
---|---|
data
|
Token data.
TYPE:
|
refresh_token
|
Access Token.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
Access, Refresh Token.
TYPE:
|
Source code in webtool/auth/service.py
RedisJWTService
¶
RedisJWTService(
cache,
secret_key="",
access_token_expire_time=3600,
refresh_token_expire_time=604800,
jwt_manager=None,
algorithm=None,
)
Bases: JWTService
, Generic[PayloadT]
generate access token, refresh token
Info
Most cases, the algorithm
parameter is automatically determined based on the secret_key
,
so there is no need to specify the algorithm
.
If using an asymmetric encryption key, providing the secret_key
will automatically use the correct public key.
The secret_key
can be generated using the webtools.utils
package.
Source code in webtool/auth/service.py
refresh_token_expire_time
instance-attribute
¶
create_token
async
¶
Create Access and Refresh Tokens.
PARAMETER | DESCRIPTION |
---|---|
data
|
must include 'sub' field.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
Access, Refresh Token.
TYPE:
|
Source code in webtool/auth/service.py
validate_access_token
async
¶
Validate Access Token.
PARAMETER | DESCRIPTION |
---|---|
access_token
|
Access Token.
TYPE:
|
options
|
Optional parameters for additional handling of additional errors.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[PayloadT]
|
Optional[PayloadType]: Access Token Data |
Source code in webtool/auth/service.py
validate_refresh_token
async
¶
Validate Refresh Token.
PARAMETER | DESCRIPTION |
---|---|
refresh_token
|
Access Token.
TYPE:
|
options
|
Optional parameters for additional handling of additional errors.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[PayloadT]
|
Optional[PayloadType]: Refresh Token Data |
Source code in webtool/auth/service.py
update_token
async
¶
Invalidates the Refresh token and the Access token issued with it and issue New Access and Refresh Tokens.
PARAMETER | DESCRIPTION |
---|---|
data
|
Token data.
TYPE:
|
refresh_token
|
Access Token.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
Access, Refresh Token.
TYPE:
|
Source code in webtool/auth/service.py
invalidate_token
async
¶
Invalidates the Refresh token and the Access token issued with it .
PARAMETER | DESCRIPTION |
---|---|
refresh_token
|
Access Token.
TYPE:
|
refresh_jti_to_invalidate
|
Refresh Token JTI to invalidate can be found using search_token.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
Returns
TYPE:
|
Source code in webtool/auth/service.py
search_token
async
¶
Returns the JTI of the refresh token issued with the token’s sub claim
PARAMETER | DESCRIPTION |
---|---|
refresh_token
|
Access Token.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[bytes]
|
list[bytes]: Returns a list containing JTIs on success. |