我正在尝试使用Sping Boot 和Spring Security实现一个OAuth2资源服务器。我的内省服务器需要mTLS用于令牌内省请求。
如何配置Spring Security以使用客户端证书进行令牌内省调用?
我的安全配置看起来像这样:
@Configuration
@EnableWebSecurity
public class MyCustomSecurityConfiguration {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(authorize -> authorize
.anyRequest().authenticated()
)
.oauth2ResourceServer(oauth2 -> oauth2
.opaqueToken(opaqueToken -> opaqueToken
.introspector(myIntrospector())
)
);
return http.build();
}
}
字符串
我尝试提供自己的自定义内省器,它基于NimbusOpaqueTokenIntrospector
,但我看不到任何方法,我如何将TLS证书添加到底层HTTP请求。
1条答案
按热度按时间gev0vcfq1#
我通过使用构造函数NimbusOpaqueTokenIntrospector(StringintrospectionUri,org.springframework.web.client.RestOperations restOperations)使其工作
作为第二个构造函数参数,我提供了一个Spring RestTemplate的mTLS自定义实现