-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Immutable CodexAuth #8857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Immutable CodexAuth #8857
Conversation
…cess sync - Add AuthManager::auth_cached and move stale-token refresh logic into AuthManager - Make CodexAuth::get_token/get_token_data synchronous and remove CodexAuth::refresh_token - Change auth_provider_from_auth and BackendClient::from_auth to non-async - Replace direct CodexAuth usage with AuthManager where appropriate and use cached auth for UI/status
There was a problem hiding this 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: d8143b7a97
ℹ️ 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".
| let token_data = match auth.get_token_data() { | ||
| Ok(data) => data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refresh workspace restriction check before reading token data
This enforcement now reads auth.get_token_data() without any refresh path, but get_token_data no longer refreshes stale ChatGPT tokens. If last_refresh is older than the refresh interval (e.g., user changed workspaces or lost access since the last refresh), this check will validate against an outdated ID token and allow login; later calls to AuthManager::auth() will refresh, but there is no re-check, so the workspace restriction can be bypassed until manual logout. Consider refreshing here (e.g., via AuthManager::auth() or an explicit refresh-if-stale) before validating the workspace ID.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a legit bug, but it's a pretty extreme edge case. Could add a TODO and address it in a follow-on PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that refreshing the token doesn't refresh the workspace (same way it doesn't pick up the plan_type).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, then it should be fine.
etraut-openai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new separation of concerns is a big improvement. I should have thought of this when I added the AuthManager in the first place. Thanks!
Codex found one bug related to workspace enforcement, but it's a pretty small hole. Could leave it for a later PR IMO, but it would be good to at least add a TODO.
| let token_data = match auth.get_token_data() { | ||
| Ok(data) => data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a legit bug, but it's a pretty extreme edge case. Could add a TODO and address it in a follow-on PR.
Historically we started with a CodexAuth that knew how to refresh it's own tokens and then added AuthManager that did a different kind of refresh (re-reading from disk).
I don't think it makes sense for both
CodexAuthandAuthManagerto be mutable and contain behaviors.Move all refresh logic into
AuthManagerand keepCodexAuthas a data object.