Skip to content

[codex] force reauth on workspace-restricted ChatGPT 401#28962

Open
radai-oai wants to merge 4 commits into
mainfrom
logout-of-disallowed-workspace
Open

[codex] force reauth on workspace-restricted ChatGPT 401#28962
radai-oai wants to merge 4 commits into
mainfrom
logout-of-disallowed-workspace

Conversation

@radai-oai

Copy link
Copy Markdown

Summary

  • detect workspace-restricted ChatGPT 401 responses before normal auth recovery
  • clear active Codex-backend auth state and return an Unauthorized reauth error
  • leave generic 401s, malformed bodies, and API-key auth on existing paths

Testing

  • cargo test -p codex-core workspace_restricted --lib
  • cargo test -p codex-core generic_or_malformed_401_uses_existing_recovery_path --lib
  • cargo fmt
  • git diff --check

External (non-OpenAI) Pull Request Requirements

External code contributions are by invitation only. Please read the dedicated "Contributing" markdown file for details:
https://github.com/openai/codex/blob/main/docs/contributing.md

If your PR conforms to our contribution guidelines, replace this text with a detailed and high quality description of your changes.

Include a link to a bug report or enhancement request.

## Summary

- detect workspace-restricted ChatGPT 401 responses before normal auth recovery
- clear active Codex-backend auth state and return an Unauthorized reauth error
- leave generic 401s, malformed bodies, and API-key auth on existing paths

## Testing

- `cargo test -p codex-core workspace_restricted --lib`
- `cargo test -p codex-core generic_or_malformed_401_uses_existing_recovery_path --lib`
- `cargo fmt`
- `git diff --check`
@radai-oai radai-oai requested a review from a team as a code owner June 18, 2026 19:32
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@radai-oai

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jun 18, 2026

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

Copy link
Copy Markdown
Contributor

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: fe9ea22d74

ℹ️ 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".

Comment thread codex-rs/core/src/client.rs
Comment thread codex-rs/login/src/auth/manager.rs Outdated
Comment thread codex-rs/login/src/auth/manager.rs Outdated
@radai-oai

Copy link
Copy Markdown
Author

@codex review

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

Copy link
Copy Markdown
Contributor

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: 46958de18d

ℹ️ 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".

Comment thread codex-rs/login/src/auth/manager.rs Outdated
Comment thread codex-rs/login/src/auth/manager.rs
Comment thread codex-rs/login/src/auth/manager.rs
Comment thread codex-rs/core/src/client.rs Outdated
@radai-oai

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: f6105e668f

ℹ️ 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".

@radai-oai

Copy link
Copy Markdown
Author

@codex security review

@jif-oai jif-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I shouldn't be the main reviewer but I just made a first pass to have an idea of what is happenning. Please wait for Celia's approval

#[derive(Debug, Default)]
struct WebsocketSession {
connection: Option<ApiWebSocketConnection>,
connection_auth: Option<CodexAuth>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Noooooope. This puts raw CodexAuth under the derived Debug. So any format!("{model_client:?}") for example can dump the API key or any other creds. We should either store a redacted version or have a dedicated Debug implementation (I don't think it's fixable using derivation but I might be wrong)

}

let removal_result = self.logout_stores_matching_rejected_auth(rejected_auth);
let cache_changed = self.set_cached_auth(self.load_auth_from_storage().await);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

load_auth_from_storage() reapplies CODEX_ACCESS_TOKEN, so this can silently fall back to an env PAT/AgentIdentity. Or reload the same rejected env credential....
I might be missing something here? Is this on purpose?

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.

3 participants