相关疑难解决方法(0)

用Spring Boot 2代替403而不是403

随着春天引导 1.5.6.RELEASE我能够发送HTTP状态代码401,而不是403在描述如果请求的uri没有认证如何让春天的安全响应未经授权(HTTP 401码),这样做:

public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        //...
        http.exceptionHandling()
                .authenticationEntryPoint(new Http401AuthenticationEntryPoint("myHeader"));
        //...
    }
}
Run Code Online (Sandbox Code Playgroud)

使用org.springframework.boot.autoconfigure.security.Http401AuthenticationEntryPoint班级.

我刚刚升级到Spring Boot 2.0.0.RELEASE,发现不再有这样的类了(至少在那个包中).

问:Http401AuthenticationEntryPoint Spring Boot中 是否存在此类()?如果不是,那么在现有项目中保持相同行为以保持与依赖于此状态代码(401而不是403?)的其他实现保持一致的可能是一个很好的选择.

java spring spring-security http-status-code-401 spring-boot

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