Skip to content

feat: add websocket auth for app-server#14847

Merged
viyatb-oai merged 11 commits intomainfrom
codex/viyatb/app-server-websocket-auth
Mar 25, 2026
Merged

feat: add websocket auth for app-server#14847
viyatb-oai merged 11 commits intomainfrom
codex/viyatb/app-server-websocket-auth

Conversation

@viyatb-oai
Copy link
Collaborator

@viyatb-oai viyatb-oai commented Mar 16, 2026

Summary

This change adds websocket authentication at the app-server transport boundary and enforces it before JSON-RPC initialize, so authenticated deployments reject unauthenticated clients during the websocket handshake rather than after a connection has already been admitted.

During rollout, websocket auth is opt-in for non-loopback listeners so we do not break existing remote clients. If --ws-auth ... is configured, the server enforces auth during websocket upgrade. If auth is not configured, non-loopback listeners still start, but app-server logs a warning and the startup banner calls out that auth should be configured before real remote use.

The server supports two auth modes: a file-backed capability token, and a standard HMAC-signed JWT/JWS bearer token verified with the jsonwebtoken crate, with optional issuer, audience, and clock-skew validation. Capability tokens are normalized, hashed, and compared in constant time. Short shared secrets for signed bearer tokens are rejected at startup. Requests carrying an Origin header are rejected with 403 by transport middleware, and authenticated clients present credentials as Authorization: Bearer <token> during websocket upgrade.

Validation

  • cargo test -p codex-app-server transport::auth
  • cargo test -p codex-cli app_server_
  • cargo clippy -p codex-app-server --all-targets -- -D warnings
  • just bazel-lock-check

Note: in the broad cargo test -p codex-app-server connection_handling_websocket run, the touched websocket auth cases passed, but unrelated Unix shutdown tests failed with a timeout in this environment.

@viyatb-oai viyatb-oai marked this pull request as draft March 16, 2026 21:10
@viyatb-oai viyatb-oai changed the title feat: add websocket auth flags for app-server feat: add websocket auth for app-server Mar 16, 2026
@viyatb-oai viyatb-oai marked this pull request as ready for review March 17, 2026 07:12
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/app-server-websocket-auth branch from 7bde80f to ba5da01 Compare March 18, 2026 00:46
@viyatb-oai viyatb-oai requested review from bolinfest, etraut-openai and maxj-oai and removed request for bolinfest March 18, 2026 01:15
@etraut-openai
Copy link
Collaborator

@codex review

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 612dc17da1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@etraut-openai
Copy link
Collaborator

@codex security review

@chatgpt-codex-connector
Copy link
Contributor

Security review completed. No security issues were found in this pull request.

View security finding report

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Copy link
Collaborator

@etraut-openai etraut-openai left a comment

Choose a reason for hiding this comment

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

The implementation looks good to me.

I have some concerns about this from a usability standpoint. The "signed bearer token" auth method is very advanced and will not be appropriate for most codex users and use cases. The capability token approach is easier to configure, but it still requires multiple steps. We'll need to document this very well to help users get through the steps.

@etraut-openai etraut-openai force-pushed the codex/viyatb/app-server-websocket-auth branch from 612dc17 to 4e69aa8 Compare March 24, 2026 15:26
@viyatb-oai viyatb-oai merged commit 6124564 into main Mar 25, 2026
42 of 43 checks passed
@viyatb-oai viyatb-oai deleted the codex/viyatb/app-server-websocket-auth branch March 25, 2026 19:35
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants