gpt4 book ai didi

具有多个登录页面的 Spring 安全性

转载 作者:IT老高 更新时间:2023-10-28 13:57:39 25 4
gpt4 key购买 nike

我正在使用 Spring 安全性来保护使用用户名和密码登录到应用程序管理部分。但是现在我的客户需要为应用程序客户端部分提供另一个登录屏幕,他们将在其中拥有自己的用户名/密码来登录客户端部分。到目前为止,我已经使用以下 spring-security.xml 设置成功实现了管理部分登录:

<security:http auto-config="true" use-expressions="true">
<security:form-login login-page="/login"
default-target-url="/admin/dashboard" always-use-default-target="true"
authentication-failure-url="/login/admin?error_msg=wrong username or password" />
<security:intercept-url pattern="/admin/*" access="hasRole('ROLE_ADMIN')" />
<security:logout logout-success-url="/login"/>
</security:http>

<security:authentication-manager>
<security:authentication-provider
user-service-ref="adminServiceImpl">
</security:authentication-provider>
</security:authentication-manager>

我在网上搜索了很多,试图找到如何添加客户端部分登录屏幕、拦截 URL、安全身份验证提供程序,但找不到任何信息,所以有人可以帮我解决任何问题链接到任何教程/示例,指导如何做到这一点?

谢谢

最佳答案

根据Spring Security docs :

From Spring Security 3.1 it is now possible to use multiple http elements to define separate security filter chain configurations for different request patterns. If the pattern attribute is omitted from an http element, it matches all requests.

每个元素在内部 FilterChainProxy 和应该映射到它的 URL 模式中创建一个过滤器链。元素将按照声明的顺序添加,因此必须再次首先声明最具体的模式。

所以,基本上你需要两个 <http> 每个元素都有不同的 pattern属性。

这里有详细教程:https://blog.codecentric.de/en/2012/07/spring-security-two-security-realms-in-one-application/

关于具有多个登录页面的 Spring 安全性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21209962/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com