Skip to content

feat(auth): select region and open Ed token setup - #17

Closed
bunizao wants to merge 5 commits into
mainfrom
feat/auth-regions
Closed

bunizao wants to merge 5 commits into
mainfrom
feat/auth-regions

Conversation

@bunizao

@bunizao bunizao commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Ed uses separate AU, US, and EU API endpoints, but login previously saved only the token and subsequent commands defaulted to AU. Login now selects the region, opens its token settings page through the system default browser, verifies the pasted token, and saves the token and region together for the CLI and local stdio MCP server.

  • Support --region au|us|eu for scripted login and EDSTEM_REGION for environment credentials; retain legacy plain-text token files with the AU default and explicit EDSTEM_BASE_URL overrides.
  • Request https://edstem.org/<region>/settings/api-tokens using native URL launchers on macOS, Windows, and Linux. Always show the interactive token-page link. Browser profiles and sessions stay under the user's control.
  • Skip automatic browser opening for --no-browser, stdin login, non-interactive login, and dry runs.
  • Share interactive recovery between explicit login and first-run onboarding: after authentication rejection, choose another token, reselect the region, or cancel; after connection/upstream failures, also offer retry with the same token. Configuration errors propagate. Scripted stdin login exits promptly instead of prompting for recovery.
  • Warn about token, region, and endpoint environment overrides before verification without printing their values.
  • Write and sync verified credentials to a private temporary file on the same filesystem, then atomically replace the saved file. Failures before replacement and cancelled/rejected login preserve existing credentials.
  • Update help, README, and the generated skill.

Validation: npm run check, all 257 tests (225 Node, 22 remote, 10 Worker), npm run build:local, skill regeneration, and git diff --check passed. Tests cover regional routing, native launcher arguments, recovery/cancellation in explicit login and first-run onboarding, environment warnings, stdin failure behavior, write/sync/rename fault injection, owner-only permissions, and concurrent saves. API and launcher behavior is mocked. The AU token page was separately verified in an existing signed-in Chrome Work profile. No full live CLI-to-browser smoke test or live token creation was performed.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 04:01

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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-08T04:05:28.487140Z d403eb4 PR opened
🔒 Security Review ✅ Completed 2026-10-08T04:04:23.236128Z d403eb4 PR opened
ℹ️ 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.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
edstem-mcp e4308ca Commit Preview URL

Branch Preview URL
Oct 08 2026, 08:03 AM

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

ℹ️ 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 src/cli.ts Outdated
async function onboardToken(ui: Ui, tokenFile: string, verify: (token: string) => Promise<EdClient>): Promise<string> {
async function onboardToken(ui: Ui, tokenFile: string, verify: CliRuntime["createClientForToken"]): Promise<void> {
showWordmark(ui);
const region = await promptEdRegion(ui);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor EDSTEM_REGION during first-run onboarding

When an interactive first-run command has EDSTEM_REGION set but no token, onboarding always prompts for a region and verifies the token against that selection. Immediately afterward, loadTokenWithSource() reapplies the environment region; if the user selects a different region, the token is successfully verified against one endpoint and then used against another, causing the original command to fail authentication. Resolve EDSTEM_REGION before prompting, as the explicit auth login path already does.

Useful? React with 👍 / 👎.

@bunizao bunizao changed the title feat(auth): save Ed region with API token feat(auth): select region and open Ed token setup Oct 8, 2026
@bunizao

bunizao commented Oct 18, 2026

Copy link
Copy Markdown
Owner Author

Closing as superseded by the released v0.8.0 implementation, rather than merging this older branch. Compared the release tag and current main against this PR: regional token persistence and CLI/stdio MCP routing are present, and later commits implement the remaining features: 5d3f835 (atomic credential saves; the atomic-save regression test matches this PR), 7f54760 (system-default-browser token setup and manual fallback), 06085b0 (login/onboarding recovery and environment override warnings), and 706d3d2 (override warnings during dry runs). v0.8.0 also adds automatic region detection and region-source reporting. The implementations are not identical commits, but this PR no longer has a feature that needs merging; merging it would reintroduce an older login flow. Release: https://github.com/bunizao/edstem-cli/releases/tag/v0.8.0 . Keeping the branch for traceability.

@bunizao bunizao closed this Oct 18, 2026
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