Skip to content

Support OAuth2 auto-registration#9940

Draft
JohnNiang wants to merge 2 commits into
mainfrom
feature/oauth2-auto-registration
Draft

Support OAuth2 auto-registration#9940
JohnNiang wants to merge 2 commits into
mainfrom
feature/oauth2-auto-registration

Conversation

@JohnNiang
Copy link
Copy Markdown
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

Add OAuth2 auto-registration support. When a user logs in via OAuth2 (e.g., GitHub, Google) for the first time without an existing account, Halo will now automatically create a new user account with a generated username instead of redirecting to the manual binding page.

Key changes:

  1. MapOAuth2AuthenticationFilter — Added autoRegisterUser() method that:

    • Auto-generates username via Metadata.setGenerateName("user-")
    • Extracts displayName and email from OAuth2 provider attributes
    • Creates a new User, RoleBinding, and UserConnection
  2. OAuth2SecurityConfigurer — Added ReactiveExtensionClient and SystemConfigFetcher dependencies

  3. MapOAuth2AuthenticationFilterTest — 5 unit tests covering auto-registration flow

Note: This code was generated with assistance from Claude Code (LLM) and has been reviewed for correctness.

Which issue(s) this PR fixes:

Fixes #8120

Ref halo-sigs/plugin-oauth2#77

Does this PR introduce a user-facing change?

Added OAuth2 auto-registration support. When logging in via OAuth2 providers for the first time, Halo will automatically create a new account with a generated username.

@f2c-ci-robot f2c-ci-robot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. labels May 2, 2026
@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented May 2, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign guqing for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 8, 2026
JohnNiang added 2 commits May 15, 2026 21:36
- Replace ReactiveExtensionClient with UserService injection
- Use userService.createUser() instead of manual client.create() + RoleBinding.create()
- Generate username with UUID instead of relying on generateName
- Remove unused ReactiveExtensionClient and RoleBinding imports
- Update tests to mock UserService instead of ReactiveExtensionClient
@JohnNiang JohnNiang force-pushed the feature/oauth2-auto-registration branch from 53859ff to 8851188 Compare May 15, 2026 13:38
@f2c-ci-robot f2c-ci-robot Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 15, 2026
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request support for auto-registering after logging in with OAuth2

1 participant