pymap.token
¶
- pymap.token.tokens: Plugin[TokensBase] = Plugin('pymap.token')¶
Registers token plugins.
- class pymap.token.TokensBase(config)[source]¶
Base class for token types registered by
tokens
.- Parameters:
config (IMAPConfig) – The IMAP configuration object.
- class pymap.token.AllTokens(config)[source]¶
Uses
tokens
to support all registered token types.For token creation, the
default
token plugin is used. For token parsing, each token plugin is tried until one succeeds.- Parameters:
config (IMAPConfig)
- get_login_token(identifier, authcid, key, *, authzid=None, location=None, expiration=None)[source]¶
Returns a new token string that encapsulates the provided login data, or
None
if tokens are not supported.- Parameters:
identifier (str) – Any string that can facilitate the lookup of key.
authcid (str) – The authentication identity of the token.
key (bytes) – The private key used to create and verify the token.
authzid (str | None) – Limits the token to authorizing as this identity.
location (str | None) – Arbitrary metadata string, application-specific.
expiration (datetime | None) – An expiration when this token shall no longer be valid.
- Return type:
str | None
- get_admin_token(admin_key, *, authzid=None, location=None, expiration=None)[source]¶
Returns a new token string that encapsulates the provided login data, or
None
if tokens are not supported. This token uses a special private admin key that grants unrestricted access.- Parameters:
- Return type:
str | None
- parse(authzid, token, *, admin_keys=frozenset({}))[source]¶
Parses a token string to produce authentication credentials.
- Parameters:
- Raises:
ValueError – The token string was not valid.
- Return type:
TokenCredentials