Sfoglia il codice sorgente

Apply consistent naming for jwkSet

Issue gh-143
Joe Grandja 4 anni fa
parent
commit
4e4656f7bb

+ 1 - 1
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<B extends HttpSecurityBui
 
 		JwkSetEndpointFilter jwkSetEndpointFilter = new JwkSetEndpointFilter(
 				getKeySource(builder),
-				providerSettings.jwksEndpoint());
+				providerSettings.jwkSetEndpoint());
 		builder.addFilterBefore(postProcess(jwkSetEndpointFilter), AbstractPreAuthenticatedProcessingFilter.class);
 
 		AuthenticationManager authenticationManager = builder.getSharedObject(AuthenticationManager.class);

+ 3 - 3
oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/oidc/OidcProviderConfiguration.java

@@ -142,11 +142,11 @@ public final class OidcProviderConfiguration implements OidcProviderMetadataClai
 		/**
 		 * 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
 		 */
-		public Builder jwksUri(String jwksUri) {
-			return claim(OidcProviderMetadataClaimNames.JWKS_URI, jwksUri);
+		public Builder jwkSetUri(String jwkSetUri) {
+			return claim(OidcProviderMetadataClaimNames.JWKS_URI, jwkSetUri);
 		}
 
 		/**

+ 7 - 7
oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/config/ProviderSettings.java

@@ -30,7 +30,7 @@ public class ProviderSettings extends Settings {
 	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 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");
 
 	/**
@@ -111,18 +111,18 @@ public class ProviderSettings extends Settings {
 	 *
 	 * @return the JWK Set endpoint
 	 */
-	public String jwksEndpoint() {
-		return setting(JWKS_ENDPOINT);
+	public String jwkSetEndpoint() {
+		return setting(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
 	 */
-	public ProviderSettings jwksEndpoint(String jwksEndpoint) {
-		return setting(JWKS_ENDPOINT, jwksEndpoint);
+	public ProviderSettings jwkSetEndpoint(String jwkSetEndpoint) {
+		return setting(JWK_SET_ENDPOINT, jwkSetEndpoint);
 	}
 
 	/**
@@ -148,7 +148,7 @@ public class ProviderSettings extends Settings {
 		Map<String, Object> 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;
 	}

+ 1 - 1
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())

+ 3 - 3
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")

+ 2 - 2
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();

+ 5 - 5
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");
 	}

+ 2 - 2
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);