Spring OAuth2 token introspection with mTLS

avkwfej4  于 2024-01-05  发布在  Spring
关注(0)|答案(1)|浏览(177)

我正在尝试使用Sping Boot 和Spring Security实现一个OAuth2资源服务器。我的内省服务器需要mTLS用于令牌内省请求。
如何配置Spring Security以使用客户端证书进行令牌内省调用?
我的安全配置看起来像这样:

  1. @Configuration
  2. @EnableWebSecurity
  3. public class MyCustomSecurityConfiguration {
  4. @Bean
  5. public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
  6. http
  7. .authorizeHttpRequests(authorize -> authorize
  8. .anyRequest().authenticated()
  9. )
  10. .oauth2ResourceServer(oauth2 -> oauth2
  11. .opaqueToken(opaqueToken -> opaqueToken
  12. .introspector(myIntrospector())
  13. )
  14. );
  15. return http.build();
  16. }
  17. }

字符串
我尝试提供自己的自定义内省器,它基于NimbusOpaqueTokenIntrospector,但我看不到任何方法,我如何将TLS证书添加到底层HTTP请求。

gev0vcfq

gev0vcfq1#

我通过使用构造函数NimbusOpaqueTokenIntrospector(StringintrospectionUri,org.springframework.web.client.RestOperations restOperations)使其工作
作为第二个构造函数参数,我提供了一个Spring RestTemplate的mTLS自定义实现

相关问题