小编use*_*273的帖子

需要spring security java配置示例,仅显示基本身份验证

我当前的java安全配置如下所示:

@Configuration
@EnableWebSecurity
public class RootConfig extends WebSecurityConfigurerAdapter {

@Override
protected void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception
{
auth.inMemoryAuthentication()
    .withUser("tester").password("passwd").roles("USER");
}

@Override
protected void configure(HttpSecurity http) throws Exception {
     http
     .authorizeUrls()
         .anyRequest().authenticated()
         .and()
     .httpBasic();       
  }
}
Run Code Online (Sandbox Code Playgroud)

当我使用浏览器执行GET请求时,我将收到错误403.我希望得到一个浏览器弹出窗口,询问我的用户名/密码.可能是什么问题?

spring-security

9
推荐指数
1
解决办法
7576
查看次数

标签 统计

spring-security ×1