Преглед изворни кода

Remove the google auth patch quirk #6710 (#6964)

Chris Ross пре 7 година
родитељ
комит
65ee89a71e

+ 1 - 18
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 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";
     }
     }
 }
 }

+ 0 - 50
src/Security/Authentication/Google/src/GoogleHelper.cs

@@ -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
-{
-    /// <summary>
-    /// Contains static methods that allow to extract user's information from a <see cref="JObject"/>
-    /// instance retrieved from Google after a successful authentication process.
-    /// </summary>
-    public static class GoogleHelper
-    {
-        /// <summary>
-        /// Gets the user's email.
-        /// </summary>
-        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;
-        }
-    }
-}

+ 5 - 16
src/Security/Authentication/Google/src/GoogleOptions.cs

@@ -26,22 +26,11 @@ namespace Microsoft.AspNetCore.Authentication.Google
             Scope.Add("email");
             Scope.Add("email");
 
 
             ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
             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");
         }
         }
 
 
         /// <summary>
         /// <summary>