Apply consistent naming for jwkSet

Issue gh-143
This commit is contained in:
Joe Grandja 2020-11-30 07:33:42 -05:00
parent eb97e12f56
commit 4e4656f7bb
8 changed files with 24 additions and 24 deletions

View File

@ -221,7 +221,7 @@ public final class OAuth2AuthorizationServerConfigurer<B extends HttpSecurityBui
JwkSetEndpointFilter jwkSetEndpointFilter = new JwkSetEndpointFilter( JwkSetEndpointFilter jwkSetEndpointFilter = new JwkSetEndpointFilter(
getKeySource(builder), getKeySource(builder),
providerSettings.jwksEndpoint()); providerSettings.jwkSetEndpoint());
builder.addFilterBefore(postProcess(jwkSetEndpointFilter), AbstractPreAuthenticatedProcessingFilter.class); builder.addFilterBefore(postProcess(jwkSetEndpointFilter), AbstractPreAuthenticatedProcessingFilter.class);
AuthenticationManager authenticationManager = builder.getSharedObject(AuthenticationManager.class); AuthenticationManager authenticationManager = builder.getSharedObject(AuthenticationManager.class);

View File

@ -142,11 +142,11 @@ public final class OidcProviderConfiguration implements OidcProviderMetadataClai
/** /**
* Use this {@code jwks_uri} in the resulting {@link OidcProviderConfiguration}, REQUIRED. * Use this {@code jwks_uri} in the resulting {@link OidcProviderConfiguration}, REQUIRED.
* *
* @param jwksUri the URL of the OpenID Provider's JSON Web Key Set document * @param jwkSetUri the URL of the OpenID Provider's JSON Web Key Set document
* @return the {@link Builder} for further configuration * @return the {@link Builder} for further configuration
*/ */
public Builder jwksUri(String jwksUri) { public Builder jwkSetUri(String jwkSetUri) {
return claim(OidcProviderMetadataClaimNames.JWKS_URI, jwksUri); return claim(OidcProviderMetadataClaimNames.JWKS_URI, jwkSetUri);
} }
/** /**

View File

@ -30,7 +30,7 @@ public class ProviderSettings extends Settings {
public static final String ISSUER = PROVIDER_SETTING_BASE.concat("issuer"); public static final String ISSUER = PROVIDER_SETTING_BASE.concat("issuer");
public static final String AUTHORIZATION_ENDPOINT = PROVIDER_SETTING_BASE.concat("authorization-endpoint"); public static final String AUTHORIZATION_ENDPOINT = PROVIDER_SETTING_BASE.concat("authorization-endpoint");
public static final String TOKEN_ENDPOINT = PROVIDER_SETTING_BASE.concat("token-endpoint"); public static final String TOKEN_ENDPOINT = PROVIDER_SETTING_BASE.concat("token-endpoint");
public static final String JWKS_ENDPOINT = PROVIDER_SETTING_BASE.concat("jwks-endpoint"); public static final String JWK_SET_ENDPOINT = PROVIDER_SETTING_BASE.concat("jwk-set-endpoint");
public static final String TOKEN_REVOCATION_ENDPOINT = PROVIDER_SETTING_BASE.concat("token-revocation-endpoint"); public static final String TOKEN_REVOCATION_ENDPOINT = PROVIDER_SETTING_BASE.concat("token-revocation-endpoint");
/** /**
@ -111,18 +111,18 @@ public class ProviderSettings extends Settings {
* *
* @return the JWK Set endpoint * @return the JWK Set endpoint
*/ */
public String jwksEndpoint() { public String jwkSetEndpoint() {
return setting(JWKS_ENDPOINT); return setting(JWK_SET_ENDPOINT);
} }
/** /**
* Sets the Provider's JWK Set endpoint. * Sets the Provider's JWK Set endpoint.
* *
* @param jwksEndpoint the JWK Set endpoint * @param jwkSetEndpoint the JWK Set endpoint
* @return the {@link ProviderSettings} for further configuration * @return the {@link ProviderSettings} for further configuration
*/ */
public ProviderSettings jwksEndpoint(String jwksEndpoint) { public ProviderSettings jwkSetEndpoint(String jwkSetEndpoint) {
return setting(JWKS_ENDPOINT, jwksEndpoint); return setting(JWK_SET_ENDPOINT, jwkSetEndpoint);
} }
/** /**
@ -148,7 +148,7 @@ public class ProviderSettings extends Settings {
Map<String, Object> settings = new HashMap<>(); Map<String, Object> settings = new HashMap<>();
settings.put(AUTHORIZATION_ENDPOINT, "/oauth2/authorize"); settings.put(AUTHORIZATION_ENDPOINT, "/oauth2/authorize");
settings.put(TOKEN_ENDPOINT, "/oauth2/token"); settings.put(TOKEN_ENDPOINT, "/oauth2/token");
settings.put(JWKS_ENDPOINT, "/oauth2/jwks"); settings.put(JWK_SET_ENDPOINT, "/oauth2/jwks");
settings.put(TOKEN_REVOCATION_ENDPOINT, "/oauth2/revoke"); settings.put(TOKEN_REVOCATION_ENDPOINT, "/oauth2/revoke");
return settings; return settings;
} }

View File

@ -80,7 +80,7 @@ public class OidcProviderConfigurationEndpointFilter extends OncePerRequestFilte
.tokenEndpoint(asUrl(this.providerSettings.issuer(), this.providerSettings.tokenEndpoint())) .tokenEndpoint(asUrl(this.providerSettings.issuer(), this.providerSettings.tokenEndpoint()))
.tokenEndpointAuthenticationMethod("client_secret_basic") // TODO: Use ClientAuthenticationMethod.CLIENT_SECRET_BASIC in Spring Security 5.5.0 .tokenEndpointAuthenticationMethod("client_secret_basic") // TODO: Use ClientAuthenticationMethod.CLIENT_SECRET_BASIC in Spring Security 5.5.0
.tokenEndpointAuthenticationMethod("client_secret_post") // TODO: Use ClientAuthenticationMethod.CLIENT_SECRET_POST in Spring Security 5.5.0 .tokenEndpointAuthenticationMethod("client_secret_post") // TODO: Use ClientAuthenticationMethod.CLIENT_SECRET_POST in Spring Security 5.5.0
.jwksUri(asUrl(this.providerSettings.issuer(), this.providerSettings.jwksEndpoint())) .jwkSetUri(asUrl(this.providerSettings.issuer(), this.providerSettings.jwkSetEndpoint()))
.responseType(OAuth2AuthorizationResponseType.CODE.getValue()) .responseType(OAuth2AuthorizationResponseType.CODE.getValue())
.grantType(AuthorizationGrantType.AUTHORIZATION_CODE.getValue()) .grantType(AuthorizationGrantType.AUTHORIZATION_CODE.getValue())
.grantType(AuthorizationGrantType.CLIENT_CREDENTIALS.getValue()) .grantType(AuthorizationGrantType.CLIENT_CREDENTIALS.getValue())

View File

@ -38,7 +38,7 @@ public class OidcProviderConfigurationTests {
.issuer("https://example.com/issuer1") .issuer("https://example.com/issuer1")
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize") .authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
.tokenEndpoint("https://example.com/issuer1/oauth2/token") .tokenEndpoint("https://example.com/issuer1/oauth2/token")
.jwksUri("https://example.com/issuer1/oauth2/jwks") .jwkSetUri("https://example.com/issuer1/oauth2/jwks")
.scope("openid") .scope("openid")
.responseType("code") .responseType("code")
.subjectType("public"); .subjectType("public");
@ -49,7 +49,7 @@ public class OidcProviderConfigurationTests {
.issuer("https://example.com/issuer1") .issuer("https://example.com/issuer1")
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize") .authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
.tokenEndpoint("https://example.com/issuer1/oauth2/token") .tokenEndpoint("https://example.com/issuer1/oauth2/token")
.jwksUri("https://example.com/issuer1/oauth2/jwks") .jwkSetUri("https://example.com/issuer1/oauth2/jwks")
.scope("openid") .scope("openid")
.responseType("code") .responseType("code")
.grantType("authorization_code") .grantType("authorization_code")
@ -77,7 +77,7 @@ public class OidcProviderConfigurationTests {
.issuer("https://example.com/issuer1") .issuer("https://example.com/issuer1")
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize") .authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
.tokenEndpoint("https://example.com/issuer1/oauth2/token") .tokenEndpoint("https://example.com/issuer1/oauth2/token")
.jwksUri("https://example.com/issuer1/oauth2/jwks") .jwkSetUri("https://example.com/issuer1/oauth2/jwks")
.scope("openid") .scope("openid")
.responseType("code") .responseType("code")
.subjectType("public") .subjectType("public")

View File

@ -149,7 +149,7 @@ public class OidcProviderConfigurationHttpMessageConverterTests {
.issuer("https://example.com/issuer1") .issuer("https://example.com/issuer1")
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize") .authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
.tokenEndpoint("https://example.com/issuer1/oauth2/token") .tokenEndpoint("https://example.com/issuer1/oauth2/token")
.jwksUri("https://example.com/issuer1/oauth2/jwks") .jwkSetUri("https://example.com/issuer1/oauth2/jwks")
.scope("openid") .scope("openid")
.responseType("code") .responseType("code")
.grantType("authorization_code") .grantType("authorization_code")
@ -191,7 +191,7 @@ public class OidcProviderConfigurationHttpMessageConverterTests {
.issuer("https://example.com/issuer1") .issuer("https://example.com/issuer1")
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize") .authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
.tokenEndpoint("https://example.com/issuer1/oauth2/token") .tokenEndpoint("https://example.com/issuer1/oauth2/token")
.jwksUri("https://example.com/issuer1/oauth2/jwks") .jwkSetUri("https://example.com/issuer1/oauth2/jwks")
.responseType("code") .responseType("code")
.subjectType("public") .subjectType("public")
.build(); .build();

View File

@ -34,7 +34,7 @@ public class ProviderSettingsTests {
assertThat(providerSettings.issuer()).isNull(); assertThat(providerSettings.issuer()).isNull();
assertThat(providerSettings.authorizationEndpoint()).isEqualTo("/oauth2/authorize"); assertThat(providerSettings.authorizationEndpoint()).isEqualTo("/oauth2/authorize");
assertThat(providerSettings.tokenEndpoint()).isEqualTo("/oauth2/token"); assertThat(providerSettings.tokenEndpoint()).isEqualTo("/oauth2/token");
assertThat(providerSettings.jwksEndpoint()).isEqualTo("/oauth2/jwks"); assertThat(providerSettings.jwkSetEndpoint()).isEqualTo("/oauth2/jwks");
assertThat(providerSettings.tokenRevocationEndpoint()).isEqualTo("/oauth2/revoke"); assertThat(providerSettings.tokenRevocationEndpoint()).isEqualTo("/oauth2/revoke");
} }
@ -42,7 +42,7 @@ public class ProviderSettingsTests {
public void settingsWhenProvidedThenSet() { public void settingsWhenProvidedThenSet() {
String authorizationEndpoint = "/oauth2/v1/authorize"; String authorizationEndpoint = "/oauth2/v1/authorize";
String tokenEndpoint = "/oauth2/v1/token"; String tokenEndpoint = "/oauth2/v1/token";
String jwksEndpoint = "/oauth2/v1/jwks"; String jwkSetEndpoint = "/oauth2/v1/jwks";
String tokenRevocationEndpoint = "/oauth2/v1/revoke"; String tokenRevocationEndpoint = "/oauth2/v1/revoke";
String issuer = "https://example.com:9000"; String issuer = "https://example.com:9000";
@ -50,13 +50,13 @@ public class ProviderSettingsTests {
.issuer(issuer) .issuer(issuer)
.authorizationEndpoint(authorizationEndpoint) .authorizationEndpoint(authorizationEndpoint)
.tokenEndpoint(tokenEndpoint) .tokenEndpoint(tokenEndpoint)
.jwksEndpoint(jwksEndpoint) .jwkSetEndpoint(jwkSetEndpoint)
.tokenRevocationEndpoint(tokenRevocationEndpoint); .tokenRevocationEndpoint(tokenRevocationEndpoint);
assertThat(providerSettings.issuer()).isEqualTo(issuer); assertThat(providerSettings.issuer()).isEqualTo(issuer);
assertThat(providerSettings.authorizationEndpoint()).isEqualTo(authorizationEndpoint); assertThat(providerSettings.authorizationEndpoint()).isEqualTo(authorizationEndpoint);
assertThat(providerSettings.tokenEndpoint()).isEqualTo(tokenEndpoint); assertThat(providerSettings.tokenEndpoint()).isEqualTo(tokenEndpoint);
assertThat(providerSettings.jwksEndpoint()).isEqualTo(jwksEndpoint); assertThat(providerSettings.jwkSetEndpoint()).isEqualTo(jwkSetEndpoint);
assertThat(providerSettings.tokenRevocationEndpoint()).isEqualTo(tokenRevocationEndpoint); assertThat(providerSettings.tokenRevocationEndpoint()).isEqualTo(tokenRevocationEndpoint);
} }
@ -106,7 +106,7 @@ public class ProviderSettingsTests {
@Test @Test
public void jwksEndpointWhenNullThenThrowIllegalArgumentException() { public void jwksEndpointWhenNullThenThrowIllegalArgumentException() {
ProviderSettings settings = new ProviderSettings(); ProviderSettings settings = new ProviderSettings();
assertThatThrownBy(() -> settings.jwksEndpoint(null)) assertThatThrownBy(() -> settings.jwkSetEndpoint(null))
.isInstanceOf(IllegalArgumentException.class) .isInstanceOf(IllegalArgumentException.class)
.hasMessage("value cannot be null"); .hasMessage("value cannot be null");
} }

View File

@ -82,13 +82,13 @@ public class OidcProviderConfigurationEndpointFilterTests {
public void doFilterWhenConfigurationRequestThenConfigurationResponse() throws Exception { public void doFilterWhenConfigurationRequestThenConfigurationResponse() throws Exception {
String authorizationEndpoint = "/oauth2/v1/authorize"; String authorizationEndpoint = "/oauth2/v1/authorize";
String tokenEndpoint = "/oauth2/v1/token"; String tokenEndpoint = "/oauth2/v1/token";
String jwksEndpoint = "/oauth2/v1/jwks"; String jwkSetEndpoint = "/oauth2/v1/jwks";
ProviderSettings providerSettings = new ProviderSettings() ProviderSettings providerSettings = new ProviderSettings()
.issuer("https://example.com/issuer1") .issuer("https://example.com/issuer1")
.authorizationEndpoint(authorizationEndpoint) .authorizationEndpoint(authorizationEndpoint)
.tokenEndpoint(tokenEndpoint) .tokenEndpoint(tokenEndpoint)
.jwksEndpoint(jwksEndpoint); .jwkSetEndpoint(jwkSetEndpoint);
OidcProviderConfigurationEndpointFilter filter = OidcProviderConfigurationEndpointFilter filter =
new OidcProviderConfigurationEndpointFilter(providerSettings); new OidcProviderConfigurationEndpointFilter(providerSettings);