如何跳过Spring登录页面

时间:2014-01-20 14:55:32

标签: spring-security siteminder

我正在使用siteminder进行身份验证,但目前用于开发目的我正在通过fiddler工具伪造像SM_USER这样的URL属性。我能够在我的类中获取属性,我已经实现了自定义方法以从DB获取用户权限。一切正常,最后它重定向到Spring Security Login Page.Below是我的代码片段......

     <http pattern="/pages/UnAuthorized.jsf*" security="none"/>
     <http pattern="/pages/Logout.jsf*" security="none"/>
     <http pattern="/pages/SessionTimeout.jsf*" security="none"/>
     <http auto-config="false" use-expressions="true">
<intercept-url pattern="/**" access="fullyAuthenticated" />
<custom-filter position="PRE_AUTH_FILTER" ref="siteminderFilter" />
<logout logout-url="/logout" logout-success-url="/pages/Logout.jsf" />
</http>

   <authentication-manager alias="authenticationManager">  
    <authentication-provider ref="customAuthenticationProvider" >  
    </authentication-provider>     
   </authentication-manager> 

    <bean id="siteminderFilter" class="org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter">
    <property name="principalRequestHeader" value="SM_USER"/>
    <property name="authenticationManager" ref="authenticationManager" />
</bean>

<bean id="userDetailsServiceWrapper"  
        class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">  
    <property name="userDetailsService" ref="UserPermissionsProcessor"/>  
</bean>

<bean id="customAuthenticationProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider">
    <property name="preAuthenticatedUserDetailsService"  ref="userDetailsServiceWrapper">
    </property>
</bean>

我尝试使用入口点参考,如其中一篇文章中所建议的,但对我没用。

1 个答案:

答案 0 :(得分:0)

是否正在创建身份验证对象?如果是,请在SecurityContextHolder中设置如下。

  

SecurityContextHolder.getContext()setAuthentication(认证);

如果验证对象不存在,则下面的行失败,

显然你将被重定向到登录页面。

相关问题