Skip to content

Conversation

jsight
Copy link

@jsight jsight commented Aug 16, 2025

I ran into this issue earlier today and found it surprisingly difficult to use a converter along with JwtIssuerAuthenticationManagerResolver. This is a proposed PR to make it possible to directly pass in the converter when creating the resolver.

Thoughts?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 16, 2025
@jzheaux
Copy link
Contributor

jzheaux commented Sep 10, 2025

Hi, @jsight, thanks for the suggestion. I'd prefer to leave the implementation details hidden regarding what authentication provider(s) the resolver chooses to construct, if possible.

Have you already considered the following:

public final class MyIssuerAuthenticationManagerResolver implements AuthenticationManagerResolver<String> {
    private final List<String> issuers;
    
    @Cacheable
    @Override 
    public AuthenticationManager resolve(String issuer) {
        Assert.isTrue(this.issuers.contains(issuer), "untrusted issuer");
        JwtDecoder jwtDecoder = JwtDecoder.fromIssuerLocation(issuer);
        JwtAuthenticationProvider authenticationProvider = new JwtAuthenticationProvider(jwtDecoder);
        JwtAuthenticationConverter converter = // your custom code
        authenticationProvider.setJwtAuthenticationConverter(converter);
        return new ProviderManager(authenticationProvider);
    }
}

and then:

JwtIssuerAuthenticationManagerResolver.fromTrustedIssuers(new MyIssuerAuthenticationManagerResolver());

@jzheaux jzheaux added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 10, 2025
@jzheaux jzheaux self-assigned this Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-feedback We need additional information before we can continue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants