Skip to content

fix(api): API key replaces Basic Auth on /api/v1 when set - #91

Merged
overcuriousity merged 2 commits into
masterfrom
fix/api-key-basic-auth-conflict
Oct 10, 2026
Merged

overcuriousity merged 2 commits into
masterfrom
fix/api-key-basic-auth-conflict

Conversation

@overcuriousity

Copy link
Copy Markdown
Owner

Fixes the credential conflict on /api/v1: Basic Auth and the API key both used the Authorization header, so with both configured no request could pass.

Behaviour (per CTO decision, MIK-87):

  • BITVAULT_API_KEY set → bearer token is the only /api/v1 credential; Basic Auth middleware is skipped on that scope. Wrong/missing bearer → 401 API_KEY_REQUIRED.
  • No key, Basic Auth configured → Basic Auth still guards /api/v1 (except /health).
  • Neither → open (unchanged).
  • Web UI Basic Auth unchanged.

Changes

  • src/util/auth.rs: api_scope_uses_basic_auth(api_key, basic_username); src/main.rs uses it for the /api/v1 Condition.
  • src/endpoints/api.rs: tests api_key_replaces_basic_auth_on_api_scope, basic_auth_guards_api_scope_without_api_key.
  • README.md, openapi.yaml: auth docs rewritten to match.

Verified locally: cargo fmt --check, cargo test endpoints::api (4/4), cargo clippy --all-targets -D warnings clean.

🤖 Generated with Claude Code

overcuriousity and others added 2 commits October 10, 2026 21:44
Both schemes use the Authorization header, so with BITVAULT_API_KEY and
Basic Auth configured no request could pass. A configured key is now the
sole API credential; without a key Basic Auth still guards /api/v1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 21:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@overcuriousity
overcuriousity merged commit ab6654d into master Oct 10, 2026
4 checks passed
@overcuriousity
overcuriousity deleted the fix/api-key-basic-auth-conflict branch October 10, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants