1. Project:
2, Anonymous Authentication configuration:
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "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/beans http://www.springframework.org/schema/beans/spring-beans.xsd Http://www.springframework.org/schema/security http://www.springframework.org/schema/security/ Spring-security.xsd "> <security:httpAuto-config= "true"> <security:anonymousenabled= "true"Key= "Doesnotmatter"granted-authority= "role_anonymously"username= "User"></security:anonymous> <Security:intercept-urlpattern= "/admin/**"Access= "Role_user"/>--Set Role_user access rights <Security:intercept-urlpattern= "/common/**"Access= "role_user,role_anonymously"/> <Security:intercept-urlpattern="/**"Access= "role_user,role_anonymously"></Security:intercept-url> </security:http><!--<bean id= "Anonymousauthfilter" class= "org.springframework.security.web.authentication.AnonymousAuthent Icationfilter "> <property name=" key "value=" Doesnotmatter "/> <property name=" Userattribute "Val Ue= "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:username= "Admin"Password= "Admin"authorities= "Role_user"></Security:user> <Security:username= "User"Password= "User"authorities= "role_anonymously"></Security:user> </Security:user-service> </Security:authentication-provider> </Security:authentication-manager></Beans>
Admin login can access all pages, and user login will return to deny authorization,:
Spring Security Anonymous Authentication