Skip to content

internal/oauth: assorted fixes and cleanups - #7414

Open
thaJeztah wants to merge 5 commits into
docker:masterfrom
thaJeztah:interactive_login_nits
Open

thaJeztah wants to merge 5 commits into
docker:masterfrom
thaJeztah:interactive_login_nits

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

internal/oauth: avoid opening browser after login cancellation

Check the context after reading stdin to avoid launching the browser
if login was canceled while waiting for ENTER.

internal/oauth: combine "web-based login" message with info note

Make the output less verbose, and combine the "web-based login" message
with the info message that's already printed.

Before this patch:

docker login

USING WEB-BASED LOGIN

i Info → To sign in with credentials on the command line, use 'docker login -u <username>'

Your one-time device confirmation code is: VVPV-NSSL
Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate

Waiting for authentication in the browser…

With this patch:

docker login

i Info → Using web-based login. To sign in with credentials on the command line, use 'docker login -u <username>'

Your one-time device confirmation code is: QBBD-PQNS
Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate

Waiting for authentication in the browser…

internal/oauth: handle error when failing to open browser

Before this patch, pressing ENTER to open the browser would silently
discard the error;

docker login

i Info → Using web-based login. To sign in with credentials on the command line, use 'docker login -u <username>'

Your one-time device confirmation code is: VGTB-VKBG
Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate

Waiting for authentication in the browser…

With this patch, a failure is printed, so that the user can manually open
the URL (or cancel the login);

docker login

i Info → Using web-based login. To sign in with credentials on the command line, use 'docker login -u <username>'

Your one-time device confirmation code is: SZFX-BSGP
Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate

Waiting for authentication in the browser…

No browser found. Open the URL above manually to continue.

internal/oauth: cleanup output

  • Remove extra newline before message
  • Include the token in the URL (instead of requiring the user to manually
    enter it on the website).
  • Improve the "call to action"; ENTER can be used to automatically open
    the browser (but the user can manually open it instead), and CTRL-C can
    be used to cancel the login.
  • Remove the "Waiting for authentication in the browser…" message, which
    could be confusing if no browser was opened (yet), instead print a message
    after successfully requesting the browser to be opened.

When running docker login;

docker login

i Info → Using web-based login. To sign in with credentials on the command line, use 'docker login -u <username>'

Your one-time device confirmation code is: NRJL-BLRL
Open this URL to authenticate: https://login.docker.com/activate?user_code=NRJL-BLRL

Press ENTER to open the URL in your browser, or Ctrl+C to cancel.

After pressing ENTER, it either prints the "success" message;

Press ENTER to open the URL in your browser, or Ctrl+C to cancel.

Opening browser…

or a failure when unable to launch a browser;

Press ENTER to open the URL in your browser, or Ctrl+C to cancel.

No browser found. Open the URL above manually to continue.

internal/oauth: remove debug logs, and move them to the caller

Wrap errors in the OAuth manager instead of logging them, preserving
the underlying cause while allowing callers to detect startup failures.

Log failures at the fallback handler and scope the device-code login
result to its branch.

Release notes (optional)

A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added this to the 29.10.0 milestone Oct 19, 2026
@codecov-commenter

codecov-commenter commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.00000% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/oauth/manager/manager.go 38.09% 13 Missing ⚠️
cli/command/registry/login.go 25.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

docker-agent

This comment was marked as outdated.

Check the context after reading stdin to avoid launching the browser
if login was canceled while waiting for ENTER.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
thaJeztah force-pushed the interactive_login_nits branch from 6e5ca0f to 6417b03 Compare October 19, 2026 18:58

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

Make the output less verbose, and combine the "web-based login" message
with the info message that's already printed.

Before this patch:

    docker login

    USING WEB-BASED LOGIN

    i Info → To sign in with credentials on the command line, use 'docker login -u <username>'

    Your one-time device confirmation code is: VVPV-NSSL
    Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate

    Waiting for authentication in the browser…

With this patch:

    docker login

    i Info → Using web-based login. To sign in with credentials on the command line, use 'docker login -u <username>'

    Your one-time device confirmation code is: QBBD-PQNS
    Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate

    Waiting for authentication in the browser…

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Before this patch, pressing `ENTER` to open the browser would silently
discard the error;

    docker login

    i Info → Using web-based login. To sign in with credentials on the command line, use 'docker login -u <username>'

    Your one-time device confirmation code is: VGTB-VKBG
    Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate

    Waiting for authentication in the browser…

With this patch, a failure is printed, so that the user can manually open
the URL (or cancel the login);

    docker login

    i Info → Using web-based login. To sign in with credentials on the command line, use 'docker login -u <username>'

    Your one-time device confirmation code is: SZFX-BSGP
    Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate

    Waiting for authentication in the browser…

    No browser found. Open the URL above manually to continue.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- Remove extra newline before message
- Include the token in the URL (instead of requiring the user to manually
  enter it on the website).
- Improve the "call to action"; ENTER can be used to automatically open
  the browser (but the user can manually open it instead), and CTRL-C can
  be used to cancel the login.
- Remove the "Waiting for authentication in the browser…" message, which
  could be confusing if no browser was opened (yet), instead print a message
  after successfully requesting the browser to be opened.

When running `docker login`;

    docker login

    i Info → Using web-based login. To sign in with credentials on the command line, use 'docker login -u <username>'

    Your one-time device confirmation code is: NRJL-BLRL
    Open this URL to authenticate: https://login.docker.com/activate?user_code=NRJL-BLRL

    Press ENTER to open the URL in your browser, or Ctrl+C to cancel.

After pressing `ENTER`, it either prints the "success" message;

    Press ENTER to open the URL in your browser, or Ctrl+C to cancel.

    Opening browser…

or a failure when unable to launch a browser;

    Press ENTER to open the URL in your browser, or Ctrl+C to cancel.

    No browser found. Open the URL above manually to continue.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Wrap errors in the OAuth manager instead of logging them, preserving
the underlying cause while allowing callers to detect startup failures.

Log failures at the fallback handler and scope the device-code login
result to its branch.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
thaJeztah force-pushed the interactive_login_nits branch from 6417b03 to df9a0f4 Compare October 19, 2026 19:07
@thaJeztah
thaJeztah requested a review from a team as a code owner October 19, 2026 19:07

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@thaJeztah
thaJeztah requested a review from vvoland October 19, 2026 19:17

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants