我移動了一些我的應用程序並創建了單獨的模塊,但現在由於某種原因,當我嘗試啓用HTTPS時,它將請求發送到無限重定向循環...當在彈簧安全中配置安全通道時循環重定向
有人可能會建議爲什麼這個請求http://myhost/login
會發出重定向。這是我認爲是相關的配置。請注意,如果我拿出requiresChannel
部分,它工作正常。
@Override
protected void configure(HttpSecurity http) throws Exception {
http
//.addFilterBefore(systemAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
.addFilter(systemAuthenticationFilter())
.addFilter(new RememberMeAuthenticationFilter(authenticationManager(), rememberMeService()))
.authorizeRequests()
.antMatchers("/login","/welcome", "/login/new**", "/register", "/logout", "/**", "/session/timeout", "/admin/assets/**").permitAll()
.antMatchers("/my_account").hasRole("REGISTERED_CUSTOMER")
.anyRequest().permitAll()
.and()
.formLogin()
.failureHandler(exceptionMappingAuthenticationFailureHandler())
.loginPage("/login")
.loginProcessingUrl("/log_in")
.defaultSuccessUrl("/welcome")
.usernameParameter("username")
.passwordParameter("password")
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/login")
.deleteCookies("SPRING_SECURITY_REMEMBER_ME_COOKIE")
.and()
.requiresChannel()
.antMatchers("/my_account", "/login").requiresSecure()
.and()
.rememberMe()
.tokenValiditySeconds(1209600)
.key(env.getProperty("rememberme.key"))
;
}
哦也,此模塊,從web.xml中servlet上下文的相關部分:
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>encoding-filter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding-filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<display-name>springMultipartFilter</display-name>
<filter-name>springMultipartFilter</filter-name>
<filter-class>org.springframework.web.multipart.support.MultipartFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>springMultipartFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<display-name>springSecurityFilterChain</display-name>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>ERROR</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>