Misleading "incorrect username or password" error with an HTTP token realm (Harbor)

Open
#937 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
docker, kubernetes, linux, macos, nginx, rust

Research direction

The insecure-realm check lives in the registry authentication code of the Rust project; start by searching for where the WWW-Authenticate Bearer realm is parsed and where credentials are refused for non-HTTPS realms. Reproduce with a mock registry that returns a plain-HTTP realm and confirm the surfaced message. Done when the error names the insecure token realm instead of reporting incorrect credentials, and the existing auth tests still pass.

Written by the indexing model from the issue text.

Description

Description

docker login reports incorrect credentials when a Harbor registry behind an HTTPS reverse proxy advertises an HTTP token realm. Docker Desktop login succeeds, and Kiri pull/push also worked using existing credentials. Kiri login to demo.goharbor.io succeeds.

Environment

Harbor 2.13.2, Nginx reverse proxy with a Let's Encrypt certificate. The registry is accessed via HTTPS.

Reproduction
docker --context kiri login harbor.example.com -u testuser

Actual error:

Error response from daemon: unauthorized: incorrect username or password

Inspect the registry challenge:

curl -sS -D - -o /dev/null https://harbor.example.com/v2/
WWW-Authenticate: Bearer realm="http://harbor.example.com:8091/service/token",service="harbor-registry"
Confirmed solution

Set the public HTTPS URL in harbor.yml:

external_url: https://harbor.example.com

Regenerate the configuration with ./prepare and restart Harbor. Kiri login then succeeds.

Suggestion

Refusing to send credentials over plain HTTP is correct. However, the password error is misleading. Please explicitly report the insecure token realm and, if useful, document the Harbor external_url fix.

I noticed that the current main branch already appears to return a more specific error for insecure realms. If this is already fixed, feel free to close this issue; I wanted to leave a searchable record of the cause and solution for other Harbor users.

Dominant language
Rust
Stars
7.5k
Forks
329
Avg merge
10h 44m
Merged PRs (30d)
347

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libracoder/kiri

All issues in libracoder/kiri

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.