我正在尝试集成外部oauth 2身份验证服务器和资源服务器。它们的配置需要一些其他自定义参数:状态-应该是uuid,TimeStamp,accessType,还应该使用所有先前参数的组合作为数据对clientSecret进行签名。
我们正在使用Spring Boot,Spring Security 5.1,Camunda。
问题是我无法将参数直接添加到URI调用方法setUserAuthorizationUri中,因为此方法在初始化期间仅被调用一次
外部 OAuth2 提供程序没有公共 JwkUri,因此我也尝试使用以下代码片段覆盖默认行为:
@EnableWebSecurity
public class DirectlyConfiguredJwkSetUri extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("**/oauth2/code/esia**", "**/code/esia**", "**esia**").permitAll()
.antMatchers("/user").fullyAuthenticated()
.anyRequest().authenticated()
.and()
.csrf().disable()
.cors().disable()
.oauth2Client()
.clientRegistrationRepository(this.clientRegistrationRepository)
.authorizationCodeGrant()
.authorizationRequestResolver(new CustomAuthorizationRequestResolver(
this.clientRegistrationRepository, esiaConfig, signatureUtil, timeUtil))
.accessTokenResponseClient(customAccessTokenResponseClient())
.and().and().oauth2Login().tokenEndpoint().accessTokenResponseClient(customAccessTokenResponseClient())
.and().and().oauth2ResourceServer().jwt();
}
@Bean
JwtDecoder jwtDecoder() {
return new CustomJwtDecoder();
}
}
class CustomJwtDecoder implements JwtDecoder {
@Override
public Jwt decode(String token) throws JwtException {
System.out.println(token);
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
然而 Spring Security 不知何故仍然使用默认实现,我收到以下错误......
[missing_signature_verifier] Failed to find a Signature Verifier …Run Code Online (Sandbox Code Playgroud)