【发布时间】:2015-10-26 04:02:58
【问题描述】:
我正在使用 Spring Web、Spring Security 和 Spring social 创建一个 Spring Boot 应用程序。该应用程序包含使用基本身份验证来确保安全的其他服务。我正在尝试配置 Spring 以使应用程序无状态,但是当我使用浏览器向 Web 服务发出请求时,浏览器会提示输入用户凭据,但由于会话创建,所有先前的请求都使用相同的用户凭据。我已经配置了应用程序来阻止这种情况发生但仍然存在问题。\
public class SecurityConfig extends WebSecurityConfigurerAdapter{
@override
protected void configure(HttpSecurity http) throws Exception{
http.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.csrf().disable()
.authorizeRequests()
.antMatchers("/api/**")
.hasRole("USER")
.andBasic();
}
@override
protected void configure(AuthenticatioinManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("some@gmail.com")
.password("12345")
.role("USER");
}
}
我应该更改或添加什么来获得此功能。
【问题讨论】:
标签: java spring spring-security spring-boot