SpringSecurity Basic Authentication

当使用非浏览器处理Basic HTTP Authentication认证时,需post请求携带auth参数即可

Basic HTTP Authentication认证过程
在这里插入图片描述

1.用户访问未授权的private
2.FilterSecurityInterceptor抛出AccessDeniedException
3.ExceptionTranslationFilter开始作用,调用BasicAuthenticationEntryPoint发送WWW-Authenticate header.当客户端收到WWW-Authenticate header,会再次需用户输入username and password

在这里插入图片描述

protected void configure(HttpSecurity http) {
    http
        // ...
        .httpBasic(withDefaults());
}

参考:
https://docs.spring.io/spring-security/site/docs/5.4.5/reference/html5/#servlet-authentication-basic


版权声明:本文为claroja原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。