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

feat: provides authentication and authorization expression dialects #2729

Merged
merged 4 commits into from
Nov 23, 2022

Conversation

guqing
Copy link
Member

@guqing guqing commented Nov 21, 2022

What type of PR is this?

/kind feature
/milestone 2.0.0-rc.1
/area core

What this PR does / why we need it:

主题端支持使用表达式方言获取登录状态和判断权限,例如:

获取当前登录用户名

<div th:text="${#authentication.name}">
  The value of the "name" property of the authentication object should appear here.
</div>

关于判断登录状态我们并不推荐调用表达式 ${#authentication.isAuthenticated()},因为始终返回 true,使用以下几种属性表达式代替:

<div sec:authorize="isAuthenticated()">
如果不是匿名用户你会看到我
</div>

<div sec:authorize="isFullyAuthenticated()">
如果不是匿名用户且不是 rememberMe 你会看到我
</div>

其他

<div sec:authorize="isAnonymous()">
如果是匿名用户你会看到我
</div>
<div sec:authorize="isRememberMe()">
如果是 rememberMe  你会看到我
</div>

更多请参考:
https://github.com/thymeleaf/thymeleaf-extras-springsecurity

Console 端判断是否登录需要改一下,目前所有未登录状态都属于一个叫 anonymousUser 的用户

Which issue(s) this PR fixes:

Fixes #2676

Special notes for your reviewer:

/cc @halo-dev/sig-halo

Does this PR introduce a user-facing change?

主题端支持使用表达式方言获取登录状态和判断权限

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 21, 2022

@guqing: The provided milestone is not valid for this repository. Milestones in this repository: [1.5.6, 1.5.x, 1.6.1, 1.6.x, 2.0.0-rc.1, 2.0.0-rc.2, 2.0.0, 2.0.x, Backlog]

Use /milestone clear to clear the milestone.

In response to this:

What type of PR is this?

/kind feature
/milestone 2.0
/area core

What this PR does / why we need it:

主题端支持使用表达式方言获取登录状态和判断权限,例如:

<div th:text="${#authentication.name}">
 The value of the "name" property of the authentication object should appear here.
</div>

更多请参考:
https://github.com/thymeleaf/thymeleaf-extras-springsecurity

Console 端判断是否登录需要改一下,目前所有未登录状态都属于一个叫 anonymousUser 的用户

Which issue(s) this PR fixes:

Fixes #2676

Special notes for your reviewer:

/cc @halo-dev/sig-halo

Does this PR introduce a user-facing change?

主题端支持使用表达式方言获取登录状态和判断权限

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@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. kind/feature Categorizes issue or PR as related to a new feature. area/core Issues or PRs related to the Halo Core labels Nov 21, 2022
@guqing
Copy link
Member Author

guqing commented Nov 21, 2022

/milestone 2.0.0-rc.1

@f2c-ci-robot f2c-ci-robot bot added this to the 2.0.0-rc.1 milestone Nov 21, 2022
@guqing guqing changed the title feat: provides authentication and authorization expression dialects [WIP] feat: provides authentication and authorization expression dialects Nov 21, 2022
@f2c-ci-robot f2c-ci-robot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 21, 2022
@guqing guqing changed the title [WIP] feat: provides authentication and authorization expression dialects feat: provides authentication and authorization expression dialects Nov 22, 2022
@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 Nov 22, 2022
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 Nov 22, 2022
Copy link
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

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

/approve

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 22, 2022

[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

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 Nov 22, 2022
@f2c-ci-robot f2c-ci-robot bot merged commit 1805481 into halo-dev:main Nov 23, 2022
@guqing guqing deleted the feature/2676 branch November 23, 2022 04:24
f2c-ci-robot bot pushed a commit to halo-dev/console that referenced this pull request Nov 23, 2022
#### What type of PR is this?

/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

使用 Pinia 管理已授权用户信息,并提供判断是否是 `anonymousUser` 的方式。

适配 halo-dev/halo#2729

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试流程:

1. Halo 需要切换到 halo-dev/halo#2729 的分支。
2. 测试 Console 端的登录、退出等流程。

#### Does this PR introduce a user-facing change?

```release-note
None
```
f2c-ci-robot bot pushed a commit that referenced this pull request Nov 24, 2022
#### What type of PR is this?

/kind bug
/area core

#### What this PR does / why we need it:

The problem #2743 was introduced by #2729. This Pr mainly resolves it by setting SAMEORIGIN mode for frame options.

![image](https://user-images.githubusercontent.com/16865714/203795956-6efec450-da5f-4222-884d-5a67cb113173.png)

#### Which issue(s) this PR fixes:

Fixes #2743

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

```release-note
None
```
JohnNiang pushed a commit to JohnNiang/halo that referenced this pull request Mar 2, 2023
…#699)

#### What type of PR is this?

/kind improvement
/milestone 2.0

#### What this PR does / why we need it:

使用 Pinia 管理已授权用户信息,并提供判断是否是 `anonymousUser` 的方式。

适配 halo-dev#2729

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试流程:

1. Halo 需要切换到 halo-dev#2729 的分支。
2. 测试 Console 端的登录、退出等流程。

#### Does this PR introduce a user-facing change?

```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/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.

在主题端提供当前登录用户相关 API
3 participants