feat(auth): add --no-localhost flag to gws auth login#534
feat(auth): add --no-localhost flag to gws auth login#534qihan-bot wants to merge 9 commits intogoogleworkspace:mainfrom
Conversation
This commit introduces a `--no-localhost` flag to the `login` subcommand, which enables an out-of-band (OOB) OAuth flow. When this flag is provided, the CLI will output an authentication URL and prompt the user to paste the authorization code back into the terminal. This is particularly useful in environments where a local redirect server cannot be started or accessed, similar to `clasp login --no-localhost`. The flag adjusts the redirect URIs to prioritize `urn:ietf:wg:oauth:2.0:oob` and configures the `InstalledFlowAuthenticator` to use `InstalledFlowReturnMethod::Interactive` instead of `HTTPRedirect`.
This commit introduces a `--no-localhost` flag to the `login` subcommand, which enables an out-of-band (OOB) OAuth flow. When this flag is provided, the CLI will output an authentication URL and prompt the user to paste the authorization code back into the terminal. This is particularly useful in environments where a local redirect server cannot be started or accessed, similar to `clasp login --no-localhost`. The flag adjusts the redirect URIs to prioritize `urn:ietf:wg:oauth:2.0:oob` and configures the `InstalledFlowAuthenticator` to use `InstalledFlowReturnMethod::Interactive` instead of `HTTPRedirect`.
This commit introduces a `--no-localhost` flag to the `login` subcommand, which enables an out-of-band (OOB) OAuth flow. When this flag is provided, the CLI will output an authentication URL and prompt the user to paste the authorization code back into the terminal. This is particularly useful in environments where a local redirect server cannot be started or accessed, similar to `clasp login --no-localhost`. The flag adjusts the redirect URIs to prioritize `urn:ietf:wg:oauth:2.0:oob` and configures the `InstalledFlowAuthenticator` to use `InstalledFlowReturnMethod::Interactive` instead of `HTTPRedirect`. Additionally, it extracts the authorization code from a full redirect URL pasted by the user.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Resolved an unclosed delimiter compiler error that was caused by a formatting/merge conflict in `src/auth_commands.rs`. Tests pass, and `cargo fmt` has been run on all code.
Resolved the unclosed delimiter in `src/auth_commands.rs` that broke CI. Verified by running `cargo fmt --all -- --check`, `cargo check`, `cargo build`, and `cargo test`.
Extracted the URL parsing logic for the out-of-band `--no-localhost` OAuth flow into a separate helper `extract_code_from_input` and added tests to prevent coverage drop.
Extracted the argument parsing logic from `handle_login` into a new `parse_login_args` helper and added unit tests to cover the extraction of `--account`, `--services`, and the new `--no-localhost` flag. This resolves the Codecov coverage regression.
Resolved CI formatting checks by running `cargo fmt` after adding the new unit tests for `parse_login_args`.
🦋 Changeset detectedLatest commit: 210bee2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request introduces a new --no-localhost flag to the gws auth login command, enabling an out-of-band (OOB) OAuth authentication flow. This change allows users to authenticate without requiring a local HTTP server, by prompting them to manually paste the authorization code after opening the provided URL. The implementation involves updating the help message, refactoring argument parsing into a new parse_login_args function, modifying the present_user_url delegate to handle interactive input, and conditionally configuring the OAuth redirect URIs and return method. New unit tests have been added to cover the argument parsing and code extraction logic.
Summary
--no-localhostflag togws auth loginfor environments without a local HTTP server (SSH sessions, headless servers, containers)handle_loginargument parsing and OOB code extractioncargo fmtfor CI complianceMotivation
Users running
gwsin headless/remote environments (SSH, Docker, CI) cannot use the default localhost redirect for OAuth. The--no-localhostflag provides a manual code entry flow that works in any terminal.Test plan
add-no-localhost-flag.md)parse_login_argsand OOB code extractioncargo fmtapplied