djblets.secrets.token_generators.base¶
Base class for token generators.
New in version 3.0.
- class BaseTokenGenerator¶
Bases:
object
A base class for token generators.
These are used to generate and validate access tokens.
At the very least, subclasses must set:
as well as implement the
create_token()
andvalidate_token()
methods.New in version 3.0.
- token_generator_id: Optional[str] = None¶
The unique ID of the token generator, for registration purposes.
- Type:
- create_token(token_info: Dict[str, Any] = {}, **kwargs) str ¶
Create a new token.
Subclasses must override this to actually create the token.
- Parameters:
- Returns:
The token that was created.
- Return type:
- Raises:
NotImplementedError – The subclass did not implement this method.
- validate_token(token: str, token_info: Dict[str, Any] = {}, **kwargs) bool ¶
Validate the token.
This should return a bool indicating whether the given token is a valid token that could have been generated by this generator.
Subclasses must override this to actually validate the token.
- Parameters:
- Returns:
Whether the token is a valid token from this generator.
- Return type:
- Raises:
NotImplementedError – The subclass did not implement this method.
- __annotations__ = {'token_generator_id': typing.Optional[str]}¶