【问题标题】:HttpBasic authentication failure urlHttpBasic认证失败url
【发布时间】:2018-09-08 15:27:39
【问题描述】:

我正在使用 Spring Boot 和 Angularjs。我使用HttpBasic 来保证安全。我希望在身份验证失败或会话过期时将用户重定向到特定的 url。

我遇到的问题是,当会话过期或授权用户访问受保护的资源时,浏览器会不断弹出身份验证对话框。

这是我的SecurityConfiguration

public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
            .httpBasic().and().authorizeRequests()
            .antMatchers("/index.html", "/login.html", "/templates/forgotpassword", "/user/forgot-password", "/user/reset-password", "/reset-password/**", "/custom/**", "/app/**", "/", "/user", "/logout", "/css/**", "/api/**").permitAll()
            .anyRequest().authenticated()
            .and()
            .csrf()
            .disable();
}

【问题讨论】:

    标签: java angularjs spring-boot spring-security basic-authentication


    【解决方案1】:
    http.formLogin().loginPage("/login").permitAll();
    

    loginPage java-doc:

    如果需要登录,则指定将用户发送到的 URL。如果与 WebSecurityConfigurerAdapter 将生成默认登录页面 未指定此属性时。

    【讨论】:

      猜你喜欢
      • 2016-06-29
      • 2021-03-07
      • 2019-09-03
      • 2016-05-30
      • 2014-07-19
      • 2015-10-17
      • 2021-05-11
      • 2012-07-22
      • 2014-10-12
      相关资源
      最近更新 更多