【发布时间】:2020-07-20 15:47:16
【问题描述】:
我尝试使用 Spring 安全性通过自省来验证 OAuth2 令牌。 实际上,当我调用控制器时,我的应用程序不会尝试访问 OAuth 服务器进行自省并返回 403。
我的会议:
spring.security.oauth2.resourceserver.opaquetoken.introspection-uri=https://example.net/introspection
spring.security.oauth2.resourceserver.opaquetoken.client-id=clientId
spring.security.oauth2.resourceserver.opaquetoken.client-secret=clientSecret
网络安全:
@EnableWebSecurity
public class WebServerConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.oauth2ResourceServer().opaqueToken();
}
}
我的控制器:
@RestController
public class Controller {
@PostMapping(value = "/foo", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public void uploadMedia(BearerTokenAuthentication bearerTokenAuthentication,
@RequestHeader(value = "Authorization") String bearerToken){
System.out.println(bearerTokenAuthentication.getToken().getTokenValue());
}
}
如何使用spring security通过自省验证OAuth令牌?
马修
【问题讨论】:
-
我也在尝试,您找到解决方案了吗?
标签: spring security oauth token introspection