【发布时间】:2019-08-04 03:32:42
【问题描述】:
我们使用以下版本的spring-security-oauth2:
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.0.11.RELEASE</version>
</dependency>
在启用授权服务器并对其进行配置时,框架会启用默认 API,例如“/oauth/check_token”或“/oauth/token_key”。
我不使用这些 API(“oauth/token”除外)并希望禁用它们以防止误用。目前,我正在覆盖这些 url 的映射作为解决方法。我尝试在组件扫描中使用排除过滤器,但没有效果。有没有更方便的方法来禁用这些 API?
【问题讨论】:
-
将这些端点设置为
denyAll()还不够吗? -
@dur 我用 http.authorizeRequests().antMatchers("/oauth/error").denyAll();它没有任何效果。
-
为什么我的问题被否决了?为了下次改进,知道原因会很有帮助!
-
您必须将
AuthorizationServerSecurityConfigurer#checkTokenAccess配置为denyAll。但默认值已经是denyAll,因此您无需执行任何操作。显示您的配置。
标签: java spring spring-security spring-security-oauth2 spring-oauth2