Fix setting the default token generator via Djblets.
Review Request #12582 — Created Sept. 6, 2022 and submitted
Information | |
---|---|
maubin | |
Djblets | |
release-3.x | |
Reviewers | |
djblets | |
The default token generator can be set via
settings.DJBLETS_DEFAULT_API_TOKEN_GENERATOR
but this currently takes a class,
which isn't safe to import viasettings.py
. With this change we instead accept
a token generator ID, which is safe and ensures that we're only using token
generators that are registered.
- Created new unit tests for getting the default token generator.
- Ran unit tests in
djblets.secrets.tests
. - Ran unit tests in
reviewboard.webapi.tests
.
Summary |
---|
Description | From | Last Updated |
---|---|---|
Instead of instantiating a second copy of this, how about just returning self.get_token_generator('vendor_checksum')? We could also just assign that to … |
|
|
Let's change this slightly, to deal with any issue of the generator ID being falsy (if, say, we wanted to … |
|
-
-
djblets/secrets/token_generators/registry.py (Diff revision 1) Instead of instantiating a second copy of this, how about just returning
self.get_token_generator('vendor_checksum')
?We could also just assign that to
token_generator
so that this function has a single return statement at the end.

Commits: |
|
||||||
---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+162 -10) |
Checks run (2 succeeded)
-
-
djblets/secrets/token_generators/registry.py (Diff revision 2) Let's change this slightly, to deal with any issue of the generator ID being falsy (if, say, we wanted to provide a default with
None
somewhere):token_generator_id = ( getattr(settings, '...', None) or VendorChecksumTokenGenerator.token_generator_id )

Commits: |
|
||||||
---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+162 -10) |