2014-09-01 40 views
0

我有以下春季安全配置,我如何改變它登錄工作基於HTTP GET而不是POST,所以登錄網址將是這樣的:如何更改登錄工作得到而不是後彈簧安全

*http://localhost/myapp/j_security_check?j_username=test&j_password=test*

這是我的配置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.0.xsd 
     http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> 

    <http access-denied-page="/WEB-INF/pages/accessdenied.jsp" auto-config="true" use-expressions="true"> 

     <intercept-url pattern="/admin" access="hasRole('ROLE_ADMIN')" method="GET"/> 
     <intercept-url pattern="/user" access="hasRole('ROLE_USER')"/> 

     <form-login 
      always-use-default-target="true" 
      authentication-failure-url="/loginfailed" 
      default-target-url="/landing" 
      login-page="/login" /> 

     <logout 
       invalidate-session="true" 
       logout-success-url="/login?logout" /> 

     <form-login 
      login-page="/login" 
      default-target-url="/welcome" 
      authentication-failure-url="/login?error" 
      username-parameter="username" 
      password-parameter="password" /> 
     <logout logout-success-url="/login?logout" /> --> 

    </http> 

    <beans:bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"> 
     <beans:property name="userDetailsService" ref="userDetailsService" ></beans:property>  
    </beans:bean> 

    <beans:bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager" > 
     <beans:property name="providers"> 
      <beans:list> 
       <beans:ref local="daoAuthenticationProvider"/> 
      </beans:list> 
     </beans:property> 
    </beans:bean> 

    <authentication-manager> 
     <authentication-provider user-service-ref="userDetailsService"> 
     </authentication-provider> 
    </authentication-manager>' 
</beans:beans> 
+2

爲什麼?一般而言,您不希望將用戶名和密碼作爲請求參數傳遞,因爲這不太安全...... – 2014-09-01 08:38:45

+0

客戶端希望使用get和post方法登錄到應用程序。 – 2014-09-01 09:14:37

+0

可能重複的[Spring 3.0安全http GET登錄](http://stackoverflow.com/questions/13814346/spring-3-0-security-http-get-login) – 2014-09-01 09:29:38

回答

0

欲瞭解更多信息,如果您想通過春季安全使用方法郵寄表單。您需要將此令牌添加到您的表單。

<input type="hidden" name="${_csrf.parameterName}" 
          value="${_csrf.token}" />