gpt4 book ai didi

java - 如何使用 Spring Security 创建注销?

转载 作者:行者123 更新时间:2023-12-04 05:00:18 25 4
gpt4 key购买 nike

我试图找到一种方法来设置一个 URL,该 URL 将从系统中注销我的用户。这仅用于测试。现在我们正在使用 spring 安全中的默认登录页面

这是我的 spring-secuirty.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">


<global-method-security pre-post-annotations="enabled" />

<http use-expressions="true">
<intercept-url access="hasRole('ROLE_VERIFIED_MEMBER')" pattern="/ask-union**" />
<intercept-url access="hasRole('ROLE_VERIFIED_MEMBER')" pattern="/ask-welfare**" />
<intercept-url pattern='/*' access='permitAll' />

<form-login default-target-url="/ask-union" />

<logout logout-success-url="/" />

<session-management session-fixation-protection="newSession">
<concurrency-control max-sessions="1"/>
</session-management>

</http>

<authentication-manager>
<authentication-provider>
<user-service>
<user name="xxxxx@aol.com.dev" password="testing" authorities="ROLE_VERIFIED_MEMBER" />
ser-service>

</authentication-provider>
</authentication-manager>
</beans:beans>

最佳答案

将此行添加到您的配置中

<logout logout-url="/sign-out"/>

然后,如果您有指向该 URL 的链接,它就会将您注销

(将其添加到您的注销成功配置下方)

关于java - 如何使用 Spring Security 创建注销?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16222841/

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