Jump to >

djblets.secrets.token_generators.registry

Registry for token generators.

New in version 3.0.

class TokenGeneratorRegistry[source]

Bases: djblets.registries.mixins.ExceptionFreeGetterMixin[djblets.secrets.token_generators.base.BaseTokenGenerator], djblets.registries.registry.Registry[djblets.secrets.token_generators.base.BaseTokenGenerator]

Registry for managing token generators.

New in version 3.0.

lookup_attrs: Sequence[str] = ['token_generator_id'][source]

A list of attributes that items can be looked up by.

Type

list of str

get_token_generator(token_generator_id: str) Optional[djblets.secrets.token_generators.base.BaseTokenGenerator][source]

Return a token generator with the specified ID.

Parameters

token_generator_id (str) – The ID of the token generator.

Returns

The token generator instance, or None if not found.

Return type

djblets.secrets.token_generators.BaseTokenGenerator

get_default() djblets.secrets.token_generators.base.BaseTokenGenerator[source]

Return the default token generator.

The default token generator ID can be set in settings.DJBLETS_DEFAULT_API_TOKEN_GENERATOR. If not set the default token generator will be VendorChecksumTokenGenerator.

Returns

The default token generator.

Return type

djblets.secrets.token_generators.BaseTokenGenerator

get_defaults()[source]

Return the default token generators.

Returns

The list of default token generators.

Return type

list of djblets.secrets.token_generators.BaseTokenGenerator

get_deprecated_token_generators() Set[str][source]

Return deprecated token generator IDs.

The set of deprecated token generator IDs can be set in settings.DJBLETS_DEPRECATED_TOKEN_GENERATORS. By default the set will contain the LegacySHA1TokenGenerator’s ID.

New in version 3.1.

Returns

A set of deprecated token generator IDs.

Return type

set of str

__annotations__ = {'_items': 'Set[RegistryItemType]', '_populated': 'bool', '_registry': 'Dict[str, Dict[object, RegistryItemType]]', 'already_registered_error_class': 'Type[AlreadyRegisteredError]', 'default_errors': 'Dict[str, str]', 'errors': 'Dict[str, str]', 'item_name': 'Optional[str]', 'lookup_attrs': 'Sequence[str]', 'lookup_error_class': 'Type[ItemLookupError]'}
__orig_bases__ = (djblets.registries.mixins.ExceptionFreeGetterMixin[djblets.secrets.token_generators.base.BaseTokenGenerator], djblets.registries.registry.Registry[djblets.secrets.token_generators.base.BaseTokenGenerator])
__parameters__ = ()