API reference of zsl_jwt¶
zsl_jwt.codec¶
The module provides the two main functions encode() and decode()
which encode and decode the given payload.
-
zsl_jwt.codec.CLAIMS= (u'exp', u'nbf', u'iss', u'aud', u'iat')¶ The list of JWT claim names.
-
exception
zsl_jwt.codec.ZslJwtInvalidAudienceError[source]¶ When the audience of the token does not match the audience of the profile used to decode the token.
-
zsl_jwt.codec.decode(*args, **kwargs)[source]¶ Decodes the encoded token.
Parameters: - token – The encoded token.
- jwt_configuration – The configuration, injected.
- profile – The profile name used for encoding.
Returns: The decoded payload.
-
zsl_jwt.codec.encode(*args, **kwargs)[source]¶ Encodes the payload. :param payload: The payload to be encoded. :param jwt_configuration: The JWT configuration, it is injected. :param algorithm: Algorithm name. A reasonable default is provided. :param profile: The JWT profile to be used. See
Returns: The JWT token.
zsl_jwt.configuration¶
-
class
zsl_jwt.configuration.JWTConfiguration(default_secret=None, default_profile=None, profiles=None)[source]¶ The main JWT configuration object. Consists of several token profiles used for encoding/decoding. See
zsl_jwt.configuration.JWTProfile.
-
class
zsl_jwt.configuration.JWTProfile(secret, expiration=None, not_before=None, issuer=u'zsl_jwt', audience=u'zsl_jwt', algorithm=u'HS256')[source]¶ - Each profile consits of its own
- secret and all the JWT claims definitions:
- audience: str - must match the audience in the decoding,
- issuer name: str - just an information about the token issuer,
- expiration: datetime.timedelta specifying when token becomes invalid,
- not_before: datetime.timedelta specifying when token becomes valid,
- algorithm: encryption algorithm used to create the token.
-
algorithm¶
-
audience¶ The audience of the token for which the token is intended. This must match the audience used for decoding. This is a standard JWT claim.
-
expiration¶ The time interval specifying when the token becomes invalid. The token is valid until time now + expiration. This is a standard JWT claim.
-
issuer¶ The issuer name. This is a standard JWT claim.
-
not_before¶ The time interval specifying when the token becomes valid. The token is valid from time now + not_before. This is a standard JWT claim.
-
secret¶ Key/secret used for encryption.
zsl_jwt.module¶
-
class
zsl_jwt.module.JWTModule[source]¶ JWT module activation. Add to your IoCContainer to enable JWT support.
It just provides the
zsl_jwt.configuration.JWTConfigurationso that the users may read the JWT configuration.-
JWT_CONFIG_NAME= u'JWT'¶ Variable name in config used for JWT configuration
-
zsl_jwt.configuration¶
The configuration of the authentication.
-
class
zsl_jwt.auth.configuration.AuthConfiguration(authentication_service_class)[source]¶ Auth module configuration. It holds the string identifying the authentication service.
-
authentication_service_class¶ The string identifying the class implementing the
zsl_jwt.auth.service.AuthenticationServicewhich is used for login controller.
-
zsl_jwt.auth.module¶
This ZSL module reads the auth configuration and provides
zsl_jwt.auth.configuration.AuthConfiguration and an instance of
zsl_jwt.auth.service.AuthenticationService.
zsl_jwt.auth.service¶
The abstraction of authentication service and user information.
-
class
zsl_jwt.auth.service.AuthenticationService[source]¶ The service used for verifying username and password and querying the user information.
-
class
zsl_jwt.auth.service.StandardUserInformation(username, roles, user_object)[source]¶ Standard user information - contains username, roles (list of strings) and a user object, if wanted (may be
None)-
roles¶
-
user_object¶
-
username¶
-
zsl_jwt.controller¶
Contains the login function.
-
zsl_jwt.auth.controller.authenticate(*args, **kwargs)[source]¶ The “login” function, from the given username/password returns the JWT. Use only as a delegate function in handling of tasks.
Parameters: - username –
- password –
- authentication_service – Injected. Uses
zsl_jwt.auth.service.AuthenticationServiceto query the database.
Returns: error response if the credentials are invalid or jwt.