Consolidate our web login and credentials prompt auth logic.
Review Request #14575 — Created Sept. 8, 2025 and updated
The
get_authenticated_session()andBaseCommand.credentials_prompt()
functions both contain the same code for prompting users for their
username and password in the terminal. These need to be merged so we
don't have to maintain two copies of the same code. The functions aren't
direct replacements for one another though, they have different usages.
So instead we pull out the credentials prompt logic into a
credentials_prompt()function, which the above functions can call.Previously, only
get_authenticated_session()contained the logic for
kicking off web-based login. But we want to enable web-based login for
all rbt commands, not just the ones that callget_authenticated_session().
We now pull out the logic into anattempt_web_login()function that
anything can call when they want to authenticate a client using
web-based login.In the next change we'll make use of this function in a new auth handler
that lets us try web-based login if enabled before falling back on Basic
auth.
- Ran unit tests.
- Tested using all versions of the web login, open browser, and
debug/logging options and their.reviewboardrcconfig values
onrbt login,rbt postandrbt status. - Tested passing a username, a username and password, and an API
token to commands. - Tested passing the same auth credentials above to commands while
also passing --web-login (or setting in in.reviewboardrc), saw
that the auth credentials were used instead. - Tested
rbt post --diff-filename=-with piping a diff into STDIN
while also passing--web-login. Was able to login using web
auth before the rest of the command ran.
| Summary | ID |
|---|---|
| 19fc9926fa084c087b41aba9109455aa08ac768f |
| Description | From | Last Updated |
|---|---|---|
|
There's still a leading blank line here. |
|
|
|
This is missing docs for server_url and is_retry, and Returns. |
|
|
|
Let's make all these keyword-only, so we're more free to change these as needs change. |
|
|
|
This can be (Capabilities | None) = None. |
|
|
|
We should check if we're expecting web auth, and allow this to proceed if so. |
|
|
|
Can you add type hints to this while you're at it? |
|
|
|
These can use (str | None) = None |
|
|
|
Please add a blank line before the return |
|
|
|
Let's go with 5.4. |
|
|
|
We should pass server_url as a parameter, rather than using f-strings. |
|
- Change Summary:
-
Follow modern typing syntax, add missing docs, remove an unecessary newline.
- Commits:
-
Summary ID 8017ed8180ca13a888c0d0853f817dfb89f69d43 e94af4b758153d42d6e3345f54746ab287d4a8b0
Checks run (2 succeeded)
- Testing Done:
-
- Ran unit tests.
- Tested using all versions of the web login, open browser, and
debug/logging options and their.reviewboardrcconfig values
onrbt login,rbt postandrbt status.
- Tested passing a username, a username and password, and an API
token to commands.
- Tested passing the same auth credentials above to commands while
also passing --web-login (or setting in in.reviewboardrc), saw
that the auth credentials were used instead.
+ - Tested
rbt post --diff-filename=-with piping a diff into STDIN
while also passing--web-login. Was able to login using web
auth before the rest of the command ran.
- Commits:
-
Summary ID e94af4b758153d42d6e3345f54746ab287d4a8b0 e4266bee5bd93010b864fee3467ddbced6e49192
Checks run (2 succeeded)
- Change Summary:
-
Updated for the new dataclass version of RBClientWebLoginOptions.
- Commits:
-
Summary ID e4266bee5bd93010b864fee3467ddbced6e49192 1d4cb3ab8edabd74c4078416ea050b493b3e56b0