diff --git a/src/Security/Authentication/Google/src/GoogleDefaults.cs b/src/Security/Authentication/Google/src/GoogleDefaults.cs index 105a801d7b..b4257f0619 100644 --- a/src/Security/Authentication/Google/src/GoogleDefaults.cs +++ b/src/Security/Authentication/Google/src/GoogleDefaults.cs @@ -19,23 +19,6 @@ namespace Microsoft.AspNetCore.Authentication.Google public static readonly string TokenEndpoint = "https://www.googleapis.com/oauth2/v4/token"; - public static readonly string UserInformationEndpoint; - - private const string UseGooglePlusSwitch = "Switch.Microsoft.AspNetCore.Authentication.Google.UsePlus"; - - internal static readonly bool UseGooglePlus; - - static GoogleDefaults() - { - if (AppContext.TryGetSwitch(UseGooglePlusSwitch, out UseGooglePlus) && UseGooglePlus) - { - // https://developers.google.com/+/web/people/ - UserInformationEndpoint = "https://www.googleapis.com/plus/v1/people/me"; - } - else - { - UserInformationEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo"; - } - } + public static readonly string UserInformationEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo"; } } diff --git a/src/Security/Authentication/Google/src/GoogleHelper.cs b/src/Security/Authentication/Google/src/GoogleHelper.cs deleted file mode 100644 index 2cac949a03..0000000000 --- a/src/Security/Authentication/Google/src/GoogleHelper.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Newtonsoft.Json.Linq; - -namespace Microsoft.AspNetCore.Authentication.Google -{ - /// - /// Contains static methods that allow to extract user's information from a - /// instance retrieved from Google after a successful authentication process. - /// - public static class GoogleHelper - { - /// - /// Gets the user's email. - /// - public static string GetEmail(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return TryGetFirstValue(user, "emails", "value"); - } - - // Get the given subProperty from a list property. - private static string TryGetFirstValue(JObject user, string propertyName, string subProperty) - { - JToken value; - if (user.TryGetValue(propertyName, out value)) - { - var array = JArray.Parse(value.ToString()); - if (array != null && array.Count > 0) - { - var subObject = JObject.Parse(array.First.ToString()); - if (subObject != null) - { - if (subObject.TryGetValue(subProperty, out value)) - { - return value.ToString(); - } - } - } - } - return null; - } - } -} diff --git a/src/Security/Authentication/Google/src/GoogleOptions.cs b/src/Security/Authentication/Google/src/GoogleOptions.cs index 03abaeaada..9d08bfc56a 100644 --- a/src/Security/Authentication/Google/src/GoogleOptions.cs +++ b/src/Security/Authentication/Google/src/GoogleOptions.cs @@ -26,22 +26,11 @@ namespace Microsoft.AspNetCore.Authentication.Google Scope.Add("email"); ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); - if (GoogleDefaults.UseGooglePlus) - { - ClaimActions.MapJsonKey(ClaimTypes.Name, "displayName"); - ClaimActions.MapJsonSubKey(ClaimTypes.GivenName, "name", "givenName"); - ClaimActions.MapJsonSubKey(ClaimTypes.Surname, "name", "familyName"); - ClaimActions.MapJsonKey("urn:google:profile", "url"); - ClaimActions.MapCustomJson(ClaimTypes.Email, GoogleHelper.GetEmail); - } - else - { - ClaimActions.MapJsonKey(ClaimTypes.Name, "name"); - ClaimActions.MapJsonKey(ClaimTypes.GivenName, "given_name"); - ClaimActions.MapJsonKey(ClaimTypes.Surname, "family_name"); - ClaimActions.MapJsonKey("urn:google:profile", "link"); - ClaimActions.MapJsonKey(ClaimTypes.Email, "email"); - } + ClaimActions.MapJsonKey(ClaimTypes.Name, "name"); + ClaimActions.MapJsonKey(ClaimTypes.GivenName, "given_name"); + ClaimActions.MapJsonKey(ClaimTypes.Surname, "family_name"); + ClaimActions.MapJsonKey("urn:google:profile", "link"); + ClaimActions.MapJsonKey(ClaimTypes.Email, "email"); } ///