From 1f5edc98d55bc4f56b85817fa8762b088f661d23 Mon Sep 17 00:00:00 2001 From: Joe Grandja Date: Thu, 19 Oct 2017 11:17:19 -0400 Subject: [PATCH] ClientRegistration.Builder.scopes -> scope Fixes gh-4663 --- .../config/oauth2/client/CommonOAuth2Provider.java | 8 ++++---- .../oauth2/client/registration/ClientRegistration.java | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/oauth2/client/CommonOAuth2Provider.java b/config/src/main/java/org/springframework/security/config/oauth2/client/CommonOAuth2Provider.java index 38a1bad3eb..9d823735f2 100644 --- a/config/src/main/java/org/springframework/security/config/oauth2/client/CommonOAuth2Provider.java +++ b/config/src/main/java/org/springframework/security/config/oauth2/client/CommonOAuth2Provider.java @@ -37,7 +37,7 @@ public enum CommonOAuth2Provider { public Builder getBuilder(String registrationId) { ClientRegistration.Builder builder = getBuilder(registrationId, ClientAuthenticationMethod.BASIC, DEFAULT_REDIRECT_URL); - builder.scopes("openid", "profile", "email", "address", "phone"); + builder.scope("openid", "profile", "email", "address", "phone"); builder.authorizationUri("https://accounts.google.com/o/oauth2/v2/auth"); builder.tokenUri("https://www.googleapis.com/oauth2/v4/token"); builder.jwkSetUri("https://www.googleapis.com/oauth2/v3/certs"); @@ -54,7 +54,7 @@ public enum CommonOAuth2Provider { public Builder getBuilder(String registrationId) { ClientRegistration.Builder builder = getBuilder(registrationId, ClientAuthenticationMethod.BASIC, DEFAULT_REDIRECT_URL); - builder.scopes("user"); + builder.scope("user"); builder.authorizationUri("https://github.com/login/oauth/authorize"); builder.tokenUri("https://github.com/login/oauth/access_token"); builder.userInfoUri("https://api.github.com/user"); @@ -70,7 +70,7 @@ public enum CommonOAuth2Provider { public Builder getBuilder(String registrationId) { ClientRegistration.Builder builder = getBuilder(registrationId, ClientAuthenticationMethod.POST, DEFAULT_REDIRECT_URL); - builder.scopes("public_profile", "email"); + builder.scope("public_profile", "email"); builder.authorizationUri("https://www.facebook.com/v2.8/dialog/oauth"); builder.tokenUri("https://graph.facebook.com/v2.8/oauth/access_token"); builder.userInfoUri("https://graph.facebook.com/me"); @@ -86,7 +86,7 @@ public enum CommonOAuth2Provider { public Builder getBuilder(String registrationId) { ClientRegistration.Builder builder = getBuilder(registrationId, ClientAuthenticationMethod.BASIC, DEFAULT_REDIRECT_URL); - builder.scopes("openid", "profile", "email", "address", "phone"); + builder.scope("openid", "profile", "email", "address", "phone"); builder.userNameAttributeName(IdTokenClaim.SUB); builder.clientName("Okta"); return builder; diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientRegistration.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientRegistration.java index a8b458c46f..65d0a4f633 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientRegistration.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientRegistration.java @@ -212,7 +212,7 @@ public class ClientRegistration { this.authorizationGrantType(clientRegistrationProperties.getAuthorizationGrantType()); this.redirectUri(clientRegistrationProperties.getRedirectUri()); if (!CollectionUtils.isEmpty(clientRegistrationProperties.getScope())) { - this.scopes(clientRegistrationProperties.getScope().toArray(new String[0])); + this.scope(clientRegistrationProperties.getScope().toArray(new String[0])); } this.authorizationUri(clientRegistrationProperties.getAuthorizationUri()); this.tokenUri(clientRegistrationProperties.getTokenUri()); @@ -230,7 +230,7 @@ public class ClientRegistration { this.authorizationGrantType(clientRegistration.getAuthorizationGrantType()); this.redirectUri(clientRegistration.getRedirectUri()); if (!CollectionUtils.isEmpty(clientRegistration.getScopes())) { - this.scopes(clientRegistration.getScopes().toArray(new String[0])); + this.scope(clientRegistration.getScopes().toArray(new String[0])); } this.authorizationUri(clientRegistration.getProviderDetails().getAuthorizationUri()); this.tokenUri(clientRegistration.getProviderDetails().getTokenUri()); @@ -265,10 +265,10 @@ public class ClientRegistration { return this; } - public Builder scopes(String... scopes) { - if (scopes != null && scopes.length > 0) { + public Builder scope(String... scope) { + if (scope != null && scope.length > 0) { this.scopes = Collections.unmodifiableSet( - new LinkedHashSet<>(Arrays.asList(scopes))); + new LinkedHashSet<>(Arrays.asList(scope))); } return this; }