Skip to content

Conversation

@pakrym-oai
Copy link
Collaborator

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

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 CodexAuth and AuthManager to be mutable and contain behaviors.

Move all refresh logic into AuthManager and keep CodexAuth as a data object.

…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
@pakrym-oai pakrym-oai marked this pull request as ready for review January 7, 2026 22:58
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: 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".

Comment on lines +304 to 305
let token_data = match auth.get_token_data() {
Ok(data) => data,
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Collaborator

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.

Copy link
Collaborator Author

@pakrym-oai pakrym-oai Jan 8, 2026

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).

Copy link
Collaborator

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.

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 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.

Comment on lines +304 to 305
let token_data = match auth.get_token_data() {
Ok(data) => data,
Copy link
Collaborator

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.

@pakrym-oai pakrym-oai merged commit 634764e into main Jan 8, 2026
26 checks passed
@pakrym-oai pakrym-oai deleted the pakrym/immutable-codexauth branch January 8, 2026 19:44
@github-actions github-actions bot locked and limited conversation to collaborators Jan 8, 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.

3 participants