Introduce client API tokens.
Review Request #13032 — Created May 19, 2023 and updated
Information | |
---|---|
maubin | |
Review Board | |
release-5.0.x | |
12982 | |
Reviewers | |
reviewboard | |
This change introduces client API tokens which are tokens that clients such as
RBTools can use to authenticate to Review Board. These tokens are important
for an upcoming change that allows users to authenticate clients to Review
Board via a web-based login flow.During the web-based login flow, client API tokens are automatically created
if they do not exist or if previous client tokens are expired. Each client
will have their own client tokens, and the tokens will be marked with a note
that says the token was automatically created for the given client.
- Ran unit tests.
- Tested creating a normal token and saw the right email being sent.
- Tested creating a client token and saw the right email being sent.
- Manually tested with the upcoming client web-based login flow change.
Summary |
---|
Description | From | Last Updated |
---|---|---|
To help with readability, can you update this to uncollapse newlines? So, one '\n' for each blank line, instead of … |
|
|
The {% should be unindented. Same with the closing tag. |
|
|
Let's move these together onto the same line, to reduce the number of newlines we end up with. Text e-mails … |
|
|
We only use this for typing, so let's move this into TYPE_CHECKING. |
|
|
For now, we need to use Union[...] instead of |. The | syntax is new as of Python 3.10 (technically … |
|
|
Can we call this client_name? |
|
|
Hmm, I don't think this is particularly future-proof. This only works if the only thing in extra data is the … |
|
|
This can fail with a WebAPITokenGenerationError exception. We should either document a re-raise, or handle it. |
|
|
Can we call this client_name? I want to give us some room to expand on this if we need to … |
|
|
Swap these. |
|
|
datetime and typing should be in their own import group at the top. |
|
|
This can just be super().setUp(). |
|
|
It doesn't look like this ever changes. Maybe just make it a constant on the class? |
|
-
-
reviewboard/webapi/managers.py (Diff revision 1) Hmm, I don't think this is particularly future-proof. This only works if the only thing in extra data is the client name, but we don't have exclusive control of this--a big part of the point of extra data is that any third party can do what they want with it.
I think in this case it probably makes sense to add a new field to the token model that we can query on.
-
-
reviewboard/notifications/tests/test_email_sending.py (Diff revision 1) To help with readability, can you update this to uncollapse newlines? So, one
'\n'
for each blank line, instead of...\n\n'
. -
reviewboard/templates/notifications/api_token_created.html (Diff revision 1) The
{%
should be unindented. Same with the closing tag. -
reviewboard/templates/notifications/api_token_created.txt (Diff revision 1) Let's move these together onto the same line, to reduce the number of newlines we end up with.
Text e-mails are a bit annoying to templatize.
-
reviewboard/webapi/managers.py (Diff revision 1) We only use this for typing, so let's move this into
TYPE_CHECKING
. -
reviewboard/webapi/managers.py (Diff revision 1) For now, we need to use
Union[...]
instead of|
. The|
syntax is new as of Python 3.10 (technically mypy can deal with it, but it's not safe otherwise). -
-
reviewboard/webapi/managers.py (Diff revision 1) Can we call this
client_name
? I want to give us some room to expand on this if we need to later (say, introduce aclient
dictionary with additional information, if we later find we need to track more than this). -
-
reviewboard/webapi/tests/test_managers.py (Diff revision 1) datetime
andtyping
should be in their own import group at the top. -
-
reviewboard/webapi/tests/test_managers.py (Diff revision 1) It doesn't look like this ever changes. Maybe just make it a constant on the class?
-
-
reviewboard/webapi/managers.py (Diff revision 1) This can fail with a
WebAPITokenGenerationError
exception. We should either document a re-raise, or handle it.