Skip to content

fix(security): auth middleware fail-close, allow_no_auth flag, public OAuth routes#1117

Open
AlexZander85 wants to merge 2 commits intoRightNow-AI:mainfrom
AlexZander85:fix/auth-middleware-fail-close-v2
Open

fix(security): auth middleware fail-close, allow_no_auth flag, public OAuth routes#1117
AlexZander85 wants to merge 2 commits intoRightNow-AI:mainfrom
AlexZander85:fix/auth-middleware-fail-close-v2

Conversation

@AlexZander85
Copy link
Copy Markdown
Contributor

Summary

  • Fix auth bypass: add allow_no_auth: bool to AuthConfig (default true). When false, middleware fails closed if no API key is configured
  • Log warning when allow_no_auth=true and no key is set (existing behavior preserved but now explicit)
  • Add 6 OAuth provider routes to middleware public endpoint list (codex, gemini, qwen, minimax)
  • Add 5 middleware unit tests covering fail-close, fail-open, public routes, missing key scenarios

Changed files

  • crates/openfang-api/src/middleware.rs - allow_no_auth logic, 6 new public routes, 5 unit tests
  • crates/openfang-api/src/server.rs - wiring allow_no_auth from config
  • crates/openfang-types/src/config.rs - allow_no_auth: bool in AuthConfig (default true)
  • crates/openfang-api/tests/api_integration_test.rs - allow_no_auth field in AuthState construction

Test plan

  • cargo build --workspace --lib - compiles clean
  • cargo test -p openfang-api -p openfang-runtime -p openfang-types - all 910+ tests pass
  • cargo clippy --workspace --all-targets -- -D warnings - zero warnings

Part of #1030 OAuth providers review split (PR 3 of 3)

…with vault token persistence

Adds a new oauth_providers module with device-flow implementations for
OpenAI Codex, Google Gemini, Qwen (DashScope), and MiniMax. Tokens are
persisted to both the in-memory vault and secrets.env for dual-write
durability. The Copilot flow is preserved unchanged.

New routes:
  POST /api/providers/openai-codex/oauth/start
  GET  /api/providers/openai-codex/oauth/poll/{poll_id}
  POST /api/providers/gemini-oauth/oauth/start
  GET  /api/providers/gemini-oauth/oauth/poll/{poll_id}
  POST /api/providers/qwen-oauth/oauth/start
  GET  /api/providers/qwen-oauth/oauth/poll/{poll_id}
  POST /api/providers/minimax-oauth/oauth/start
  GET  /api/providers/minimax-oauth/oauth/poll/{poll_id}

UI: Settings page shows Login buttons for each provider with device-code
display and polling feedback.
… OAuth routes

- Add allow_no_auth to AuthConfig (default true) for backward compatibility
- Replace fail-open with fail-close+opt-in: when allow_no_auth=false and no API
  key is set, return 401 instead of allowing all access (RightNow-AI#1034)
- Add codex/gemini/qwen/minimax OAuth routes to middleware public endpoint list
- Add auth middleware unit tests
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.

1 participant