【发布时间】:2019-09-07 14:34:18
【问题描述】:
目前我们正在使用基本身份验证并将加密格式的用户名和密码设置为 HttpHeaders。有没有办法用任何 Springboot 安全性删除/替换它?如果是的话,你能帮我在我的项目中实现它吗?
【问题讨论】:
标签: java spring-boot spring-security spring-security-oauth2
目前我们正在使用基本身份验证并将加密格式的用户名和密码设置为 HttpHeaders。有没有办法用任何 Springboot 安全性删除/替换它?如果是的话,你能帮我在我的项目中实现它吗?
【问题讨论】:
标签: java spring-boot spring-security spring-security-oauth2
步骤
我会附上它的样子
@Configuration
public class EnablingSecutiry extends WebSecurityConfigurerAdapter
{
@Override
protected void configure(HttpSecurity http) throws Exception
{
http
.csrf().disable()
.authorizeRequests().anyRequest().authenticated()
.and()
.httpBasic();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth)
throws Exception
{
auth.inMemoryAuthentication()
.withUser("admin")
.password("{noop}password")
.roles("USER");
}
}
步骤
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
【讨论】: