Introduce client API tokens.
Review Request #13032 — Created May 19, 2023 and submitted
This change introduces client API tokens which are API tokens that belong
specifically to a given client. Clients (e.g. RBTools) will use these tokens
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 | ID |
---|---|
98e1dc56139935bbc7bb26c58727b00680da7888 |
Description | From | Last Updated |
---|---|---|
To help with readability, can you update this to uncollapse newlines? So, one '\n' for each blank line, instead of … |
chipx86 | |
The {% should be unindented. Same with the closing tag. |
chipx86 | |
Let's move these together onto the same line, to reduce the number of newlines we end up with. Text e-mails … |
chipx86 | |
We only use this for typing, so let's move this into TYPE_CHECKING. |
chipx86 | |
For now, we need to use Union[...] instead of |. The | syntax is new as of Python 3.10 (technically … |
chipx86 | |
Can we call this client_name? |
chipx86 | |
Hmm, I don't think this is particularly future-proof. This only works if the only thing in extra data is the … |
david | |
This can fail with a WebAPITokenGenerationError exception. We should either document a re-raise, or handle it. |
chipx86 | |
Can we call this client_name? I want to give us some room to expand on this if we need to … |
chipx86 | |
Swap these. |
chipx86 | |
datetime and typing should be in their own import group at the top. |
chipx86 | |
This can just be super().setUp(). |
chipx86 | |
It doesn't look like this ever changes. Maybe just make it a constant on the class? |
chipx86 |
-
-
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.
-
-
To help with readability, can you update this to uncollapse newlines? So, one
'\n'
for each blank line, instead of...\n\n'
. -
-
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.
-
-
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). -
-
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). -
-
-
-
- Change Summary:
-
- Fix up some formatting for emails and their tests.
- Better querying for getting client tokens.
- Switch to
client_name
instead of client. - Document that
get_or_create_client_token
raisesWebAPITokenGenerationError
.
- Description:
-
~ 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. ~ This change introduces client API tokens which are API tokens that belong
~ specifically to a given client. Clients (e.g. RBTools) will use these tokens ~ 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. - Commits:
-
Summary ID 3964adb643332b05aee8ff74d4df3722e8326b6e 98e1dc56139935bbc7bb26c58727b00680da7888 - Diff:
-
Revision 2 (+1016 -50)