Skip to content

401 response includes WWW-Authenticate header#457

Merged
stefanvi merged 3 commits into
OpenLEADR:mainfrom
joaoag:add-header-for-401-responses
Jun 30, 2026
Merged

401 response includes WWW-Authenticate header#457
stefanvi merged 3 commits into
OpenLEADR:mainfrom
joaoag:add-header-for-401-responses

Conversation

@joaoag

@joaoag joaoag commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds WWW-Authenticate: Bearer realm="VTN" header to all 401 responses from AppError.
  • The OAuth token endpoint (ResponseOAuthError in auth.rs) already returned this header for InvalidClient, so this PR closes the gap for bearer token auth failures (invalid/expired JWT, unparseable subject).

Approach

  • Considered restructuring the AppError::into_response() match to return response tuples from every arm, but instead went for inserting header post-match, based on the response status code.
  • This keeps the existing match structure untouched, at the cost of inconsistency, with a special step just for the Unauthorized arm
  • Very open to other ways of doing this!

Changes

  • error.rs: Insert WWW-Authenticate header after response construction when status is 401
  • user.rs: Add header assertions to delete_credential and delete_user tests

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.30%. Comparing base (169eb52) to head (02da5df).

Files with missing lines Patch % Lines
openleadr-vtn/src/error.rs 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #457      +/-   ##
==========================================
- Coverage   83.34%   83.30%   -0.04%     
==========================================
  Files          50       50              
  Lines        7353     7360       +7     
==========================================
+ Hits         6128     6131       +3     
- Misses       1225     1229       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread openleadr-vtn/src/error.rs
@stefanvi stefanvi linked an issue Jun 30, 2026 that may be closed by this pull request
Signed-off-by: João Abbott-Gribben <joao.abbott.gribben@gmail.com>
@stefanvi stefanvi enabled auto-merge June 30, 2026 11:54
@stefanvi stefanvi added this pull request to the merge queue Jun 30, 2026
Merged via the queue into OpenLEADR:main with commit 6b03d35 Jun 30, 2026
15 checks passed
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.

Return WWW-Authenticate header

2 participants