【发布时间】:2017-10-17 10:34:32
【问题描述】:
所以我有一些 Spring Boot 安全代码,并且出于某种原因,尽管我的 STATELESS Angular 应用程序发送了一个 GET 请求。 Spring Security 似乎收到了两个请求,并在两个线程上以相同的毫秒数开始处理它们(然后我最终得到了一个唯一的用户约束,因为它试图将同一个用户两次添加到数据库中)。
我的 spring 安全配置是否有问题,发生双重请求? Spring Security 应该基本上检查来自无状态应用程序的所有请求以获取 X-AUTH-TOKEN。
http
.authenticationProvider(authenticationProvider)
.addFilterBefore(new HeaderAuthenticationFilter(), BasicAuthenticationFilter.class)
//.addFilterBefore(new CorsFilter(request -> corsConfiguration), HeaderAuthenticationFilter.class)
.authorizeRequests()
.antMatchers("/").permitAll()
.anyRequest()
.authenticated()
.and()
.csrf().disable()
.exceptionHandling().accessDeniedPage("/error");
基本上 HeaderAuthenticationProvider 和 HeaderAuthenticationFilter 用于检查 X-AUTH-TOKEN。
2017-05-17 19:46:41.868 INFO 5 --- [nio-8443-exec-8] o.a.c.util.SessionIdGeneratorBase : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [13,338] milliseconds.
2017-05-17 19:46:41.868 INFO 5 --- [nio-8443-exec-1] o.a.c.util.SessionIdGeneratorBase : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [8,315] milliseconds.
2017-05-17 19:46:41.872 INFO 5 --- [nio-8443-exec-8] m.d.f.a.HeaderAuthenticationProvider : Authenticate:: Authorization Token: bf6bbb6f5a850fb7b152b5e143534e5bd13a96abd3250d2
2017-05-17 19:46:41.872 INFO 5 --- [nio-8443-exec-1] m.d.f.a.HeaderAuthenticationProvider : Authenticate:: Authorization Token: bf6bbb6f5a850fb7b152b5e143534e5bd13a96abd3250d2
【问题讨论】:
标签: spring-boot spring-security stateless-session