pyauthorizer.encryptor package¶
- pyauthorizer.encryptor.get_encryptor(target)[source]¶
Get the encryptor corresponding to the target.
- Parameters:
target (str) – The target for which to retrieve the encryptor.
- Returns:
An instance of the encryptor class corresponding to the target, or None if no encryptor is found.
- Return type:
BaseEncryptor | None
Subpackages¶
Submodules¶
pyauthorizer.encryptor.base module¶
- class pyauthorizer.encryptor.base.BaseEncryptor[source]¶
Bases:
ABC
Abstract base class for encryptors.
- validate_token(token, data)[source]¶
Validates a token by comparing its decrypted data with the provided data dictionary.
- Parameters:
- Returns:
- The status of the token after validation. Possible values are:
TokenStatus.INVALID: If the token data does not match the provided data dictionary.
TokenStatus.ACTIVE: If the token is valid and active.
TokenStatus.EXPIRED: If the token is valid but has expired.
- Return type:
- class pyauthorizer.encryptor.base.Token(secret_key, token, expiry)[source]¶
Bases:
object
Class representing a token.
- Parameters:
- class pyauthorizer.encryptor.base.TokenStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Enum representing the status of a token.
- ACTIVE = 1¶
Token is valid and active.
- EXPIRED = 2¶
Token is valid but has expired.
- INVALID = 3¶
Token is invalid.
pyauthorizer.encryptor.interface module¶
- pyauthorizer.encryptor.interface.get_encryptor(target)[source]¶
Get the encryptor corresponding to the target.
- Parameters:
target (str) – The target for which to retrieve the encryptor.
- Returns:
An instance of the encryptor class corresponding to the target, or None if no encryptor is found.
- Return type:
BaseEncryptor | None
pyauthorizer.encryptor.plugin_manager module¶
- class pyauthorizer.encryptor.plugin_manager.EncryptorPlugins[source]¶
Bases:
PluginManager
Plugin manager for encryptor plugins
- class pyauthorizer.encryptor.plugin_manager.PluginManager(group_name)[source]¶
Bases:
ABC
Base class for managing plugins
- Parameters:
group_name (str) – The name of the plugin group.
- property registry: dict[str, EntryPoint]¶
Get the plugin registry
pyauthorizer.encryptor.utils module¶
- pyauthorizer.encryptor.utils.decrypt_with_cipher(token, cipher)[source]¶
Decrypts a token using the provided cipher and returns the decrypted token data.
- Parameters:
token (Token) – The token to be decrypted.
cipher (cryptography.fernet.Fernet|cryptography.fernet.MultiFernet) – The cipher object used for decryption.
- Returns:
The decrypted token data as a dictionary.
- Return type: