RequestToken#
authx.schema.RequestToken #
Bases: BaseModel
Verify and validate a token with comprehensive security checks.
Performs multiple layers of token validation including JWT decoding, type verification, CSRF protection, and freshness checks.
PARAMETER | DESCRIPTION |
---|---|
key | The cryptographic key used for token verification.
|
algorithms | Optional list of allowed cryptographic algorithms. Defaults to HS256.
|
audience | Optional expected token audience.
|
issuer | Optional expected token issuer.
|
verify_jwt | Flag to enable JWT verification. Defaults to True.
|
verify_type | Flag to validate token type matches expected type. Defaults to True.
|
verify_csrf | Flag to perform Cross-Site Request Forgery protection. Defaults to True.
|
verify_fresh | Flag to require a fresh token. Defaults to False.
|
RETURNS | DESCRIPTION |
---|---|
A validated TokenPayload instance representing the decoded token. |
RAISES | DESCRIPTION |
---|---|
JWTDecodeError | If token decoding fails. |
TokenTypeError | If token type does not match expected type. |
FreshTokenRequiredError | If a fresh token is required but not provided. |
CSRFError | If CSRF token validation fails. |
verify #
verify(key, algorithms=None, audience=None, issuer=None, verify_jwt=True, verify_type=True, verify_csrf=True, verify_fresh=False)
Verify and validate a token with comprehensive security checks.
Performs multiple layers of token validation including JWT decoding, type verification, CSRF protection, and freshness checks.
PARAMETER | DESCRIPTION |
---|---|
key | TYPE: |
algorithms | TYPE: |
audience | TYPE: |
issuer | TYPE: |
verify_jwt | TYPE: |
verify_type | TYPE: |
verify_csrf | TYPE: |
verify_fresh | TYPE: |
PARAMETER | DESCRIPTION |
---|---|
key | The cryptographic key used for token verification. TYPE: |
algorithms | Optional list of allowed cryptographic algorithms. Defaults to HS256. TYPE: |
audience | Optional expected token audience. TYPE: |
issuer | Optional expected token issuer. TYPE: |
verify_jwt | Flag to enable JWT verification. Defaults to True. TYPE: |
verify_type | Flag to validate token type matches expected type. Defaults to True. TYPE: |
verify_csrf | Flag to perform Cross-Site Request Forgery protection. Defaults to True. TYPE: |
verify_fresh | Flag to require a fresh token. Defaults to False. TYPE: |
RETURNS | DESCRIPTION |
---|---|
TokenPayload | A validated TokenPayload instance representing the decoded token. |
RAISES | DESCRIPTION |
---|---|
JWTDecodeError | If token decoding fails. |
TokenTypeError | If token type does not match expected type. |
FreshTokenRequiredError | If a fresh token is required but not provided. |
CSRFError | If CSRF token validation fails. |