Skip to content

OAuth: an unreachable auth server refuses the token, whatever its address - #315

Merged
vsilent merged 1 commit into
devfrom
fix/oauth-no-test-user-fallback
Oct 30, 2026
Merged

vsilent merged 1 commit into
devfrom
fix/oauth-no-test-user-fallback

Conversation

@vsilent

@vsilent vsilent commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Found by the user.role security audit.

Problem. fetch_user (src/middleware/authentication/method/f_oauth.rs) handled a failed request to the auth server (connection error) differently depending on the address. When auth_url started with http://127.0.0.1: or contained localhost, it returned a fixed user test_user_id (role group_user) for any bearer token. Any string in Authorization: Bearer then acted as that one shared account, with its projects and deployments. Settings::default() has auth_url: http://localhost:8080/me, and the service runs on those defaults whenever its configuration does not deserialize (see the companion PR).

Change. That branch is removed. An unreachable auth server is now the same error for every address, and the middleware refuses the request. A request with no Authorization header still goes through anonym, as before.

Tests

  • an_unreachable_loopback_auth_server_refuses_the_token (127.0.0.1 and localhost, a port with nothing listening). It failed against the old code with an unverified token became user Ok("test_user_id") and passes now.
  • Locally: cargo test --lib passes (2305). cargo nextest run --tests -E 'not binary(bdd)' passes all 2977, so no test relied on the fallback. cargo test --test bdd passes 334 scenarios.

🤖 Generated with Claude Code

…ress

fetch_user returned a shared `test_user_id` (role group_user) for any
bearer token when the request to the auth server failed and auth_url was
loopback or contained "localhost" - which Settings::default() is. Any
string in `Authorization: Bearer` then acted as that one account. The
branch was a test convenience compiled into production; the test harness
runs its own /me mock and never needed it.

Now it is the same error as for any other address, and the middleware
refuses the request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vsilent
vsilent merged commit ad9690f into dev Oct 30, 2026
11 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.

2 participants