Skip to content

feat: add remember-me mechanism to enhance user login experience - #5929

Merged
f2c-ci-robot[bot] merged 4 commits into
halo-dev:mainfrom
guqing:feature/remember-me
May 24, 2024
Merged

f2c-ci-robot[bot] merged 4 commits into
halo-dev:mainfrom
guqing:feature/remember-me

Conversation

@guqing

@guqing guqing commented May 16, 2024 •

Copy link
Copy Markdown
Member

What type of PR is this?

/kind feature
/area core
/milestone 2.16.x

What this PR does / why we need it:

为登录增加记住我机制以优化登录体验

how to test it?

  1. 勾选记住密码选项后登录
  2. 退出浏览器后打开 console 期望依然可以访问而不需要登录
  3. 测试修改密码功能,期望修改密码后所有会话需要重新登录包括当前设备和其他设备

Which issue(s) this PR fixes:

Fixes #2362

Does this PR introduce a user-facing change?

为登录增加保持登录会话机制以优化登录体验。

@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. 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. labels May 16, 2024
@f2c-ci-robot f2c-ci-robot Bot added this to the 2.16.x milestone May 16, 2024
@f2c-ci-robot
f2c-ci-robot Bot requested a review from LIlGG May 16, 2024 06:07
@f2c-ci-robot f2c-ci-robot Bot added the area/core Issues or PRs related to the Halo Core label May 16, 2024
@f2c-ci-robot
f2c-ci-robot Bot requested a review from ruibaby May 16, 2024 06:07
@guqing

guqing commented May 16, 2024

Copy link
Copy Markdown
Member Author

@ruibaby 帮忙适配一下 Console 登陆页面,添加记住我选项,此时需要为登陆 API 传递查询参数 remember-me=true

@codecov

codecov Bot commented May 16, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 27.16535% with 185 lines in your changes are missing coverage. Please review.

Project coverage is 56.46%. Comparing base (5fdf6c0) to head (d4573bb).
Report is 199 commits behind head on main.

❗ Current head d4573bb differs from pull request most recent head 66c03ee

Please upload reports for the commit 66c03ee to get more accurate results.

Files Patch % Lines
...ation/rememberme/TokenBasedRememberMeServices.java 23.71% 117 Missing and 2 partials ⚠️
.../authentication/login/UsernamePasswordHandler.java 8.33% 22 Missing ⚠️
...on/rememberme/RememberMeAuthenticationManager.java 12.50% 14 Missing ⚠️
...ation/rememberme/RememberMeCookieResolverImpl.java 26.31% 14 Missing ⚠️
...un/halo/app/security/LogoutSecurityConfigurer.java 10.00% 9 Missing ⚠️
...ion/rememberme/RememberMeAuthenticationFilter.java 72.72% 3 Missing ⚠️
.../rememberme/DefaultCookieSignatureKeyResolver.java 33.33% 2 Missing ⚠️
.../halo/app/infra/properties/SecurityProperties.java 66.66% 0 Missing and 1 partial ⚠️
...urity/authentication/login/impl/RsaKeyService.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5929      +/-   ##
============================================
- Coverage     56.91%   56.46%   -0.45%     
- Complexity     3319     3512     +193     
============================================
  Files           587      617      +30     
  Lines         18968    20745    +1777     
  Branches       1401     1440      +39     
============================================
+ Hits          10795    11713     +918     
- Misses         7594     8449     +855     
- Partials        579      583       +4     

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

@guqing
guqing marked this pull request as ready for review May 16, 2024 07:26
@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 May 16, 2024
@f2c-ci-robot
f2c-ci-robot Bot requested a review from JohnNiang May 16, 2024 07:26
@guqing
guqing force-pushed the feature/remember-me branch from 4194359 to 8615bc5 Compare May 16, 2024 08:12

@ruibaby ruibaby left a comment

Copy link
Copy Markdown
Member

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 lgtm Indicates that a PR is ready to be merged. and removed lgtm Indicates that a PR is ready to be merged. labels May 16, 2024
@guqing

guqing commented May 21, 2024

Copy link
Copy Markdown
Member Author

/ping @JohnNiang

@JohnNiang JohnNiang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

经测试发现,通过 TOTP 登录之后 Session 的有效期为当前 Session,请看下面的截图:

image

@guqing

guqing commented May 22, 2024

Copy link
Copy Markdown
Member Author

/hold 经过探讨发现通过 session 的 cookie 来实现 remember me 很容易被覆盖比如 totp,因此此 PR 将实现 Token Based 的方式来使用一个新的 cookie 值避免被影响

@f2c-ci-robot f2c-ci-robot Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 22, 2024
@guqing

guqing commented May 23, 2024

Copy link
Copy Markdown
Member Author

/unhold

@f2c-ci-robot f2c-ci-robot Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 23, 2024

@JohnNiang JohnNiang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

另外,建议本地 squash 一下 commits。

@guqing
guqing force-pushed the feature/remember-me branch from 57cc1fd to d4573bb Compare May 23, 2024 08:03
@guqing

guqing commented May 23, 2024

Copy link
Copy Markdown
Member Author

另外,建议本地 squash 一下 commits。

Done

guqing added 2 commits May 24, 2024 12:43
# Conflicts:
#	application/src/main/java/run/halo/app/security/authentication/CryptoService.java
#	application/src/main/java/run/halo/app/security/authentication/login/impl/RsaKeyService.java
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
4 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.2% Duplication on New Code

See analysis details on SonarCloud

@codecov-commenter

codecov-commenter commented May 24, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 27.38095% with 183 lines in your changes are missing coverage. Please review.

Project coverage is 56.38%. Comparing base (5fdf6c0) to head (66c03ee).
Report is 201 commits behind head on main.

Files Patch % Lines
...ation/rememberme/TokenBasedRememberMeServices.java 23.71% 117 Missing and 2 partials ⚠️
.../authentication/login/UsernamePasswordHandler.java 8.33% 22 Missing ⚠️
...on/rememberme/RememberMeAuthenticationManager.java 12.50% 14 Missing ⚠️
...ation/rememberme/RememberMeCookieResolverImpl.java 26.31% 14 Missing ⚠️
...un/halo/app/security/LogoutSecurityConfigurer.java 10.00% 9 Missing ⚠️
...ion/rememberme/RememberMeAuthenticationFilter.java 72.72% 3 Missing ⚠️
.../halo/app/infra/properties/SecurityProperties.java 66.66% 0 Missing and 1 partial ⚠️
.../rememberme/DefaultCookieSignatureKeyResolver.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5929      +/-   ##
============================================
- Coverage     56.91%   56.38%   -0.53%     
- Complexity     3319     3501     +182     
============================================
  Files           587      615      +28     
  Lines         18968    20698    +1730     
  Branches       1401     1439      +38     
============================================
+ Hits          10795    11671     +876     
- Misses         7594     8446     +852     
- Partials        579      581       +2     

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

@JohnNiang JohnNiang left a comment

Copy link
Copy Markdown
Member

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 May 24, 2024
@f2c-ci-robot

f2c-ci-robot Bot commented May 24, 2024

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 24, 2024
@f2c-ci-robot
f2c-ci-robot Bot merged commit 9ec608b into halo-dev:main May 24, 2024
@guqing
guqing deleted the feature/remember-me branch May 24, 2024 06:46
@JohnNiang JohnNiang modified the milestones: 2.16.x, 2.16.0 May 24, 2024
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/feature Categorizes issue or PR as related to a new feature. 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.

登录支持保留登录状态

4 participants