日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

Spring Security 匿名认证

發(fā)布時間:2025/5/22 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring Security 匿名认证 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1、項目截圖:

2、匿名認(rèn)證配置:

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:security="http://www.springframework.org/schema/security"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/securityhttp://www.springframework.org/schema/security/spring-security.xsd"><security:http auto-config="true"><security:anonymous enabled="true" key="doesNotMatter" granted-authority="ROLE_ANONYMOUSLY" username="user"></security:anonymous><security:intercept-url pattern="/admin/**" access="ROLE_USER"/> --設(shè)置ROLE_USER訪問權(quán)限<security:intercept-url pattern="/common/**" access="ROLE_USER,ROLE_ANONYMOUSLY"/><security:intercept-url pattern="/**" access="ROLE_USER,ROLE_ANONYMOUSLY"></security:intercept-url></security:http> <!-- <bean id="anonymousAuthFilter"class="org.springframework.security.web.authentication.AnonymousAuthenticationFilter"><property name="key" value="doesNotMatter" /><property name="userAttribute" value="anonymousUser,ROLE_ANONYMOUS" /></bean><bean id="anonymousAuthenticationProvider"class="org.springframework.security.authentication.AnonymousAuthenticationProvider"><property name="key" value="doesNotMatter" /></bean>--><security:authentication-manager><security:authentication-provider><security:user-service><security:user name="admin" password="admin" authorities="ROLE_USER"></security:user><security:user name="user" password="user" authorities="ROLE_ANONYMOUSLY"></security:user></security:user-service></security:authentication-provider></security:authentication-manager> </beans>

admin 登陸后能訪問所有頁面,而user登陸將返回拒絕授權(quán),如圖:

轉(zhuǎn)載于:https://www.cnblogs.com/tyb1222/p/4157947.html

總結(jié)

以上是生活随笔為你收集整理的Spring Security 匿名认证的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。