java - 授权路线
问题描述
我在使用 Spring Security 时遇到了一些问题。我在链过滤器中声明了一个给定的路由,就像授权一样
.antMatchers("/autorized/route/**").permitAll()
并且我有另一条未授权的路线,并且需要访问令牌,但是当我尝试访问授权路线时,我收到此错误:
org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:379)
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:223)\
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:124)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
我遇到了同样的问题:
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/autorized/route/**")
.antMatchers(HttpMethod.OPTIONS, "/**");
}
顺便说一下方法 rout 是:POST
有什么解释吗?
解决方案
推荐阅读
- php - 你如何从 Laravel 6 的雄辩关系中返回单列?
- c++ - strcmp 无法将参数 '2' 的 'char**' 转换为 'const char*' 到 'int strcmp(const char*, const char*)'
- python - 如何使用烧瓶在表单中添加默认值?
- node.js - 错误:错误:04099079:rsa 例程:RSA_padding_check_PKCS1_OAEP_mgf1:oaep 解码错误
- botframework - OAuth 登录按钮在 Teams 上不起作用
- visual-studio-code - Package.xml 自动刷新 VSCode [Salesforce 元数据 API]
- iphone - 如何让这个 Vue 脚本在 iPhone 上以同样的方式工作
- oracle - 使用外键创建表失败并出现 ORA-00905:缺少关键字
- json - json.decoder.JSONDecodeError:期望','分隔符:第 305 行第 2 列
- android - 来自活动的 kotlin 打开片段