【问题标题】:How can I configure Spring to use the browser popup for authentication?如何配置 Spring 以使用浏览器弹出窗口进行身份验证?
【发布时间】:2016-03-21 17:03:27
【问题描述】:

我通过扩展WebSecurityConfigurerAdapter 实现了自定义安全性,如下所示:

@Configuration
@EnableWebSecurity
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
// Specify the authentication mechanisms that will allow user access to the site.
@Autowired
public void configureGlobal(AuthenticationManagerBuilder builder) throws Exception {
    builder.inMemoryAuthentication()
        .withUser("user").password("password").roles("ROLES_USER");
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests().anyRequest().authenticated()
        .and()
        .formLogin()
        .and()
        .httpBasic()
        .and()
        .requiresChannel().anyRequest().requiresSecure();
}
}

根据许多示例。但是,当以这种方式实现时,我会被抛出一个由 Spring 生成的登录页面。我找到了很多文档,详细说明了如何覆盖此登录页面并提供我自己设计的 .html 文件,但是,我真正想做的就是通过浏览器身份验证弹出窗口提供凭据。

我的问题是我是否可以使用浏览器弹出身份验证按照我上面的代码进行身份验证(我的实际代码在AuthenticationManagerBuilder 中使用 Kerberos,但同样的一般问题),如果我不能,可以解释一下浏览器身份验证弹出是否是为特定类型的身份验证保留的,或者究竟是什么触发它弹出?

【问题讨论】:

  • 你是指使用Basic-Authentication时弹出的浏览器窗口吗?`

标签: spring spring-mvc authentication


【解决方案1】:

删除:

    .and()
    .formLogin()

根据您的配置,.httpBasic() 将使用浏览器弹出窗口进行基本身份验证

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-04-06
  • 1970-01-01
  • 2017-05-25
  • 1970-01-01
  • 1970-01-01
  • 2010-10-02
相关资源
最近更新 更多