Skip to content

feat: wso2 login runs browser authorization code with PKCE end to end - #26

Merged
kanushka merged 4 commits into
feat/login-auth-testbedfrom
feat/login-browser-pkce
Aug 5, 2026
Merged

feat: wso2 login runs browser authorization code with PKCE end to end#26
kanushka merged 4 commits into
feat/login-auth-testbedfrom
feat/login-browser-pkce

Conversation

@kanushka

@kanushka kanushka commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Implements #20 (part of #17). Third PR of the wso2 login stack — stacked on #25; only the last four commits are new here.

What this does

  • internal/auth/oauthflow: discovery via go-oidc requiring S256, first-free loopback port of 10425–10428 on 127.0.0.1/callback, authorization URL always printed (to stderr, as a diagnostic) while the browser opens best-effort (WSO2_NO_BROWSER suppresses the attempt), Authorization Code + PKCE exchange, ID-token verification with nonce, 5-minute deadline so an abandoned login cannot hang a bound port forever.
  • internal/app/login.go: wso2 login resolves the selected context/identity, refuses by kind with stable typed problems (auth.non_interactive, auth.login_not_required, auth.kind_not_implemented, auth.discovery_failed, auth.context_not_selected), stores the session under the identity's credential reference inside the rotation lock, and reports subject, email, organization, and product namespaces — never token material.
  • Fake-issuer knobs deferred from Task 5 (AllowAnyLoopbackPort, OmitS256, OmitNonce, HTTPClient()).

Verification

Full go test ./... -race -count=1 green including the acceptance gate; golangci-lint run 0 issues. State-mismatch rejection is mutation-checked (removing the state check fails the test); output streams are asserted token-free.

Noted for reviewers: the acceptance suite's no-net/http binary invariant was narrowed to the version/inventory path, since the login command legitimately links HTTP now. docs/architecture.md mentions wso2 login --device-code, which this slice rejects as an unknown flag while the kind refuses auth.kind_not_implemented — flagged as a doc/UX question rather than resolved here.

Stack

  1. feat: context schema v2 with identities, v1 compatibility read, and selection #24 schema v2 → feature/login
  2. feat: keychain session store and fake OIDC issuer test bed #25 test bed → feat/login-context-schema-v2
  3. this PRfeat/login-auth-testbed
  4. Broker derives module access from the login session by scoped refresh #21Inline client-credentials acquisition for CI #22Live smoke, Asgardeo empirical experiments, and the login walkthrough #23 follow.

https://claude.ai/code/session_01RojiAgW9hi3b9f9G6ZXBVp

The shell binary now carries an HTTP client, so the offline guarantee is
stated where it is still true: nothing wso2 version reaches to resolve
module inventory may depend on net/http.

Claude-Session: https://claude.ai/code/session_01RojiAgW9hi3b9f9G6ZXBVp
An abandoned login waited forever on a bound callback port: the flow
honoured a cancelled context but the command never armed one.

The authorization URL is an instruction to act on, not the command's
result, so it moves to the diagnostic stream and leaves standard output
carrying only the identity report.

Also share the --context parsing both commands had grown separately, and
prove the refusals that were only asserted by construction: no browser
suppression, an identity token missing its nonce, and a login the issuer
answers without a refresh token.

Claude-Session: https://claude.ai/code/session_01RojiAgW9hi3b9f9G6ZXBVp
@kanushka
kanushka requested a review from hevayo as a code owner August 5, 2026 01:46
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4440dea4-9e6b-4181-bd99-19aab02d08e1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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 reviewed 13 out of 14 changed files in this pull request and generated no comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kanushka
kanushka merged commit 6b7afc1 into feature/login Aug 5, 2026
6 checks passed
@kanushka
kanushka deleted the feat/login-browser-pkce branch August 5, 2026 04:53
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.

3 participants