Skip to content

fix(server): enforce edge token auth in dual-auth mode#338

Closed
drew wants to merge 1 commit intoNVIDIA:mainfrom
vincentkoc:codex/propose-fix-for-gateway-auth-bypass
Closed

fix(server): enforce edge token auth in dual-auth mode#338
drew wants to merge 1 commit intoNVIDIA:mainfrom
vincentkoc:codex/propose-fix-for-gateway-auth-bypass

Conversation

@drew
Copy link
Collaborator

@drew drew commented Mar 16, 2026

Motivation

  • Dual-auth/edge mode (allow_unauthenticated=true) allowed TLS handshakes without client certs but did not enforce any application-layer token checks, leaving the gateway control plane exposed.

Description

  • Add a new edge_auth helper module (crates/openshell-server/src/edge_auth.rs) that recognizes edge tokens from cf-authorization, authorization: Bearer ..., and the CF_Authorization cookie for both HTTP and gRPC metadata.
  • Enforce application-layer checks for gRPC by wrapping the OpenShell and Inference services with an interceptor in MultiplexService that returns UNAUTHENTICATED when dual-auth mode is enabled and no edge token is present (crates/openshell-server/src/multiplex.rs).
  • Protect the WebSocket tunnel upgrade by rejecting /_ws_tunnel with HTTP 401 when dual-auth mode is enabled and the upgrade request lacks an edge token (crates/openshell-server/src/ws_tunnel.rs).
  • Wire the new module into the server crate and update the integration test expectations and architecture docs to reflect enforced application-layer auth in dual-auth mode (crates/openshell-server/src/lib.rs, crates/openshell-server/tests/edge_tunnel_auth.rs, architecture/gateway-security.md).

Testing

  • Ran cargo fmt --all which completed successfully to ensure formatting consistency.
  • Attempted targeted server checks and tests via cargo check -p openshell-server --lib and cargo test -p openshell-server edge_tunnel_auth -- --nocapture, but full test completion was blocked in this environment due to long native dependency compilation and network/tooling restrictions; partial compilation proceeded but the full test run did not finish.
  • Unit tests for the new edge_auth helpers were added and exercised locally where the build proceeded; a full CI run is recommended to validate all integration tests in a normal build environment using mise run pre-commit and cargo test -p openshell-server.

Codex Task

@drew drew added integration:aardvark Aardvark integration integration:codex Codex integration labels Mar 16, 2026
@github-actions
Copy link

Thank you for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text:


I have read the DCO document and I hereby sign the DCO.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the DCO Assistant Lite bot.

@johntmyers
Copy link
Collaborator

Closing in favor of consolidated re-implementation. See #350 for tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:aardvark Aardvark integration integration:codex Codex integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants