Add a management command for invalidating tokens
Review Request #12481 — Created July 21, 2022 and submitted
This change adds an
rb-site manage /path/to/site invalidate-api-tokens
command
that allows administrators to invalidate the API tokens for a set of users. Now
tokens can be invalidated individually via the API, or in batch with this
command.
Manually tested the command and checked that the right tokens were
being invalidated.
Summary |
---|
Description | From | Last Updated |
---|---|---|
Can we add module docstrings to the new empty __init__.py files? |
|
|
Should I write documentation for this here: https://www.reviewboard.org/docs/manual/4.0/admin/sites/management-commands/? |
![]() |
|
We should gettext_lazy() this. |
|
|
I wonder if instead we should go by usernames? |
|
|
We should _(...) all the help text. |
|
|
Needs a Raises for CommandError. |
|
|
We should end the strings with a period, make them proper sentences. |
|
|
No blank line here. |
|
|
Doesn't this already basically exist if you call invalidate_tokens with the default args (i.e. users=None)? |
|
|
I wonder if it wouldn't be better to have invalidate_tokens take a list of user PKs. That way we could … |
|
|
I think there's one-too-many ( and ). I don't think you'll need the list() though. The * should still work … |
|
|
You can avoid the list comprehension. Given we're working with set, I'd also sort. Also, both variables are already a … |
|
|
The % should be on the next line. |
|
-
-
-
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 1) Doesn't this already basically exist if you call
invalidate_tokens
with the default args (i.e.users=None
)? -
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 1) I wonder if it wouldn't be better to have
invalidate_tokens
take a list of user PKs. That way we could avoid the entireUsers
query.
-
-
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 1) We should
gettext_lazy()
this. -
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 1) I wonder if instead we should go by usernames?
-
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 1) We should
_(...)
all the help text. -
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 1) Needs a
Raises
forCommandError
. -
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 1) We should end the strings with a period, make them proper sentences.
-
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 1) No blank line here.

Commits: |
|
||||||
---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+274) |
Checks run (2 succeeded)
-
-
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 2) I think there's one-too-many
(
and)
.I don't think you'll need the
list()
though. The*
should still work with the return type forvalues_list()
. -
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 2) You can avoid the list comprehension.
Given we're working with
set
, I'd also sort.Also, both variables are already a
set
.So:
', '.join(sorted(usernames - found_usernames))
-
reviewboard/webapi/management/commands/invalidate-api-tokens.py (Diff revision 2) The
%
should be on the next line.

Commits: |
|
||||||
---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+290) |