Commit Graph
7 Commits
Author SHA1 Message Date
Sebastiaan van Stijn df9a0f430f 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.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-10-19 21:07:33 +02:00
Sebastiaan van Stijn fa65e9a3a0 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.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-10-19 21:07:27 +02:00
Sebastiaan van Stijn dc66c2a8d0 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.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-10-19 21:05:24 +02:00
Sebastiaan van Stijn ae317ab44a 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…

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-10-19 21:05:18 +02:00
Sebastiaan van Stijn 3f2ad8bf05 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.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-10-19 20:49:29 +02:00
Sebastiaan van Stijn f6b90bc253 add internal fork of docker/docker/registry
This adds an internal fork of [github.com/docker/docker/registry], taken
at commit [moby@f651a5d]. Git history  was not preserved in this fork,
but can be found using the URLs provided.

This fork was created to remove the dependency on the "Moby" codebase,
and because the CLI only needs a subset of its features. The original
package was written specifically for use in the daemon code, and includes
functionality that cannot be used in the CLI.

[github.com/docker/docker/registry]: https://pkg.go.dev/github.com/docker/docker@v28.3.2+incompatible/registry
[moby@49306c6]: https://github.com/moby/moby/tree/49306c607b72c5bf0a8e426f5a9760fa5ef96ea0/registry

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-24 19:59:17 +02:00
Sebastiaan van Stijn 479c7add4d cli/internal/oauth: move to top-level "internal"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-06 20:09:28 +02:00