Skip to content

refactor: unify external auth resolution#31421

Open
pakrym-oai wants to merge 7 commits into
mainfrom
pakrym/unify-external-auth-resolution
Open

refactor: unify external auth resolution#31421
pakrym-oai wants to merge 7 commits into
mainfrom
pakrym/unify-external-auth-resolution

Conversation

@pakrym-oai

@pakrym-oai pakrym-oai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

External auth had two paths: provider-command credentials were resolved through ExternalAuth, while app-provided ChatGPT credentials were installed separately and only used the provider for refresh. ExternalAuth also declared an auth mode independently from the CodexAuth value it returned, so the declaration and credentials could disagree.

This change makes the provider-owned CodexAuth authoritative for initial resolution, credential kind, and refresh.

  • remove ExternalAuth::auth_mode and require providers to return their current auth from resolve
  • route external auth registration, resolution, and unauthorized refresh through AuthManager::set_external_auth
  • keep the last resolved credential with its provider so synchronous consumers and unauthorized recovery observe the credential's actual mode
  • make the app-server bridge own both initial and refreshed ChatGPT credentials, and detach it on logout
  • keep model listing free of auth-refresh side effects, including in offline mode

Provider-command auth still follows its configured cache interval. App-provided ChatGPT auth still asks the parent app once after a 401 and retries the request once.

Stacked on #31355.

Testing

  • just test -p codex-login
  • just test -p codex-models-manager
  • focused codex-app-server tests for external login/logout, unauthorized refresh, and workspace mismatch

@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: c1b77736c0

ℹ️ 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/models-manager/src/manager.rs Outdated
@pakrym-oai

Copy link
Copy Markdown
Collaborator Author

@codex review this

@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: 31e538d06e

ℹ️ 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/models-manager/src/manager.rs Outdated
Comment thread codex-rs/login/src/auth/manager.rs Outdated
Comment thread codex-rs/login/src/auth/manager.rs Outdated
@pakrym-oai

Copy link
Copy Markdown
Collaborator 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: f8db315033

ℹ️ 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/app-server/src/request_processors/account_processor.rs
Comment thread codex-rs/login/src/auth/manager.rs
@pakrym-oai

Copy link
Copy Markdown
Collaborator Author

@codex review this

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

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

Reviewed commit: fb0e47f322

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

Base automatically changed from codex/external-auth-codex-auth-precursor to main July 7, 2026 16:47
@pakrym-oai pakrym-oai force-pushed the pakrym/unify-external-auth-resolution branch from 85053fa to ce1f9e4 Compare July 7, 2026 16:51
)));
}

login_with_chatgpt_auth_tokens(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This was saving tokens to ephemeral storage directly and had normal reload pick them up instead of having external auth bridge be the source of truth.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant