Skip to content

JwtDecoder constructor using Public Key #5911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
antmordel opened this issue Sep 29, 2018 · 1 comment
Closed

JwtDecoder constructor using Public Key #5911

antmordel opened this issue Sep 29, 2018 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@antmordel
Copy link

Summary

As in the class NimbusReactiveJwtDecoder, it'd be nice to have a constructor in NimbusJwtDecoderJwkSupport to create the JwtDecoder using only the PublicKey to used to verify the signature.

Version

Spring Security 5.1

Sample

public NimbusJwtDecoderJwkSupport(RSAPublicKey publicKey) throws InvalidKeySpecException, NoSuchAlgorithmException {
        RSAKey rsaKey = new RSAKey.Builder(publicKey).build();
        JWKSet jwkSet = new JWKSet(rsaKey);
        JWKSource jwkSource = new ImmutableJWKSet<>(jwkSet);
        JWSKeySelector<SecurityContext> jwsKeySelector =
                new JWSVerificationKeySelector<>(JWSAlgorithm.parse(JwsAlgorithms.RS256), jwkSource);
        DefaultJWTProcessor jwtProcessor = new DefaultJWTProcessor<>();
        jwtProcessor.setJWSKeySelector(jwsKeySelector);
        this.jwtProcessor = new DefaultJWTProcessor<>();
        this.jwtProcessor.setJWSKeySelector(jwsKeySelector);

        // Spring Security validates the claim set independent from Nimbus
        this.jwtProcessor.setJWTClaimsSetVerifier((claims, context) -> {});
    }
@jzheaux jzheaux added the status: duplicate A duplicate of another issue label Oct 1, 2018
@jzheaux
Copy link
Contributor

jzheaux commented Oct 1, 2018

@antmordel thanks for the suggestion!

I'm going to link this to the original task that we already have for this: #5131

That way, you can follow progress there.

@jzheaux jzheaux closed this as completed Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants