fix(auth): make login status recognize existing Codex authentication - #738
Conversation
8521302 to
681d3b0
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review Please review head |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 681d3b005d
ℹ️ 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".
mldangelo-oai
left a comment
There was a problem hiding this comment.
Thanks for fixing this and adding regression coverage! Having login status recognize an existing Codex session makes the first-run experience much clearer. I appreciate the contribution. We’ll handle the concurrent logout case in follow-up #759.
Summary
Fixes #670. When a user with an existing ambient Codex authentication session (e.g. in
~/.codex/auth.jsonor$CODEX_HOME/auth.json) rancodex-security login statusor invokedsecurity.account()on a fresh state directory, Codex Security reported "Not logged in".Ambient credentials were only imported during scan execution (via
initialCredentialsAvailable), creating an inconsistency wherelogin statusreported not logged in immediately before a scan succeeded using ChatGPT authentication.Changes
sdk/typescript/src/cli.ts: Whenargs.action === "status"andcredentialHomeexists, invokeinitialCredentialsAvailable(dependencies.environment, ambientHome, credentialHome)before executing Codexlogin status.sdk/typescript/src/api.ts: InCodexSecurity.prototype.account(), invokeinitialCredentialsAvailable(...)onauthentication.codexHomeprior to queryingaccountStatus().initialCredentialsAvailable()continues to enforcecodexSecurityCredentialAllowsAmbientImport(isolatedHome), ensuring ambient credentials are never re-imported if the user previously logged out.sdk/typescript/tests-ts/cli-authentication.test.tsandsdk/typescript/tests-ts/api-credentials.test.ts.Testing
Ran the following checks locally:
pnpm --dir sdk/typescript run types-> passed with 0 errorsbun test ./tests-ts/cli-authentication.test.ts ./tests-ts/auth.test.ts ./tests-ts/api-credentials.test.ts-> 43 passed, 2 skipped (platform-specific), 0 failedpnpm --dir sdk/typescript run format-> passed (all matched files use Prettier style)python .github/scripts/check_plugin_source_compatibility.py-> passedRisk and rollout
Public disclosure review