TokenStrategy
fastauth.strategy.base.TokenStrategy
TokenStrategy(config)
Source code in fastauth/strategy/base.py
10 11 |
|
read_token
abstractmethod
async
read_token(token, **kwargs)
Decode token and try fetch User model
PARAMETER | DESCRIPTION |
---|---|
token
|
Token string
TYPE:
|
kwargs
|
Extra data
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
Token payload dict |
Source code in fastauth/strategy/base.py
13 14 15 16 17 18 19 20 21 |
|
write_token
abstractmethod
async
write_token(user, token_type, **kwargs)
Create token from User model
PARAMETER | DESCRIPTION |
---|---|
user
|
User model
TYPE:
|
token_type
|
Token type
TYPE:
|
kwargs
|
Extra user data
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
str
|
Token string |
Source code in fastauth/strategy/base.py
23 24 25 26 27 28 29 30 31 32 |
|
JWT Token Strategy
fastauth.strategy.jwt.JWTStrategy
JWTStrategy(config)
Bases: Generic[UP, ID]
, TokenStrategy[UP, ID]
Source code in fastauth/strategy/jwt.py
16 17 18 |
|
read_token
async
read_token(token, **kwargs)
Read jwt token and return the payload
PARAMETER | DESCRIPTION |
---|---|
token
|
jwt token string
TYPE:
|
kwargs
|
Extra PyJWT decoder data(audience, leeway, issuer, etc.)
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
Token payload dict |
RAISES | DESCRIPTION |
---|---|
InvalidToken
|
If the token is invalid |
Source code in fastauth/strategy/jwt.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
write_token
async
write_token(user, token_type, **kwargs)
Write jwt token for the user model
PARAMETER | DESCRIPTION |
---|---|
user
|
User model
TYPE:
|
token_type
|
Token type (access or refresh)
TYPE:
|
kwargs
|
extra token data(audience, max_age, headers, extra_data)
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
str
|
Token string |
Source code in fastauth/strategy/jwt.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|