From 4e4656f7bbb6a97c34cb55abdb73106f9c1e9c90 Mon Sep 17 00:00:00 2001 From: Joe Grandja Date: Mon, 30 Nov 2020 07:33:42 -0500 Subject: [PATCH] Apply consistent naming for jwkSet Issue gh-143 --- .../OAuth2AuthorizationServerConfigurer.java | 2 +- .../core/oidc/OidcProviderConfiguration.java | 6 +++--- .../authorization/config/ProviderSettings.java | 14 +++++++------- .../OidcProviderConfigurationEndpointFilter.java | 2 +- .../core/oidc/OidcProviderConfigurationTests.java | 6 +++--- ...iderConfigurationHttpMessageConverterTests.java | 4 ++-- .../config/ProviderSettingsTests.java | 10 +++++----- ...dcProviderConfigurationEndpointFilterTests.java | 4 ++-- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2AuthorizationServerConfigurer.java b/oauth2-authorization-server/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2AuthorizationServerConfigurer.java index 3adbe88..a6f25b6 100644 --- a/oauth2-authorization-server/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2AuthorizationServerConfigurer.java +++ b/oauth2-authorization-server/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2AuthorizationServerConfigurer.java @@ -221,7 +221,7 @@ public final class OAuth2AuthorizationServerConfigurer settings = new HashMap<>(); settings.put(AUTHORIZATION_ENDPOINT, "/oauth2/authorize"); 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"); return settings; } diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/OidcProviderConfigurationEndpointFilter.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/OidcProviderConfigurationEndpointFilter.java index 0a75bb6..92a90da 100644 --- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/OidcProviderConfigurationEndpointFilter.java +++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/OidcProviderConfigurationEndpointFilter.java @@ -80,7 +80,7 @@ public class OidcProviderConfigurationEndpointFilter extends OncePerRequestFilte .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_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()) .grantType(AuthorizationGrantType.AUTHORIZATION_CODE.getValue()) .grantType(AuthorizationGrantType.CLIENT_CREDENTIALS.getValue()) diff --git a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/oidc/OidcProviderConfigurationTests.java b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/oidc/OidcProviderConfigurationTests.java index 15c63e6..45ce178 100644 --- a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/oidc/OidcProviderConfigurationTests.java +++ b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/oidc/OidcProviderConfigurationTests.java @@ -38,7 +38,7 @@ public class OidcProviderConfigurationTests { .issuer("https://example.com/issuer1") .authorizationEndpoint("https://example.com/issuer1/oauth2/authorize") .tokenEndpoint("https://example.com/issuer1/oauth2/token") - .jwksUri("https://example.com/issuer1/oauth2/jwks") + .jwkSetUri("https://example.com/issuer1/oauth2/jwks") .scope("openid") .responseType("code") .subjectType("public"); @@ -49,7 +49,7 @@ public class OidcProviderConfigurationTests { .issuer("https://example.com/issuer1") .authorizationEndpoint("https://example.com/issuer1/oauth2/authorize") .tokenEndpoint("https://example.com/issuer1/oauth2/token") - .jwksUri("https://example.com/issuer1/oauth2/jwks") + .jwkSetUri("https://example.com/issuer1/oauth2/jwks") .scope("openid") .responseType("code") .grantType("authorization_code") @@ -77,7 +77,7 @@ public class OidcProviderConfigurationTests { .issuer("https://example.com/issuer1") .authorizationEndpoint("https://example.com/issuer1/oauth2/authorize") .tokenEndpoint("https://example.com/issuer1/oauth2/token") - .jwksUri("https://example.com/issuer1/oauth2/jwks") + .jwkSetUri("https://example.com/issuer1/oauth2/jwks") .scope("openid") .responseType("code") .subjectType("public") diff --git a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/oidc/http/converter/OidcProviderConfigurationHttpMessageConverterTests.java b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/oidc/http/converter/OidcProviderConfigurationHttpMessageConverterTests.java index b4e8590..2b41f9e 100644 --- a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/oidc/http/converter/OidcProviderConfigurationHttpMessageConverterTests.java +++ b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/oidc/http/converter/OidcProviderConfigurationHttpMessageConverterTests.java @@ -149,7 +149,7 @@ public class OidcProviderConfigurationHttpMessageConverterTests { .issuer("https://example.com/issuer1") .authorizationEndpoint("https://example.com/issuer1/oauth2/authorize") .tokenEndpoint("https://example.com/issuer1/oauth2/token") - .jwksUri("https://example.com/issuer1/oauth2/jwks") + .jwkSetUri("https://example.com/issuer1/oauth2/jwks") .scope("openid") .responseType("code") .grantType("authorization_code") @@ -191,7 +191,7 @@ public class OidcProviderConfigurationHttpMessageConverterTests { .issuer("https://example.com/issuer1") .authorizationEndpoint("https://example.com/issuer1/oauth2/authorize") .tokenEndpoint("https://example.com/issuer1/oauth2/token") - .jwksUri("https://example.com/issuer1/oauth2/jwks") + .jwkSetUri("https://example.com/issuer1/oauth2/jwks") .responseType("code") .subjectType("public") .build(); diff --git a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/config/ProviderSettingsTests.java b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/config/ProviderSettingsTests.java index cc33a77..db8a3a1 100644 --- a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/config/ProviderSettingsTests.java +++ b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/config/ProviderSettingsTests.java @@ -34,7 +34,7 @@ public class ProviderSettingsTests { assertThat(providerSettings.issuer()).isNull(); assertThat(providerSettings.authorizationEndpoint()).isEqualTo("/oauth2/authorize"); assertThat(providerSettings.tokenEndpoint()).isEqualTo("/oauth2/token"); - assertThat(providerSettings.jwksEndpoint()).isEqualTo("/oauth2/jwks"); + assertThat(providerSettings.jwkSetEndpoint()).isEqualTo("/oauth2/jwks"); assertThat(providerSettings.tokenRevocationEndpoint()).isEqualTo("/oauth2/revoke"); } @@ -42,7 +42,7 @@ public class ProviderSettingsTests { public void settingsWhenProvidedThenSet() { String authorizationEndpoint = "/oauth2/v1/authorize"; String tokenEndpoint = "/oauth2/v1/token"; - String jwksEndpoint = "/oauth2/v1/jwks"; + String jwkSetEndpoint = "/oauth2/v1/jwks"; String tokenRevocationEndpoint = "/oauth2/v1/revoke"; String issuer = "https://example.com:9000"; @@ -50,13 +50,13 @@ public class ProviderSettingsTests { .issuer(issuer) .authorizationEndpoint(authorizationEndpoint) .tokenEndpoint(tokenEndpoint) - .jwksEndpoint(jwksEndpoint) + .jwkSetEndpoint(jwkSetEndpoint) .tokenRevocationEndpoint(tokenRevocationEndpoint); assertThat(providerSettings.issuer()).isEqualTo(issuer); assertThat(providerSettings.authorizationEndpoint()).isEqualTo(authorizationEndpoint); assertThat(providerSettings.tokenEndpoint()).isEqualTo(tokenEndpoint); - assertThat(providerSettings.jwksEndpoint()).isEqualTo(jwksEndpoint); + assertThat(providerSettings.jwkSetEndpoint()).isEqualTo(jwkSetEndpoint); assertThat(providerSettings.tokenRevocationEndpoint()).isEqualTo(tokenRevocationEndpoint); } @@ -106,7 +106,7 @@ public class ProviderSettingsTests { @Test public void jwksEndpointWhenNullThenThrowIllegalArgumentException() { ProviderSettings settings = new ProviderSettings(); - assertThatThrownBy(() -> settings.jwksEndpoint(null)) + assertThatThrownBy(() -> settings.jwkSetEndpoint(null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("value cannot be null"); } diff --git a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/OidcProviderConfigurationEndpointFilterTests.java b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/OidcProviderConfigurationEndpointFilterTests.java index 012bd07..8bd3c2e 100644 --- a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/OidcProviderConfigurationEndpointFilterTests.java +++ b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/OidcProviderConfigurationEndpointFilterTests.java @@ -82,13 +82,13 @@ public class OidcProviderConfigurationEndpointFilterTests { public void doFilterWhenConfigurationRequestThenConfigurationResponse() throws Exception { String authorizationEndpoint = "/oauth2/v1/authorize"; String tokenEndpoint = "/oauth2/v1/token"; - String jwksEndpoint = "/oauth2/v1/jwks"; + String jwkSetEndpoint = "/oauth2/v1/jwks"; ProviderSettings providerSettings = new ProviderSettings() .issuer("https://example.com/issuer1") .authorizationEndpoint(authorizationEndpoint) .tokenEndpoint(tokenEndpoint) - .jwksEndpoint(jwksEndpoint); + .jwkSetEndpoint(jwkSetEndpoint); OidcProviderConfigurationEndpointFilter filter = new OidcProviderConfigurationEndpointFilter(providerSettings);