djblets.secrets.token_generators.legacy_sha1¶
Token generator for legacy SHA1 tokens.
New in version 3.0.
- class LegacySHA1TokenGenerator[source]¶
Bases:
BaseTokenGenerator
Token generator for legacy SHA1 tokens.
The support for SHA1 tokens will soon be deprecated in favour of
VendorChecksumTokenGenerator
tokens.New in version 3.0.
- token_generator_id: Optional[str] = 'legacy_sha1'[source]¶
The unique ID of the token generator, for registration purposes.
- Type:
- create_token(token_info: Dict[str, Any] = {}, **kwargs) str [source]¶
Create a SHA1 token.
- Parameters:
token_info (
dict
) –A dictionary that must contain the following information about the token:
- Keys:
attempt (
int
) – The number of attempts that have been made to create a token. This is used in the raw token string.user (
django.contrib.auth.models.User
) – The user that the token belongs to.
**kwargs (
dict
, unused) – Additional keyword arguments.
- Returns:
The token value.
- Return type:
- Raises:
KeyError – The
token_info
dictionary is missing a required key.
- validate_token(token: str, token_info: Dict[str, Any] = {}, **kwargs) bool [source]¶
Validate the token to see if it is a valid token from this generator.
- __annotations__ = {'token_generator_id': 'Optional[str]'}¶