Repository navigation
feat: Add connection test command for SSO login flow - #177
jonatascastro12 wants to merge 8 commits into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Original prompt from jonatas
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
[Medium impact] The PR appears safe to merge; all three numbered findings are fixed and no new actionable issues were found. SummaryAdds
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
❌ Cannot revive Devin session - the session is too old. Please start a new session instead. |
…ection-test # Conflicts: # src/bin.ts # src/commands/connection.spec.ts # src/commands/connection.ts # src/utils/help-json.ts
Production environments reject http/localhost redirect URIs, so the localhost callback can never be registered or reached. Fail fast with a clear message instead of falling through to a manual Dashboard step that cannot succeed.
|
Merged
Added one fix of my own (0027b48): the command now refuses
|
|
❌ Cannot revive Devin session - the session is too old. Please start a new session instead. |
- Print the login URL to stderr in JSON mode so agents and --json --no-open callers can start the flow; stdout keeps only the final JSON. - Error out instead of prompting when redirect URI registration fails in JSON mode (ui.confirm refuses to prompt there). - Reject --port values outside 1-65535; port 0 made the OS pick a port that no longer matched the registered redirect URI.
Summary
Adds
workos connection test <id>— an end-to-end SSO smoke test for a connection, run entirely from the CLI:http://localhost:<port>/callbackas an environment redirect URI automatically via the existingPOST /user_management/redirect_uriswrapper (client.redirectUris.add). If registration fails (e.g. insufficient permissions), it prints the URI and asks the user to add it in the Dashboard before continuing (errors out in agent/CI mode instead of prompting).sso.getAuthorizationUrl({ clientId, redirectUri, connection, state }), whereclientIdresolves from--client-id→WORKOS_CLIENT_ID→ the active environment's stored client ID.--no-opento disable), waits for the IdP redirect (default 300s timeout,--timeoutto override), validatesstate, exchanges the code viasso.getProfileAndToken, and prints the authenticated profile.Flags:
--client-id,--port(default 4807),--timeout,--open/--no-open, plus the usual--api-key/--json.JSON mode outputs
{ connectionId, redirectUri, redirectUriRegistered, authorizationUrl, profile }.Also registered in
bin.tsand thehelp-json.tscommand registry, with spec coverage for the happy path, flag overrides, IdP error callbacks, state mismatch, registration fallback prompts, agent-mode behavior, and JSON output.Test plan
pnpm test(2102 passed),pnpm typecheck,pnpm lint,pnpm format:check,pnpm buildall passsrc/commands/connection.spec.tsmock the HTTP server, browser open, and SDK to exercise the full callback flowLink to Devin session: https://app.devin.ai/sessions/68e059345eaa4022851eb4f324d9c361
Requested by: @jonatascastro12