Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support binding OAuth2 user automatically #6702

Merged
merged 1 commit into from
Sep 29, 2024

Conversation

JohnNiang
Copy link
Member

@JohnNiang JohnNiang commented Sep 26, 2024

What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

What this PR does / why we need it:

This PR add support for binding OAuth2 user automatically. So we can remove the user-binding page.

Please note that those changes may break the OAuth2 and SocialLogin plugins.

Special notes for your reviewer:

Build OAuth2 plugin from halo-sigs/plugin-oauth2#64 or use plugin-oauth2-1.0.4-SNAPSHOT.zip I built.

  • Bind after logging in
  1. Log in Halo with username and password method
  2. Try to unbind OAuth2 user
  3. Bind OAuth2 user again
  • Initially bind without logging in
  1. Go to login page
  2. Log in with OAuth2 method and you will be redirected to login page
  3. Log in with username and password method
  4. See the result of binding
  • Log in with OAuth2 method after binding
  1. Go to login page
  2. Log in with OAuth2 method and you will be redirected to uc page directly

Does this PR introduce a user-facing change?

支持自动绑定 OAuth2 登录用户

@f2c-ci-robot f2c-ci-robot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/improvement Categorizes issue or PR as related to a improvement. labels Sep 26, 2024
@f2c-ci-robot f2c-ci-robot bot added this to the 2.20.x milestone Sep 26, 2024
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label Sep 26, 2024
@f2c-ci-robot f2c-ci-robot bot requested review from LIlGG and wan92hen September 26, 2024 02:50
@f2c-ci-robot f2c-ci-robot bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 28, 2024
@JohnNiang JohnNiang force-pushed the refactor/oauth2-connection branch from 49c4fce to a286769 Compare September 29, 2024 04:28
@JohnNiang JohnNiang changed the title WIP: Support binding OAuth2 user automatically Support binding OAuth2 user automatically Sep 29, 2024
@f2c-ci-robot f2c-ci-robot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 29, 2024
Copy link

codecov bot commented Sep 29, 2024

Codecov Report

Attention: Patch coverage is 43.12977% with 149 lines in your changes missing coverage. Please review.

Project coverage is 57.84%. Comparing base (982a45b) to head (5b44e30).
Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
...e/user/service/impl/UserConnectionServiceImpl.java 9.09% 40 Missing ⚠️
...tication/oauth2/HaloOAuth2AuthenticationToken.java 0.00% 25 Missing ⚠️
...tication/oauth2/MapOAuth2AuthenticationFilter.java 53.19% 22 Missing ⚠️
...tion/oauth2/DefaultOAuth2LoginHandlerEnhancer.java 30.00% 14 Missing ⚠️
...n/twofactor/TwoFactorAuthenticationEntryPoint.java 43.47% 13 Missing ⚠️
...uth2/WebSessionOAuth2AuthenticationTokenCache.java 14.28% 12 Missing ⚠️
...ain/java/run/halo/app/infra/SchemeInitializer.java 50.00% 6 Missing ⚠️
...fra/exception/OAuth2UserAlreadyBoundException.java 0.00% 6 Missing ⚠️
...un/halo/app/security/LoginHandlerEnhancerImpl.java 0.00% 5 Missing ⚠️
.../java/run/halo/app/infra/config/WebFluxConfig.java 81.25% 3 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6702      +/-   ##
============================================
- Coverage     58.29%   57.84%   -0.45%     
- Complexity     3963     3988      +25     
============================================
  Files           680      704      +24     
  Lines         23338    23720     +382     
  Branches       1584     1570      -14     
============================================
+ Hits          13604    13721     +117     
- Misses         9108     9379     +271     
+ Partials        626      620       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JohnNiang JohnNiang force-pushed the refactor/oauth2-connection branch from aaa9fc4 to 5b44e30 Compare September 29, 2024 09:56
Copy link

Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

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

已测试登录和注册之后都可以正常绑定。

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Sep 29, 2024
Copy link
Member

@guqing guqing left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link

f2c-ci-robot bot commented Sep 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: guqing

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

The pull request process is described here

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 29, 2024
@f2c-ci-robot f2c-ci-robot bot merged commit e779543 into halo-dev:main Sep 29, 2024
8 checks passed
@JohnNiang JohnNiang modified the milestones: 2.20.x, 2.20.0 LTS Sep 29, 2024
@JohnNiang JohnNiang deleted the refactor/oauth2-connection branch September 30, 2024 06:23
f2c-ci-robot bot pushed a commit to halo-sigs/plugin-oauth2 that referenced this pull request Oct 11, 2024
This PR refactors OAuth2 login for adapting Halo 2.20. See halo-dev/halo#6702 for more.

#### How to build?

1. Checkout to halo-dev/halo#6702
2. Execute command `./gradlew publishToMavenLocal -Pversion=2.20.0+local.5` in Halo project
3. Execute command `./gradlew build` in current project.

```release-note
None
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement. lgtm Indicates that a PR is ready to be merged. 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.

3 participants