1

嗨,我是 Spring Security 的新手。

我曾尝试使用匿名用户访问该应用程序。但现在我想实现匿名用户和经过身份验证的用户访问应用程序。任何人都可以帮助我。

以下 security.xml 我曾用于匿名用户。但现在我想实现匿名用户和经过身份验证的用户。(经过身份验证的用户示例注册用户的用户名和密码以检查)

<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">

    <http pattern="/static/**" security="none" />
    <http pattern="**/static/**" security="none" />
    <http pattern="/w/login*" security="none" />
    <http pattern="/w/about*" security="none" />    
    <http pattern="/w/getInvolved*" security="none" />
    <http pattern="/w/faq*" security="none" />
    <http pattern="/w/feedback*" security="none" />
    <http pattern="/w/contact*" security="none" />
    <http pattern="/w/privacy*" security="none" />
    <http pattern="/w/terms*" security="none" />
    <http auto-config='true' use-expressions="true">

    <form-login login-page='/w/login' />

    <intercept-url pattern="/w/**" access="isAnonymous()"/>
    <intercept-url pattern="/a/**" access="isAnonymous()"/>
    <logout logout-url="/w/logout"  logout-success-url="/w/login" />
  </http>


  <authentication-manager>
     <authentication-provider user-service-ref="twwiUserSQLMapDAO">
        <password-encoder hash="sha"></password-encoder>
    </authentication-provider>
  </authentication-manager>
  </beans:beans>
4

1 回答 1

2

If you want to give access to authenticated and anonymous users you can use permitAll:

<intercept-url pattern="/login/**" access="permitAll" />
于 2013-08-19T09:33:58.610 回答