Skip to content

Add guided admin key setup and verification - #387

Merged
saioai merged 23 commits into
mainfrom
codex/admin-setup-public-20261008
Oct 11, 2026
Merged

saioai merged 23 commits into
mainfrom
codex/admin-setup-public-20261008

Conversation

@saioai

@saioai saioai commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Admin commands currently fail without explaining that they need an admin key.
This adds clear guidance and openai setup admin, which hides key entry and verifies access automatically.

What changes

  • Explain admin-key requirements after validating required command inputs.
  • Show the key-creation link before hidden entry.
  • Verify access with one read-only project-list request, with a 15-second timeout and no retries or redirects.
  • Keep the key in that process. Setup does not save credentials or authenticate later commands.
  • Discard pending input before the hidden prompt.
  • Preserve cancellation and restore terminal input after entry.
  • Enable Windows output processing for the prompt, then restore its original mode.
  • Respect --quiet for verification progress while retaining the prompt, result, and errors.
  • Cover standard and mTLS OpenAI hosts while preserving explicit authentication and custom-endpoint overrides.
  • Escape the displayed destination without changing the request URL.
  • Retain offline setup instructions and existing machine-readable errors.
  • Stop before key entry on platforms without supported terminal cleanup, with a manual setup command.

Commands

openai setup admin         # Hidden key entry and automatic verification.
openai setup admin --help  # Interactive command details.
openai --quiet setup admin # Keep the prompt and result without optional progress.
openai help setup admin    # Offline key creation and manual setup guide.

Interactive setup requires terminal stdin, stdout, and stderr, with text output.
Debug logging and structured output stop before prompting.
The destination follows --base-url or OPENAI_BASE_URL.
HTTPS is required except for loopback servers.
The entered key replaces Authorization; other configured headers and mTLS remain active.
An empty project list also verifies access successfully.

Code

pkg/custom owns credential checks, setup orchestration, hidden input, and safe errors.
The Windows factory uses a console-record reader with cancellable waits and joined cleanup.
macOS and Linux retain the existing reader with platform input cleanup.
The parser, signal handling, and verification request remain shared.

Canonical metadata survives command cloning.
Request setup checks credentials after required-input validation and before file expansion.
No new package, dependency, generated-command change, main.go change, or budget increase is included.

Tested

Candidate 3e37745 is based on main 193ee5b, including the merged Output, Files, and SDK updates.
Fresh local checks passed 816 focused product-test entries. Two unsupported-only tests skip on supported builds.
Go vet and Windows main-test compilation passed. Compilation does not establish native Windows execution.
Local validation used Go 1.26.9 on macOS arm64, synthetic keys, and loopback endpoints.

The current run includes all seven public terminal cases and all 21 native Mac key-reader scenarios.
It covers quiet behavior, cancellation, complete/partial startup input, and final queued-input cleanup.
Reader comparisons normalize Darwin PENDIN; queue checks separately require empty pending input.
Fresh shared error-path simulations cover output setup and restoration failures with no returned key.
Both restore exact native Mac terminal settings, preserve privacy, and reap their children without forced cleanup.
These simulations do not inject native Windows API failures.

Three new Windows regressions start with output processing disabled: success, cancellation, and marked multiline rejection.
They check active modes, native screen controls, and exact mode restoration.
Fresh native Windows CI passed all three cases, within 38 sessions and 37 distinct reader checks.
It recorded 42 reader-phase frames and exact output-mode restoration.
Paste markers are injected; these cases do not verify clipboard framing.

At 2baa586, separate error-presentation checks passed 85 entries; module verification and the standalone build passed.
That standalone binary passed 14 setup cases and three startup-input scenarios.
The old runtime fails both startup regressions while preserving five controls.
The simulated startup-flush failure returned no key, created no reader, displayed no prompt, and restored terminal settings.
Its negative control failed when startup flushing was removed.
The private startup/failure probes used exact terminal comparisons after FIONREAD, without masking.
The current change preserves startup/final input cleanup. Its non-Windows output helper changes no modes.
The queue guarantee covers bytes pending when cleanup runs, not later arrivals.

At bfb7309, the unchanged unsupported-entry paths passed 91 fallback-simulation entries and three native Mac rejection cases.
Copied manual recovery ran through bash and zsh with quoted executable paths.
That simulation does not establish native BSD execution.
FreeBSD, OpenBSD, and Windows amd64 CLI compilation passed at 2baa586.

Independent reviews cover all recorded findings and the current-main composition.
Current-head CI passed, including the full Linux suite and artifact validation.
Help, CodeQL, nine vulnerability targets, and the custom-code gate also passed.
The automated review completed without additional findings. All ten review threads are resolved after verification.
Merged through the normal queue after queue CI passed.
No workflow, scanner, generated-command, or budget gate changed. Setup saves no credentials.
Native Windows quiet-mode behavior, Windows Terminal application behavior, and live API verification remain untested.

Demo

Actual binaries on macOS arm64, comparing main d32b3ae with ce129ba.
The recording uses a synthetic key and loopback API. No live key is created.
The follow-up preserves this setup output; its validation and cancellation corrections have separate regression coverage.

Admin setup before and after

Before:

Before: no interactive setup

After:

After: hidden input and automatic verification

Recording recipe · Synthetic fixture

BEGIN_COMMIT_OVERRIDE
feat(admin): add guided admin-key setup and access verification (#387)
END_COMMIT_OVERRIDE

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Castiron custom code

Evaluated main: 193ee5b56e304723fa1995ff96aa711c876b45ef.

✅ No new custom-code files detected.

5 mixed files remain; 0 existing customizations changed.

Compared 193ee5b56e30 → 3e37745b9a87. Generated baselines verified.

5 existing customizations unchanged
  • pkg/cmd/adminorganizationcertificate.go
  • pkg/cmd/audiovoice.go
  • scripts/castiron/custom_code_budget.py
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_budget.py

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 38111156735 --repo openai/openai-cli \
  --name castiron-custom-code-38111156735-1 --dir /tmp/castiron-custom-code-38111156735-1
git apply --stat /tmp/castiron-custom-code-38111156735-1/custom-code.patch
cat /tmp/castiron-custom-code-38111156735-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 193ee5b56e304723fa1995ff96aa711c876b45ef 3e37745b9a87a44898f5676ff3d3143366be16e3
python3 scripts/castiron/custom_code_report.py report \
  --base 193ee5b56e304723fa1995ff96aa711c876b45ef \
  --head 3e37745b9a87a44898f5676ff3d3143366be16e3 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-3e37745b9a87
cat /tmp/castiron-custom-code-3e37745b9a87/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@saioai

saioai commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Please review commit ce129ba36684bb4f523b44b2778b633a544fe69c against this PR's current base. Check public-command behavior, preserved input/output contracts, errors, and cancellation. Distinguish code defects from the documented validation limits.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T04:15:42.795049Z 3e37745 New commits
🔒 Security Review ✅ Completed 2026-10-11T04:10:40.346913Z 3e37745 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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

ℹ️ 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 pkg/custom/admin_setup_interactive.go Outdated
Comment thread pkg/custom/admin_credentials.go Outdated
Comment thread pkg/custom/admin_credentials.go Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: ce129ba366

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@saioai

saioai commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Please review the functional correction in 00be8a07529159e9d713cccdd496a6a53b73c2de, including code and security checks.

It addresses the three findings from ce129ba36684bb4f523b44b2778b633a544fe69c.
Required and piped input validation now precedes credential checks.
Checkpoint permissions and positional routes receive the same admin-key guidance.
Cancellation retains standard context errors while keeping private causes hidden.
The PR base remains unchanged.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 00be8a0752

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 00be8a0752

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

…min-setup-public-20261008

# Conflicts:
#	pkg/custom/help.go
@saioai

saioai commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Please review code and security for Help-aligned head 3c60f6970a34a5451bd900d136de94f5018c4b63 against main 6fcc478086507571286727084a7d7b162a37ab51.

This local merge preserves the reviewed Admin correction from 00be8a and main's complete Help behavior.
The Help conflict retains the Admin manual guide after main's configuration.
Admin validation tests now require main's exact command-specific error guidance.
All Admin runtime files remain unchanged from the reviewed correction.
Focused integration checks, the exact binary build, vet, and the trusted budget check passed.
Earlier hosted reviews remain attributed to 00be8a.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 3c60f6970a

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

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

Copy link
Copy Markdown

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: 3c60f6970a

ℹ️ 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 pkg/custom/admin_credentials.go Outdated
Comment thread pkg/custom/admin_setup_interactive.go
Comment thread pkg/custom/admin_setup_key.go
Comment thread pkg/custom/admin_setup_key.go

@jbeckwith-oai jbeckwith-oai 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.

Reviewed credential precedence and validation order, cloned admin routes, endpoint/mTLS preservation, hidden input, cancellation, verification, and error presentation. No blocking findings; the previously reported issues appear addressed.

On the exact head, focused TestAdmin and public TestMainAdmin tests, go vet ./..., and changed-file gofmt checks pass. A temporary credential-acceptance mutation was caught by the tests, and the restored tests passed. Hosted checks pass. Native Windows behavior was reviewed statically, not executed; no live API calls were made.

@saioai
saioai marked this pull request as ready for review October 11, 2026 03:14
@saioai
saioai requested a review from a team as a code owner October 11, 2026 03:14

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

Copy link
Copy Markdown

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: 8487ddf7f9

ℹ️ 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 pkg/custom/admin_setup_input_flush_other.go

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

Copy link
Copy Markdown

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: 8db6894b9e

ℹ️ 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 pkg/custom/admin_setup_key.go

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

Copy link
Copy Markdown

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

ℹ️ 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 pkg/custom/admin_setup_key.go
@saioai
saioai added this pull request to the merge queue Oct 11, 2026
Merged via the queue into main with commit 4183995 Oct 11, 2026
29 checks passed
@saioai
saioai deleted the codex/admin-setup-public-20261008 branch October 11, 2026 04:28
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.

2 participants