使用Spring Boot 2的java – 401而不是403
发布时间:2020-12-15 01:40:10 所属栏目:大数据 来源:网络整理
导读:使用Spring Boot 1.5.6.RELEASE我能够发送HTTP状态代码401而不是403,如How let spring security response unauthorized(http 401 code) if requesting uri without authentication所述,通过这样做: public class SecurityConfig extends WebSecurityConfigu
使用Spring Boot 1.5.6.RELEASE我能够发送HTTP状态代码401而不是403,如How let spring security response unauthorized(http 401 code) if requesting uri without authentication所述,通过这样做:
使用org.springframework.boot.autoconfigure.security.Http401AuthenticationEntryPoint类. 我刚刚升级到Spring Boot 2.0.0.RELEASE,发现不再有这样的课程了(至少在那个包中). 问: 最佳答案
删除了类org.springframework.boot.autoconfigure.security.Http401AuthenticationEntryPoint,转而使用org.springframework.security.web.authentication.HttpStatusEntryPoint.
在我的情况下,代码将是这样的:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |