Search in sources :

Example 1 with JwksSignature

use of io.micronaut.security.token.jwt.signature.jwks.JwksSignature in project micronaut-security by micronaut-projects.

the class DefaultOpenIdTokenResponseValidator method jwksSignatureForOpenIdProviderMetadata.

/**
 * @param openIdProviderMetadata The OpenID provider metadata
 * @return A {@link JwksSignature} for the OpenID provider JWKS uri.
 */
protected JwksSignature jwksSignatureForOpenIdProviderMetadata(@NonNull OpenIdProviderMetadata openIdProviderMetadata) {
    final String jwksuri = openIdProviderMetadata.getJwksUri();
    if (!jwksSignatures.containsKey(jwksuri)) {
        JwksSignatureConfigurationProperties config = new JwksSignatureConfigurationProperties();
        config.setUrl(openIdProviderMetadata.getJwksUri());
        jwksSignatures.put(jwksuri, new JwksSignature(config, jwkValidator));
    }
    return jwksSignatures.get(jwksuri);
}
Also used : JwksSignature(io.micronaut.security.token.jwt.signature.jwks.JwksSignature) JwksSignatureConfigurationProperties(io.micronaut.security.token.jwt.signature.jwks.JwksSignatureConfigurationProperties)

Example 2 with JwksSignature

use of io.micronaut.security.token.jwt.signature.jwks.JwksSignature in project micronaut-security by micronaut-projects.

the class JwksUriSignatureFactory method createJwksUriSignature.

/**
 * @param openIdProviderMetadata The open id provider metadata
 * @param jwkValidator JWK Validator
 * @return a {@link JwksSignature} pointed to the jwks_uri exposed via OpenID configuration
 */
@Requires(property = SecurityConfigurationProperties.PREFIX + ".authentication", value = "idtoken")
@EachBean(DefaultOpenIdProviderMetadata.class)
public JwksSignature createJwksUriSignature(@Parameter BeanProvider<DefaultOpenIdProviderMetadata> openIdProviderMetadata, JwkValidator jwkValidator) {
    JwksSignatureConfigurationProperties jwksSignatureConfiguration = new JwksSignatureConfigurationProperties();
    jwksSignatureConfiguration.setUrl(openIdProviderMetadata.get().getJwksUri());
    return new JwksSignature(jwksSignatureConfiguration, jwkValidator);
}
Also used : JwksSignature(io.micronaut.security.token.jwt.signature.jwks.JwksSignature) JwksSignatureConfigurationProperties(io.micronaut.security.token.jwt.signature.jwks.JwksSignatureConfigurationProperties) Requires(io.micronaut.context.annotation.Requires) EachBean(io.micronaut.context.annotation.EachBean)

Aggregations

JwksSignature (io.micronaut.security.token.jwt.signature.jwks.JwksSignature)2 JwksSignatureConfigurationProperties (io.micronaut.security.token.jwt.signature.jwks.JwksSignatureConfigurationProperties)2 EachBean (io.micronaut.context.annotation.EachBean)1 Requires (io.micronaut.context.annotation.Requires)1