From c046b5d6e108694d64a5b63bea44a61686c62141 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 29 Jan 2019 11:12:08 +0000 Subject: [PATCH 1/7] Copy GooglePlus project into its own Google project --- OwinOAuthProviders.sln | 8 +- .../Constants.cs | 7 + .../GooglePlusAuthenticationExtensions.cs | 29 ++ .../GooglePlusAuthenticationHandler.cs | 256 ++++++++++++++++++ .../GooglePlusAuthenticationMiddleware.cs | 83 ++++++ .../GooglePlusAuthenticationOptions.cs | 116 ++++++++ .../Owin.Security.Providers.Google.csproj | 104 +++++++ .../Properties/AssemblyInfo.cs | 15 + .../GooglePlusAuthenticatedContext.cs | 124 +++++++++ .../GooglePlusAuthenticationProvider.cs | 50 ++++ .../GooglePlusReturnEndpointContext.cs | 26 ++ .../IGooglePlusAuthenticationProvider.cs | 24 ++ .../Resources.Designer.cs | 81 ++++++ .../Resources.resx | 126 +++++++++ .../packages.config | 7 + 15 files changed, 1055 insertions(+), 1 deletion(-) create mode 100644 src/Owin.Security.Providers.Google/Constants.cs create mode 100644 src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs create mode 100644 src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs create mode 100644 src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs create mode 100644 src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs create mode 100644 src/Owin.Security.Providers.Google/Owin.Security.Providers.Google.csproj create mode 100644 src/Owin.Security.Providers.Google/Properties/AssemblyInfo.cs create mode 100644 src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs create mode 100644 src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs create mode 100644 src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs create mode 100644 src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs create mode 100644 src/Owin.Security.Providers.Google/Resources.Designer.cs create mode 100644 src/Owin.Security.Providers.Google/Resources.resx create mode 100644 src/Owin.Security.Providers.Google/packages.config diff --git a/OwinOAuthProviders.sln b/OwinOAuthProviders.sln index 3e28843..2683eb2 100644 --- a/OwinOAuthProviders.sln +++ b/OwinOAuthProviders.sln @@ -1,4 +1,4 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.12 MinimumVisualStudioVersion = 10.0.40219.1 @@ -114,6 +114,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Owin.Security.Providers.Arc EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Owin.Security.Providers.Typeform", "src\Owin.Security.Providers.Typeform\Owin.Security.Providers.Typeform.csproj", "{C8862B45-E1D1-4AB7-A83D-3A2FD2A22526}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Owin.Security.Providers.Google", "src\Owin.Security.Providers.Google\Owin.Security.Providers.Google.csproj", "{ED434959-8CF8-4CAB-83B3-E4A618327AB5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -344,6 +346,10 @@ Global {C8862B45-E1D1-4AB7-A83D-3A2FD2A22526}.Debug|Any CPU.Build.0 = Debug|Any CPU {C8862B45-E1D1-4AB7-A83D-3A2FD2A22526}.Release|Any CPU.ActiveCfg = Release|Any CPU {C8862B45-E1D1-4AB7-A83D-3A2FD2A22526}.Release|Any CPU.Build.0 = Release|Any CPU + {ED434959-8CF8-4CAB-83B3-E4A618327AB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED434959-8CF8-4CAB-83B3-E4A618327AB5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED434959-8CF8-4CAB-83B3-E4A618327AB5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED434959-8CF8-4CAB-83B3-E4A618327AB5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Owin.Security.Providers.Google/Constants.cs b/src/Owin.Security.Providers.Google/Constants.cs new file mode 100644 index 0000000..e8e8499 --- /dev/null +++ b/src/Owin.Security.Providers.Google/Constants.cs @@ -0,0 +1,7 @@ +namespace Owin.Security.Providers.GooglePlus +{ + internal static class Constants + { + public const string DefaultAuthenticationType = "GooglePlus"; + } +} \ No newline at end of file diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs new file mode 100644 index 0000000..4ab09e3 --- /dev/null +++ b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs @@ -0,0 +1,29 @@ +using System; + +namespace Owin.Security.Providers.GooglePlus +{ + public static class GooglePlusAuthenticationExtensions + { + public static IAppBuilder UseGooglePlusAuthentication(this IAppBuilder app, + GooglePlusAuthenticationOptions options) + { + if (app == null) + throw new ArgumentNullException(nameof(app)); + if (options == null) + throw new ArgumentNullException(nameof(options)); + + app.Use(typeof(GooglePlusAuthenticationMiddleware), app, options); + + return app; + } + + public static IAppBuilder UseGooglePlusAuthentication(this IAppBuilder app, string clientId, string clientSecret) + { + return app.UseGooglePlusAuthentication(new GooglePlusAuthenticationOptions + { + ClientId = clientId, + ClientSecret = clientSecret + }); + } + } +} \ No newline at end of file diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs new file mode 100644 index 0000000..94a42d8 --- /dev/null +++ b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs @@ -0,0 +1,256 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.Owin.Infrastructure; +using Microsoft.Owin.Logging; +using Microsoft.Owin.Security; +using Microsoft.Owin.Security.Infrastructure; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Owin.Security.Providers.GooglePlus.Provider; + +namespace Owin.Security.Providers.GooglePlus +{ + public class GooglePlusAuthenticationHandler : AuthenticationHandler + { + private const string XmlSchemaString = "http://www.w3.org/2001/XMLSchema#string"; + private const string TokenEndpoint = "https://accounts.google.com/o/oauth2/token"; + private const string UserInfoEndpoint = "https://www.googleapis.com/oauth2/v3/userinfo"; + private const string GooglePlusUserEndpoint = "https://www.googleapis.com/plus/v1/people/me"; + + private readonly ILogger _logger; + private readonly HttpClient _httpClient; + + public GooglePlusAuthenticationHandler(HttpClient httpClient, ILogger logger) + { + _httpClient = httpClient; + _logger = logger; + } + + protected override async Task AuthenticateCoreAsync() + { + AuthenticationProperties properties = null; + + try + { + string code = null; + string state = null; + + var query = Request.Query; + var values = query.GetValues("code"); + if (values != null && values.Count == 1) + { + code = values[0]; + } + values = query.GetValues("state"); + if (values != null && values.Count == 1) + { + state = values[0]; + } + + properties = Options.StateDataFormat.Unprotect(state); + if (properties == null) + { + return null; + } + + // OAuth2 10.12 CSRF + if (!ValidateCorrelationId(properties, _logger)) + { + return new AuthenticationTicket(null, properties); + } + + var requestPrefix = Request.Scheme + "://" + Request.Host; + var redirectUri = requestPrefix + Request.PathBase + Options.CallbackPath; + + // Build up the body for the token request + var body = new List> + { + new KeyValuePair("grant_type", "authorization_code"), + new KeyValuePair("code", code), + new KeyValuePair("redirect_uri", redirectUri), + new KeyValuePair("client_id", Options.ClientId), + new KeyValuePair("client_secret", Options.ClientSecret) + }; + + // Request the token + var tokenResponse = + await _httpClient.PostAsync(TokenEndpoint, new FormUrlEncodedContent(body)); + tokenResponse.EnsureSuccessStatusCode(); + var text = await tokenResponse.Content.ReadAsStringAsync(); + + // Deserializes the token response + dynamic response = JsonConvert.DeserializeObject(text); + var accessToken = (string)response.access_token; + var expires = (string) response.expires_in; + string refreshToken = null; + if (response.refresh_token != null) + refreshToken = (string) response.refresh_token; + + // Get the Google user + var graphResponse = await _httpClient.GetAsync( + UserInfoEndpoint + "?access_token=" + Uri.EscapeDataString(accessToken), Request.CallCancelled); + graphResponse.EnsureSuccessStatusCode(); + text = await graphResponse.Content.ReadAsStringAsync(); + var user = JObject.Parse(text); + + // Get the Google+ Person Info + graphResponse = await _httpClient.GetAsync( + GooglePlusUserEndpoint + "?access_token=" + Uri.EscapeDataString(accessToken), Request.CallCancelled); + graphResponse.EnsureSuccessStatusCode(); + text = await graphResponse.Content.ReadAsStringAsync(); + var person = JObject.Parse(text); + + var context = new GooglePlusAuthenticatedContext(Context, user, person, accessToken, expires, refreshToken) + { + Identity = new ClaimsIdentity( + Options.AuthenticationType, + ClaimsIdentity.DefaultNameClaimType, + ClaimsIdentity.DefaultRoleClaimType) + }; + if (!string.IsNullOrEmpty(context.Id)) + { + context.Identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, context.Id, XmlSchemaString, Options.AuthenticationType)); + } + if (!string.IsNullOrEmpty(context.UserName)) + { + context.Identity.AddClaim(new Claim(ClaimsIdentity.DefaultNameClaimType, context.UserName, XmlSchemaString, Options.AuthenticationType)); + } + if (!string.IsNullOrEmpty(context.Email)) + { + context.Identity.AddClaim(new Claim(ClaimTypes.Email, context.Email, XmlSchemaString, Options.AuthenticationType)); + } + if (!string.IsNullOrEmpty(context.Name)) + { + context.Identity.AddClaim(new Claim("urn:googleplus:name", context.Name, XmlSchemaString, Options.AuthenticationType)); + } + if (!string.IsNullOrEmpty(context.Link)) + { + context.Identity.AddClaim(new Claim("urn:googleplus:url", context.Link, XmlSchemaString, Options.AuthenticationType)); + } + context.Properties = properties; + + await Options.Provider.Authenticated(context); + + return new AuthenticationTicket(context.Identity, context.Properties); + } + catch (Exception ex) + { + _logger.WriteError(ex.Message); + } + return new AuthenticationTicket(null, properties); + } + + protected override Task ApplyResponseChallengeAsync() + { + if (Response.StatusCode != 401) + { + return Task.FromResult(null); + } + + var challenge = Helper.LookupChallenge(Options.AuthenticationType, Options.AuthenticationMode); + + if (challenge == null) return Task.FromResult(null); + var baseUri = + Request.Scheme + + Uri.SchemeDelimiter + + Request.Host + + Request.PathBase; + + var currentUri = + baseUri + + Request.Path + + Request.QueryString; + + var redirectUri = + baseUri + + Options.CallbackPath; + + var properties = challenge.Properties; + if (string.IsNullOrEmpty(properties.RedirectUri)) + { + properties.RedirectUri = currentUri; + } + + // OAuth2 10.12 CSRF + GenerateCorrelationId(properties); + + // comma separated + var scope = string.Join(" ", Options.Scope); + + var state = Options.StateDataFormat.Protect(properties); + + var authorizationEndpoint = + "https://accounts.google.com/o/oauth2/auth" + + "?response_type=code" + + "&client_id=" + Uri.EscapeDataString(Options.ClientId) + + "&redirect_uri=" + Uri.EscapeDataString(redirectUri) + + "&scope=" + Uri.EscapeDataString(scope) + + "&state=" + Uri.EscapeDataString(state); + + // Check if offline access was requested + if (Options.RequestOfflineAccess) + authorizationEndpoint += "&access_type=offline"; + + // Request the moment types + if (Options.MomentTypes.Count > 0) + authorizationEndpoint += $"&request_visible_actions={string.Join(" ", Options.MomentTypes)}"; + + Response.Redirect(authorizationEndpoint); + + return Task.FromResult(null); + } + + public override async Task InvokeAsync() + { + return await InvokeReplyPathAsync(); + } + + private async Task InvokeReplyPathAsync() + { + if (!Options.CallbackPath.HasValue || Options.CallbackPath != Request.Path) return false; + // TODO: error responses + + var ticket = await AuthenticateAsync(); + if (ticket == null) + { + _logger.WriteWarning("Invalid return state, unable to redirect."); + Response.StatusCode = 500; + return true; + } + + var context = new GooglePlusReturnEndpointContext(Context, ticket) + { + SignInAsAuthenticationType = Options.SignInAsAuthenticationType, + RedirectUri = ticket.Properties.RedirectUri + }; + + await Options.Provider.ReturnEndpoint(context); + + if (context.SignInAsAuthenticationType != null && + context.Identity != null) + { + var grantIdentity = context.Identity; + if (!string.Equals(grantIdentity.AuthenticationType, context.SignInAsAuthenticationType, StringComparison.Ordinal)) + { + grantIdentity = new ClaimsIdentity(grantIdentity.Claims, context.SignInAsAuthenticationType, grantIdentity.NameClaimType, grantIdentity.RoleClaimType); + } + Context.Authentication.SignIn(context.Properties, grantIdentity); + } + + if (context.IsRequestCompleted || context.RedirectUri == null) return context.IsRequestCompleted; + var redirectUri = context.RedirectUri; + if (context.Identity == null) + { + // add a redirect hint that sign-in failed in some way + redirectUri = WebUtilities.AddQueryString(redirectUri, "error", "access_denied"); + } + Response.Redirect(redirectUri); + context.RequestCompleted(); + + return context.IsRequestCompleted; + } + } +} \ No newline at end of file diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs new file mode 100644 index 0000000..d00d41f --- /dev/null +++ b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs @@ -0,0 +1,83 @@ +using System; +using System.Globalization; +using System.Net.Http; +using Microsoft.Owin; +using Microsoft.Owin.Logging; +using Microsoft.Owin.Security; +using Microsoft.Owin.Security.DataHandler; +using Microsoft.Owin.Security.DataProtection; +using Microsoft.Owin.Security.Infrastructure; +using Owin.Security.Providers.GooglePlus.Provider; + +namespace Owin.Security.Providers.GooglePlus +{ + public class GooglePlusAuthenticationMiddleware : AuthenticationMiddleware + { + private readonly HttpClient _httpClient; + private readonly ILogger _logger; + + public GooglePlusAuthenticationMiddleware(OwinMiddleware next, IAppBuilder app, + GooglePlusAuthenticationOptions options) + : base(next, options) + { + if (string.IsNullOrWhiteSpace(Options.ClientId)) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, + Resources.Exception_OptionMustBeProvided, "ClientId")); + if (string.IsNullOrWhiteSpace(Options.ClientSecret)) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, + Resources.Exception_OptionMustBeProvided, "ClientSecret")); + + _logger = app.CreateLogger(); + + if (Options.Provider == null) + Options.Provider = new GooglePlusAuthenticationProvider(); + + if (Options.StateDataFormat == null) + { + var dataProtector = app.CreateDataProtector( + typeof (GooglePlusAuthenticationMiddleware).FullName, + Options.AuthenticationType, "v1"); + Options.StateDataFormat = new PropertiesDataFormat(dataProtector); + } + + if (string.IsNullOrEmpty(Options.SignInAsAuthenticationType)) + Options.SignInAsAuthenticationType = app.GetDefaultSignInAsAuthenticationType(); + + _httpClient = new HttpClient(ResolveHttpMessageHandler(Options)) + { + Timeout = Options.BackchannelTimeout, + MaxResponseContentBufferSize = 1024*1024*10 + }; + } + + /// + /// Provides the object for processing + /// authentication-related requests. + /// + /// + /// An configured with the + /// supplied to the constructor. + /// + protected override AuthenticationHandler CreateHandler() + { + return new GooglePlusAuthenticationHandler(_httpClient, _logger); + } + + private static HttpMessageHandler ResolveHttpMessageHandler(GooglePlusAuthenticationOptions options) + { + var handler = options.BackchannelHttpHandler ?? new WebRequestHandler(); + + // If they provided a validator, apply it or fail. + if (options.BackchannelCertificateValidator == null) return handler; + // Set the cert validate callback + var webRequestHandler = handler as WebRequestHandler; + if (webRequestHandler == null) + { + throw new InvalidOperationException(Resources.Exception_ValidatorHandlerMismatch); + } + webRequestHandler.ServerCertificateValidationCallback = options.BackchannelCertificateValidator.Validate; + + return handler; + } + } +} \ No newline at end of file diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs new file mode 100644 index 0000000..a71da12 --- /dev/null +++ b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using Microsoft.Owin; +using Microsoft.Owin.Security; +using Owin.Security.Providers.GooglePlus.Provider; + +namespace Owin.Security.Providers.GooglePlus +{ + public class GooglePlusAuthenticationOptions : AuthenticationOptions + { + /// + /// Gets or sets the a pinned certificate validator to use to validate the endpoints used + /// in back channel communications belong to Google+. + /// + /// + /// The pinned certificate validator. + /// + /// + /// If this property is null then the default certificate checks are performed, + /// validating the subject name and if the signing chain is a trusted party. + /// + public ICertificateValidator BackchannelCertificateValidator { get; set; } + + /// + /// The HttpMessageHandler used to communicate with Google+. + /// This cannot be set at the same time as BackchannelCertificateValidator unless the value + /// can be downcast to a WebRequestHandler. + /// + public HttpMessageHandler BackchannelHttpHandler { get; set; } + + /// + /// Gets or sets timeout value in milliseconds for back channel communications with Google+. + /// + /// + /// The back channel timeout in milliseconds. + /// + public TimeSpan BackchannelTimeout { get; set; } + + /// + /// The request path within the application's base path where the user-agent will be returned. + /// The middleware will process this request when it arrives. + /// Default value is "/signin-googleplus". + /// + public PathString CallbackPath { get; set; } + + /// + /// Get or sets the text that the user can display on a sign in user interface. + /// + public string Caption + { + get { return Description.Caption; } + set { Description.Caption = value; } + } + + /// + /// Gets or sets the Google supplied Client ID + /// + public string ClientId { get; set; } + + /// + /// Gets or sets the Google supplied Client Secret + /// + public string ClientSecret { get; set; } + + /// + /// The list of moment types which you application wants to write. During authentication this will be passed through via the request_visible_actions parameter. + /// For more information of the moment types you may request, see https://developers.google.com/+/api/moment-types/ + /// + public IList MomentTypes { get; private set; } + + /// + /// Gets or sets the used in the authentication events + /// + public IGooglePlusAuthenticationProvider Provider { get; set; } + + /// + /// Gets or sets whether to request offline access. If offline access is requested the will contain a Refresh Token. + /// + public bool RequestOfflineAccess { get; set; } + + /// + /// A list of permissions to request. + /// + public IList Scope { get; private set; } + + /// + /// Gets or sets the name of another authentication middleware which will be responsible for actually issuing a user + /// . + /// + public string SignInAsAuthenticationType { get; set; } + + /// + /// Gets or sets the type used to secure data handled by the middleware. + /// + public ISecureDataFormat StateDataFormat { get; set; } + + /// + /// Initializes a new + /// + public GooglePlusAuthenticationOptions() + : base("GooglePlus") + { + Caption = Constants.DefaultAuthenticationType; + CallbackPath = new PathString("/signin-googleplus"); + AuthenticationMode = AuthenticationMode.Passive; + MomentTypes = new List(); + Scope = new List + { + "https://www.googleapis.com/auth/plus.login", + "https://www.googleapis.com/auth/plus.profile.emails.read" + }; + BackchannelTimeout = TimeSpan.FromSeconds(60); + } + } +} \ No newline at end of file diff --git a/src/Owin.Security.Providers.Google/Owin.Security.Providers.Google.csproj b/src/Owin.Security.Providers.Google/Owin.Security.Providers.Google.csproj new file mode 100644 index 0000000..d40710d --- /dev/null +++ b/src/Owin.Security.Providers.Google/Owin.Security.Providers.Google.csproj @@ -0,0 +1,104 @@ + + + + + Debug + AnyCPU + {ED434959-8CF8-4CAB-83B3-E4A618327AB5} + Library + Properties + Owin.Security.Providers.Google + Owin.Security.Providers.Google + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + 6 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + 6 + + + + ..\..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll + True + + + ..\..\packages\Microsoft.Owin.Security.3.0.1\lib\net45\Microsoft.Owin.Security.dll + True + + + ..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + True + + + ..\..\packages\Owin.1.0\lib\net40\Owin.dll + True + + + + + + + + + + + + + + + + + + + + + + + + Resources.resx + True + True + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + + + + + + + + + + + + + + $(PostBuildEventDependsOn); + PostBuildMacros; + + + diff --git a/src/Owin.Security.Providers.Google/Properties/AssemblyInfo.cs b/src/Owin.Security.Providers.Google/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7dc7a8f --- /dev/null +++ b/src/Owin.Security.Providers.Google/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Owin.Security.Providers.Google")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Owin.Security.Providers.Google")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("ed434959-8cf8-4cab-83b3-e4a618327ab5")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] diff --git a/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs b/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs new file mode 100644 index 0000000..c1f09b0 --- /dev/null +++ b/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs @@ -0,0 +1,124 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. + +using System; +using System.Globalization; +using System.Linq; +using System.Security.Claims; +using Microsoft.Owin; +using Microsoft.Owin.Security; +using Microsoft.Owin.Security.Provider; +using Newtonsoft.Json.Linq; + +namespace Owin.Security.Providers.GooglePlus.Provider +{ + /// + /// Contains information about the login session as well as the user . + /// + public class GooglePlusAuthenticatedContext : BaseContext + { + /// + /// Initializes a + /// + /// The OWIN environment + /// The JSON-serialized user + /// + /// Google+ Access token + /// Seconds until expiration + /// + public GooglePlusAuthenticatedContext(IOwinContext context, JObject user, JObject person, string accessToken, string expires, string refreshToken) + : base(context) + { + User = user; + Person = person; + AccessToken = accessToken; + RefreshToken = refreshToken; + + int expiresValue; + if (int.TryParse(expires, NumberStyles.Integer, CultureInfo.InvariantCulture, out expiresValue)) + { + ExpiresIn = TimeSpan.FromSeconds(expiresValue); + } + + Id = TryGetValue(person, "id"); + Name = TryGetValue(person, "displayName"); + Link = TryGetValue(person, "url"); + UserName = TryGetValue(person, "displayName").Replace(" ", ""); + + var email = (from e in person["emails"] + where e["type"].ToString() == "account" + select e).FirstOrDefault(); + if (email != null) + Email = email["value"].ToString(); + } + + /// + /// Gets the JSON-serialized user + /// + /// + /// Contains the Google user obtained from the endpoint https://www.googleapis.com/oauth2/v3/userinfo + /// + public JObject User { get; private set; } + + /// + /// Gets the JSON-serialized person + /// + /// + /// Contains the Google+ person obtained from the endpoint https://www.googleapis.com/plus/v1/people/me. For more information + /// see https://developers.google.com/+/api/latest/people + /// + public JObject Person { get; private set; } + + /// + /// Gets the Google OAuth access token + /// + public string AccessToken { get; private set; } + + /// + /// Gets the Google OAuth refresh token. This is only available when the RequestOfflineAccess property of is set to true + /// + public string RefreshToken { get; private set; } + + /// + /// Gets the Google+ access token expiration time + /// + public TimeSpan? ExpiresIn { get; set; } + + /// + /// Gets the Google+ user ID + /// + public string Id { get; private set; } + + /// + /// Gets the user's name + /// + public string Name { get; private set; } + + public string Link { get; private set; } + + /// + /// Gets the Google+ username + /// + public string UserName { get; private set; } + + /// + /// Gets the Google+ email address for the account + /// + public string Email { get; private set; } + + /// + /// Gets the representing the user + /// + public ClaimsIdentity Identity { get; set; } + + /// + /// Gets or sets a property bag for common authentication properties + /// + public AuthenticationProperties Properties { get; set; } + + private static string TryGetValue(JObject user, string propertyName) + { + JToken value; + return user.TryGetValue(propertyName, out value) ? value.ToString() : null; + } + } +} diff --git a/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs b/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs new file mode 100644 index 0000000..f59ed04 --- /dev/null +++ b/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs @@ -0,0 +1,50 @@ +using System; +using System.Threading.Tasks; + +namespace Owin.Security.Providers.GooglePlus.Provider +{ + /// + /// Default implementation. + /// + public class GooglePlusAuthenticationProvider : IGooglePlusAuthenticationProvider + { + /// + /// Initializes a + /// + public GooglePlusAuthenticationProvider() + { + OnAuthenticated = context => Task.FromResult(null); + OnReturnEndpoint = context => Task.FromResult(null); + } + + /// + /// Gets or sets the function that is invoked when the Authenticated method is invoked. + /// + public Func OnAuthenticated { get; set; } + + /// + /// Gets or sets the function that is invoked when the ReturnEndpoint method is invoked. + /// + public Func OnReturnEndpoint { get; set; } + + /// + /// Invoked whenever Google+ successfully authenticates a user + /// + /// Contains information about the login session as well as the user . + /// A representing the completed operation. + public virtual Task Authenticated(GooglePlusAuthenticatedContext context) + { + return OnAuthenticated(context); + } + + /// + /// Invoked prior to the being saved in a local cookie and the browser being redirected to the originally requested URL. + /// + /// + /// A representing the completed operation. + public virtual Task ReturnEndpoint(GooglePlusReturnEndpointContext context) + { + return OnReturnEndpoint(context); + } + } +} \ No newline at end of file diff --git a/src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs b/src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs new file mode 100644 index 0000000..2fbfb28 --- /dev/null +++ b/src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. + +using Microsoft.Owin; +using Microsoft.Owin.Security; +using Microsoft.Owin.Security.Provider; + +namespace Owin.Security.Providers.GooglePlus.Provider +{ + /// + /// Provides context information to middleware providers. + /// + public class GooglePlusReturnEndpointContext : ReturnEndpointContext + { + /// + /// + /// + /// OWIN environment + /// The authentication ticket + public GooglePlusReturnEndpointContext( + IOwinContext context, + AuthenticationTicket ticket) + : base(context, ticket) + { + } + } +} diff --git a/src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs b/src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs new file mode 100644 index 0000000..fead223 --- /dev/null +++ b/src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs @@ -0,0 +1,24 @@ +using System.Threading.Tasks; + +namespace Owin.Security.Providers.GooglePlus.Provider +{ + /// + /// Specifies callback methods which the invokes to enable developer control over the authentication process. /> + /// + public interface IGooglePlusAuthenticationProvider + { + /// + /// Invoked whenever Google+ successfully authenticates a user + /// + /// Contains information about the login session as well as the user . + /// A representing the completed operation. + Task Authenticated(GooglePlusAuthenticatedContext context); + + /// + /// Invoked prior to the being saved in a local cookie and the browser being redirected to the originally requested URL. + /// + /// + /// A representing the completed operation. + Task ReturnEndpoint(GooglePlusReturnEndpointContext context); + } +} \ No newline at end of file diff --git a/src/Owin.Security.Providers.Google/Resources.Designer.cs b/src/Owin.Security.Providers.Google/Resources.Designer.cs new file mode 100644 index 0000000..38f1040 --- /dev/null +++ b/src/Owin.Security.Providers.Google/Resources.Designer.cs @@ -0,0 +1,81 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Owin.Security.Providers.GooglePlus { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + var temp = new global::System.Resources.ResourceManager("Owin.Security.Providers.GooglePlus.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to The '{0}' option must be provided.. + /// + internal static string Exception_OptionMustBeProvided { + get { + return ResourceManager.GetString("Exception_OptionMustBeProvided", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler.. + /// + internal static string Exception_ValidatorHandlerMismatch { + get { + return ResourceManager.GetString("Exception_ValidatorHandlerMismatch", resourceCulture); + } + } + } +} diff --git a/src/Owin.Security.Providers.Google/Resources.resx b/src/Owin.Security.Providers.Google/Resources.resx new file mode 100644 index 0000000..2a19bea --- /dev/null +++ b/src/Owin.Security.Providers.Google/Resources.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + The '{0}' option must be provided. + + + An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. + + \ No newline at end of file diff --git a/src/Owin.Security.Providers.Google/packages.config b/src/Owin.Security.Providers.Google/packages.config new file mode 100644 index 0000000..cbfe6a2 --- /dev/null +++ b/src/Owin.Security.Providers.Google/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file From 334ba8664fb2e52a57ca435248c06dfa6b072b33 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 29 Jan 2019 11:16:19 +0000 Subject: [PATCH 2/7] Fix up namespaces from GooglePlus to Google --- src/Owin.Security.Providers.Google/Constants.cs | 2 +- .../GooglePlusAuthenticationExtensions.cs | 2 +- .../GooglePlusAuthenticationHandler.cs | 4 ++-- .../GooglePlusAuthenticationMiddleware.cs | 4 ++-- .../GooglePlusAuthenticationOptions.cs | 4 ++-- .../Provider/GooglePlusAuthenticatedContext.cs | 2 +- .../Provider/GooglePlusAuthenticationProvider.cs | 2 +- .../Provider/GooglePlusReturnEndpointContext.cs | 2 +- .../Provider/IGooglePlusAuthenticationProvider.cs | 2 +- src/Owin.Security.Providers.Google/Resources.Designer.cs | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Owin.Security.Providers.Google/Constants.cs b/src/Owin.Security.Providers.Google/Constants.cs index e8e8499..527cdbf 100644 --- a/src/Owin.Security.Providers.Google/Constants.cs +++ b/src/Owin.Security.Providers.Google/Constants.cs @@ -1,4 +1,4 @@ -namespace Owin.Security.Providers.GooglePlus +namespace Owin.Security.Providers.Google { internal static class Constants { diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs index 4ab09e3..c1baa8b 100644 --- a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs +++ b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs @@ -1,6 +1,6 @@ using System; -namespace Owin.Security.Providers.GooglePlus +namespace Owin.Security.Providers.Google { public static class GooglePlusAuthenticationExtensions { diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs index 94a42d8..9cee389 100644 --- a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs +++ b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs @@ -9,9 +9,9 @@ using Microsoft.Owin.Security; using Microsoft.Owin.Security.Infrastructure; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using Owin.Security.Providers.GooglePlus.Provider; +using Owin.Security.Providers.Google.Provider; -namespace Owin.Security.Providers.GooglePlus +namespace Owin.Security.Providers.Google { public class GooglePlusAuthenticationHandler : AuthenticationHandler { diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs index d00d41f..53ae671 100644 --- a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs +++ b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs @@ -7,9 +7,9 @@ using Microsoft.Owin.Security; using Microsoft.Owin.Security.DataHandler; using Microsoft.Owin.Security.DataProtection; using Microsoft.Owin.Security.Infrastructure; -using Owin.Security.Providers.GooglePlus.Provider; +using Owin.Security.Providers.Google.Provider; -namespace Owin.Security.Providers.GooglePlus +namespace Owin.Security.Providers.Google { public class GooglePlusAuthenticationMiddleware : AuthenticationMiddleware { diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs index a71da12..8effe82 100644 --- a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs +++ b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Net.Http; using Microsoft.Owin; using Microsoft.Owin.Security; -using Owin.Security.Providers.GooglePlus.Provider; +using Owin.Security.Providers.Google.Provider; -namespace Owin.Security.Providers.GooglePlus +namespace Owin.Security.Providers.Google { public class GooglePlusAuthenticationOptions : AuthenticationOptions { diff --git a/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs b/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs index c1f09b0..7c42434 100644 --- a/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs +++ b/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs @@ -9,7 +9,7 @@ using Microsoft.Owin.Security; using Microsoft.Owin.Security.Provider; using Newtonsoft.Json.Linq; -namespace Owin.Security.Providers.GooglePlus.Provider +namespace Owin.Security.Providers.Google.Provider { /// /// Contains information about the login session as well as the user . diff --git a/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs b/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs index f59ed04..07f4869 100644 --- a/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs +++ b/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs @@ -1,7 +1,7 @@ using System; using System.Threading.Tasks; -namespace Owin.Security.Providers.GooglePlus.Provider +namespace Owin.Security.Providers.Google.Provider { /// /// Default implementation. diff --git a/src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs b/src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs index 2fbfb28..cc41ee6 100644 --- a/src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs +++ b/src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs @@ -4,7 +4,7 @@ using Microsoft.Owin; using Microsoft.Owin.Security; using Microsoft.Owin.Security.Provider; -namespace Owin.Security.Providers.GooglePlus.Provider +namespace Owin.Security.Providers.Google.Provider { /// /// Provides context information to middleware providers. diff --git a/src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs b/src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs index fead223..8a463e0 100644 --- a/src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs +++ b/src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace Owin.Security.Providers.GooglePlus.Provider +namespace Owin.Security.Providers.Google.Provider { /// /// Specifies callback methods which the invokes to enable developer control over the authentication process. /> diff --git a/src/Owin.Security.Providers.Google/Resources.Designer.cs b/src/Owin.Security.Providers.Google/Resources.Designer.cs index 38f1040..8b2956b 100644 --- a/src/Owin.Security.Providers.Google/Resources.Designer.cs +++ b/src/Owin.Security.Providers.Google/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Owin.Security.Providers.GooglePlus { +namespace Owin.Security.Providers.Google { using System; From 0c529e18feb06db19d653a89a99582f341c3c20f Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 29 Jan 2019 11:26:51 +0000 Subject: [PATCH 3/7] Rename GooglePlus to Google --- .../GoogleAuthenticationExtensions.cs | 29 +++++++++++++++++++ ...dler.cs => GoogleAuthenticationHandler.cs} | 8 ++--- ...e.cs => GoogleAuthenticationMiddleware.cs} | 18 ++++++------ ...ions.cs => GoogleAuthenticationOptions.cs} | 12 ++++---- .../GooglePlusAuthenticationExtensions.cs | 29 ------------------- .../Owin.Security.Providers.Google.csproj | 16 +++++----- ...ntext.cs => GoogleAuthenticatedContext.cs} | 8 ++--- ...der.cs => GoogleAuthenticationProvider.cs} | 16 +++++----- ...text.cs => GoogleReturnEndpointContext.cs} | 4 +-- ...er.cs => IGoogleAuthenticationProvider.cs} | 8 ++--- 10 files changed, 74 insertions(+), 74 deletions(-) create mode 100644 src/Owin.Security.Providers.Google/GoogleAuthenticationExtensions.cs rename src/Owin.Security.Providers.Google/{GooglePlusAuthenticationHandler.cs => GoogleAuthenticationHandler.cs} (96%) rename src/Owin.Security.Providers.Google/{GooglePlusAuthenticationMiddleware.cs => GoogleAuthenticationMiddleware.cs} (80%) rename src/Owin.Security.Providers.Google/{GooglePlusAuthenticationOptions.cs => GoogleAuthenticationOptions.cs} (89%) delete mode 100644 src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs rename src/Owin.Security.Providers.Google/Provider/{GooglePlusAuthenticatedContext.cs => GoogleAuthenticatedContext.cs} (92%) rename src/Owin.Security.Providers.Google/Provider/{GooglePlusAuthenticationProvider.cs => GoogleAuthenticationProvider.cs} (70%) rename src/Owin.Security.Providers.Google/Provider/{GooglePlusReturnEndpointContext.cs => GoogleReturnEndpointContext.cs} (85%) rename src/Owin.Security.Providers.Google/Provider/{IGooglePlusAuthenticationProvider.cs => IGoogleAuthenticationProvider.cs} (70%) diff --git a/src/Owin.Security.Providers.Google/GoogleAuthenticationExtensions.cs b/src/Owin.Security.Providers.Google/GoogleAuthenticationExtensions.cs new file mode 100644 index 0000000..4925c71 --- /dev/null +++ b/src/Owin.Security.Providers.Google/GoogleAuthenticationExtensions.cs @@ -0,0 +1,29 @@ +using System; + +namespace Owin.Security.Providers.Google +{ + public static class GoogleAuthenticationExtensions + { + public static IAppBuilder UseGoogleAuthentication(this IAppBuilder app, + GoogleAuthenticationOptions options) + { + if (app == null) + throw new ArgumentNullException(nameof(app)); + if (options == null) + throw new ArgumentNullException(nameof(options)); + + app.Use(typeof(GoogleAuthenticationMiddleware), app, options); + + return app; + } + + public static IAppBuilder UseGoogleAuthentication(this IAppBuilder app, string clientId, string clientSecret) + { + return app.UseGoogleAuthentication(new GoogleAuthenticationOptions + { + ClientId = clientId, + ClientSecret = clientSecret + }); + } + } +} \ No newline at end of file diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs b/src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs similarity index 96% rename from src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs rename to src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs index 9cee389..5ad96c8 100644 --- a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationHandler.cs +++ b/src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs @@ -13,7 +13,7 @@ using Owin.Security.Providers.Google.Provider; namespace Owin.Security.Providers.Google { - public class GooglePlusAuthenticationHandler : AuthenticationHandler + public class GoogleAuthenticationHandler : AuthenticationHandler { private const string XmlSchemaString = "http://www.w3.org/2001/XMLSchema#string"; private const string TokenEndpoint = "https://accounts.google.com/o/oauth2/token"; @@ -23,7 +23,7 @@ namespace Owin.Security.Providers.Google private readonly ILogger _logger; private readonly HttpClient _httpClient; - public GooglePlusAuthenticationHandler(HttpClient httpClient, ILogger logger) + public GoogleAuthenticationHandler(HttpClient httpClient, ILogger logger) { _httpClient = httpClient; _logger = logger; @@ -103,7 +103,7 @@ namespace Owin.Security.Providers.Google text = await graphResponse.Content.ReadAsStringAsync(); var person = JObject.Parse(text); - var context = new GooglePlusAuthenticatedContext(Context, user, person, accessToken, expires, refreshToken) + var context = new GoogleAuthenticatedContext(Context, user, person, accessToken, expires, refreshToken) { Identity = new ClaimsIdentity( Options.AuthenticationType, @@ -221,7 +221,7 @@ namespace Owin.Security.Providers.Google return true; } - var context = new GooglePlusReturnEndpointContext(Context, ticket) + var context = new GoogleReturnEndpointContext(Context, ticket) { SignInAsAuthenticationType = Options.SignInAsAuthenticationType, RedirectUri = ticket.Properties.RedirectUri diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs b/src/Owin.Security.Providers.Google/GoogleAuthenticationMiddleware.cs similarity index 80% rename from src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs rename to src/Owin.Security.Providers.Google/GoogleAuthenticationMiddleware.cs index 53ae671..3683ba6 100644 --- a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationMiddleware.cs +++ b/src/Owin.Security.Providers.Google/GoogleAuthenticationMiddleware.cs @@ -11,13 +11,13 @@ using Owin.Security.Providers.Google.Provider; namespace Owin.Security.Providers.Google { - public class GooglePlusAuthenticationMiddleware : AuthenticationMiddleware + public class GoogleAuthenticationMiddleware : AuthenticationMiddleware { private readonly HttpClient _httpClient; private readonly ILogger _logger; - public GooglePlusAuthenticationMiddleware(OwinMiddleware next, IAppBuilder app, - GooglePlusAuthenticationOptions options) + public GoogleAuthenticationMiddleware(OwinMiddleware next, IAppBuilder app, + GoogleAuthenticationOptions options) : base(next, options) { if (string.IsNullOrWhiteSpace(Options.ClientId)) @@ -27,15 +27,15 @@ namespace Owin.Security.Providers.Google throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, "ClientSecret")); - _logger = app.CreateLogger(); + _logger = app.CreateLogger(); if (Options.Provider == null) - Options.Provider = new GooglePlusAuthenticationProvider(); + Options.Provider = new GoogleAuthenticationProvider(); if (Options.StateDataFormat == null) { var dataProtector = app.CreateDataProtector( - typeof (GooglePlusAuthenticationMiddleware).FullName, + typeof (GoogleAuthenticationMiddleware).FullName, Options.AuthenticationType, "v1"); Options.StateDataFormat = new PropertiesDataFormat(dataProtector); } @@ -58,12 +58,12 @@ namespace Owin.Security.Providers.Google /// An configured with the /// supplied to the constructor. /// - protected override AuthenticationHandler CreateHandler() + protected override AuthenticationHandler CreateHandler() { - return new GooglePlusAuthenticationHandler(_httpClient, _logger); + return new GoogleAuthenticationHandler(_httpClient, _logger); } - private static HttpMessageHandler ResolveHttpMessageHandler(GooglePlusAuthenticationOptions options) + private static HttpMessageHandler ResolveHttpMessageHandler(GoogleAuthenticationOptions options) { var handler = options.BackchannelHttpHandler ?? new WebRequestHandler(); diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs b/src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs similarity index 89% rename from src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs rename to src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs index 8effe82..0271228 100644 --- a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationOptions.cs +++ b/src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs @@ -7,7 +7,7 @@ using Owin.Security.Providers.Google.Provider; namespace Owin.Security.Providers.Google { - public class GooglePlusAuthenticationOptions : AuthenticationOptions + public class GoogleAuthenticationOptions : AuthenticationOptions { /// /// Gets or sets the a pinned certificate validator to use to validate the endpoints used @@ -70,12 +70,12 @@ namespace Owin.Security.Providers.Google public IList MomentTypes { get; private set; } /// - /// Gets or sets the used in the authentication events + /// Gets or sets the used in the authentication events /// - public IGooglePlusAuthenticationProvider Provider { get; set; } + public IGoogleAuthenticationProvider Provider { get; set; } /// - /// Gets or sets whether to request offline access. If offline access is requested the will contain a Refresh Token. + /// Gets or sets whether to request offline access. If offline access is requested the will contain a Refresh Token. /// public bool RequestOfflineAccess { get; set; } @@ -96,9 +96,9 @@ namespace Owin.Security.Providers.Google public ISecureDataFormat StateDataFormat { get; set; } /// - /// Initializes a new + /// Initializes a new /// - public GooglePlusAuthenticationOptions() + public GoogleAuthenticationOptions() : base("GooglePlus") { Caption = Constants.DefaultAuthenticationType; diff --git a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs b/src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs deleted file mode 100644 index c1baa8b..0000000 --- a/src/Owin.Security.Providers.Google/GooglePlusAuthenticationExtensions.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; - -namespace Owin.Security.Providers.Google -{ - public static class GooglePlusAuthenticationExtensions - { - public static IAppBuilder UseGooglePlusAuthentication(this IAppBuilder app, - GooglePlusAuthenticationOptions options) - { - if (app == null) - throw new ArgumentNullException(nameof(app)); - if (options == null) - throw new ArgumentNullException(nameof(options)); - - app.Use(typeof(GooglePlusAuthenticationMiddleware), app, options); - - return app; - } - - public static IAppBuilder UseGooglePlusAuthentication(this IAppBuilder app, string clientId, string clientSecret) - { - return app.UseGooglePlusAuthentication(new GooglePlusAuthenticationOptions - { - ClientId = clientId, - ClientSecret = clientSecret - }); - } - } -} \ No newline at end of file diff --git a/src/Owin.Security.Providers.Google/Owin.Security.Providers.Google.csproj b/src/Owin.Security.Providers.Google/Owin.Security.Providers.Google.csproj index d40710d..a2f5aa2 100644 --- a/src/Owin.Security.Providers.Google/Owin.Security.Providers.Google.csproj +++ b/src/Owin.Security.Providers.Google/Owin.Security.Providers.Google.csproj @@ -61,14 +61,14 @@ - - - - - - - - + + + + + + + + Resources.resx True diff --git a/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs b/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticatedContext.cs similarity index 92% rename from src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs rename to src/Owin.Security.Providers.Google/Provider/GoogleAuthenticatedContext.cs index 7c42434..d5194ce 100644 --- a/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticatedContext.cs +++ b/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticatedContext.cs @@ -14,10 +14,10 @@ namespace Owin.Security.Providers.Google.Provider /// /// Contains information about the login session as well as the user . /// - public class GooglePlusAuthenticatedContext : BaseContext + public class GoogleAuthenticatedContext : BaseContext { /// - /// Initializes a + /// Initializes a /// /// The OWIN environment /// The JSON-serialized user @@ -25,7 +25,7 @@ namespace Owin.Security.Providers.Google.Provider /// Google+ Access token /// Seconds until expiration /// - public GooglePlusAuthenticatedContext(IOwinContext context, JObject user, JObject person, string accessToken, string expires, string refreshToken) + public GoogleAuthenticatedContext(IOwinContext context, JObject user, JObject person, string accessToken, string expires, string refreshToken) : base(context) { User = user; @@ -74,7 +74,7 @@ namespace Owin.Security.Providers.Google.Provider public string AccessToken { get; private set; } /// - /// Gets the Google OAuth refresh token. This is only available when the RequestOfflineAccess property of is set to true + /// Gets the Google OAuth refresh token. This is only available when the RequestOfflineAccess property of is set to true /// public string RefreshToken { get; private set; } diff --git a/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs b/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticationProvider.cs similarity index 70% rename from src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs rename to src/Owin.Security.Providers.Google/Provider/GoogleAuthenticationProvider.cs index 07f4869..e66beb5 100644 --- a/src/Owin.Security.Providers.Google/Provider/GooglePlusAuthenticationProvider.cs +++ b/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticationProvider.cs @@ -4,14 +4,14 @@ using System.Threading.Tasks; namespace Owin.Security.Providers.Google.Provider { /// - /// Default implementation. + /// Default implementation. /// - public class GooglePlusAuthenticationProvider : IGooglePlusAuthenticationProvider + public class GoogleAuthenticationProvider : IGoogleAuthenticationProvider { /// - /// Initializes a + /// Initializes a /// - public GooglePlusAuthenticationProvider() + public GoogleAuthenticationProvider() { OnAuthenticated = context => Task.FromResult(null); OnReturnEndpoint = context => Task.FromResult(null); @@ -20,19 +20,19 @@ namespace Owin.Security.Providers.Google.Provider /// /// Gets or sets the function that is invoked when the Authenticated method is invoked. /// - public Func OnAuthenticated { get; set; } + public Func OnAuthenticated { get; set; } /// /// Gets or sets the function that is invoked when the ReturnEndpoint method is invoked. /// - public Func OnReturnEndpoint { get; set; } + public Func OnReturnEndpoint { get; set; } /// /// Invoked whenever Google+ successfully authenticates a user /// /// Contains information about the login session as well as the user . /// A representing the completed operation. - public virtual Task Authenticated(GooglePlusAuthenticatedContext context) + public virtual Task Authenticated(GoogleAuthenticatedContext context) { return OnAuthenticated(context); } @@ -42,7 +42,7 @@ namespace Owin.Security.Providers.Google.Provider /// /// /// A representing the completed operation. - public virtual Task ReturnEndpoint(GooglePlusReturnEndpointContext context) + public virtual Task ReturnEndpoint(GoogleReturnEndpointContext context) { return OnReturnEndpoint(context); } diff --git a/src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs b/src/Owin.Security.Providers.Google/Provider/GoogleReturnEndpointContext.cs similarity index 85% rename from src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs rename to src/Owin.Security.Providers.Google/Provider/GoogleReturnEndpointContext.cs index cc41ee6..7800f55 100644 --- a/src/Owin.Security.Providers.Google/Provider/GooglePlusReturnEndpointContext.cs +++ b/src/Owin.Security.Providers.Google/Provider/GoogleReturnEndpointContext.cs @@ -9,14 +9,14 @@ namespace Owin.Security.Providers.Google.Provider /// /// Provides context information to middleware providers. /// - public class GooglePlusReturnEndpointContext : ReturnEndpointContext + public class GoogleReturnEndpointContext : ReturnEndpointContext { /// /// /// /// OWIN environment /// The authentication ticket - public GooglePlusReturnEndpointContext( + public GoogleReturnEndpointContext( IOwinContext context, AuthenticationTicket ticket) : base(context, ticket) diff --git a/src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs b/src/Owin.Security.Providers.Google/Provider/IGoogleAuthenticationProvider.cs similarity index 70% rename from src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs rename to src/Owin.Security.Providers.Google/Provider/IGoogleAuthenticationProvider.cs index 8a463e0..5ef53b2 100644 --- a/src/Owin.Security.Providers.Google/Provider/IGooglePlusAuthenticationProvider.cs +++ b/src/Owin.Security.Providers.Google/Provider/IGoogleAuthenticationProvider.cs @@ -3,22 +3,22 @@ namespace Owin.Security.Providers.Google.Provider { /// - /// Specifies callback methods which the invokes to enable developer control over the authentication process. /> + /// Specifies callback methods which the invokes to enable developer control over the authentication process. /> /// - public interface IGooglePlusAuthenticationProvider + public interface IGoogleAuthenticationProvider { /// /// Invoked whenever Google+ successfully authenticates a user /// /// Contains information about the login session as well as the user . /// A representing the completed operation. - Task Authenticated(GooglePlusAuthenticatedContext context); + Task Authenticated(GoogleAuthenticatedContext context); /// /// Invoked prior to the being saved in a local cookie and the browser being redirected to the originally requested URL. /// /// /// A representing the completed operation. - Task ReturnEndpoint(GooglePlusReturnEndpointContext context); + Task ReturnEndpoint(GoogleReturnEndpointContext context); } } \ No newline at end of file From 1301c6c0d235a018b3776fb62d834d641d764a04 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 29 Jan 2019 11:43:50 +0000 Subject: [PATCH 4/7] Update GoogleAuthenticationOptions for Google Signin --- .../GoogleAuthenticationHandler.cs | 4 ---- .../GoogleAuthenticationOptions.cs | 23 +++++++------------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs b/src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs index 5ad96c8..70e95c0 100644 --- a/src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs +++ b/src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs @@ -194,10 +194,6 @@ namespace Owin.Security.Providers.Google if (Options.RequestOfflineAccess) authorizationEndpoint += "&access_type=offline"; - // Request the moment types - if (Options.MomentTypes.Count > 0) - authorizationEndpoint += $"&request_visible_actions={string.Join(" ", Options.MomentTypes)}"; - Response.Redirect(authorizationEndpoint); return Task.FromResult(null); diff --git a/src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs b/src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs index 0271228..f4bd555 100644 --- a/src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs +++ b/src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs @@ -11,7 +11,7 @@ namespace Owin.Security.Providers.Google { /// /// Gets or sets the a pinned certificate validator to use to validate the endpoints used - /// in back channel communications belong to Google+. + /// in back channel communications belonging to Google. /// /// /// The pinned certificate validator. @@ -23,14 +23,14 @@ namespace Owin.Security.Providers.Google public ICertificateValidator BackchannelCertificateValidator { get; set; } /// - /// The HttpMessageHandler used to communicate with Google+. + /// The HttpMessageHandler used to communicate with Google. /// This cannot be set at the same time as BackchannelCertificateValidator unless the value /// can be downcast to a WebRequestHandler. /// public HttpMessageHandler BackchannelHttpHandler { get; set; } /// - /// Gets or sets timeout value in milliseconds for back channel communications with Google+. + /// Gets or sets timeout value in milliseconds for back channel communications with Google. /// /// /// The back channel timeout in milliseconds. @@ -40,7 +40,7 @@ namespace Owin.Security.Providers.Google /// /// The request path within the application's base path where the user-agent will be returned. /// The middleware will process this request when it arrives. - /// Default value is "/signin-googleplus". + /// Default value is "/signin-google". /// public PathString CallbackPath { get; set; } @@ -63,12 +63,6 @@ namespace Owin.Security.Providers.Google /// public string ClientSecret { get; set; } - /// - /// The list of moment types which you application wants to write. During authentication this will be passed through via the request_visible_actions parameter. - /// For more information of the moment types you may request, see https://developers.google.com/+/api/moment-types/ - /// - public IList MomentTypes { get; private set; } - /// /// Gets or sets the used in the authentication events /// @@ -99,16 +93,15 @@ namespace Owin.Security.Providers.Google /// Initializes a new /// public GoogleAuthenticationOptions() - : base("GooglePlus") + : base("Google") { Caption = Constants.DefaultAuthenticationType; - CallbackPath = new PathString("/signin-googleplus"); + CallbackPath = new PathString("/signin-google"); AuthenticationMode = AuthenticationMode.Passive; - MomentTypes = new List(); Scope = new List { - "https://www.googleapis.com/auth/plus.login", - "https://www.googleapis.com/auth/plus.profile.emails.read" + "profile", + "email" }; BackchannelTimeout = TimeSpan.FromSeconds(60); } From 4edd2ae28a1170b1f92fa4fa529cba545d1b7e82 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 29 Jan 2019 14:26:53 +0000 Subject: [PATCH 5/7] Fix up API usage changes for Google --- .../GoogleAuthenticationHandler.cs | 18 +++----- .../GoogleAuthenticationOptions.cs | 1 + .../Provider/GoogleAuthenticatedContext.cs | 45 +++++++------------ 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs b/src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs index 70e95c0..76f555b 100644 --- a/src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs +++ b/src/Owin.Security.Providers.Google/GoogleAuthenticationHandler.cs @@ -17,8 +17,9 @@ namespace Owin.Security.Providers.Google { private const string XmlSchemaString = "http://www.w3.org/2001/XMLSchema#string"; private const string TokenEndpoint = "https://accounts.google.com/o/oauth2/token"; + // TODO: This url should come from here: https://accounts.google.com/.well-known/openid-configuration + // TODO: as described by https://developers.google.com/identity/protocols/OpenIDConnect#discovery private const string UserInfoEndpoint = "https://www.googleapis.com/oauth2/v3/userinfo"; - private const string GooglePlusUserEndpoint = "https://www.googleapis.com/plus/v1/people/me"; private readonly ILogger _logger; private readonly HttpClient _httpClient; @@ -94,16 +95,9 @@ namespace Owin.Security.Providers.Google UserInfoEndpoint + "?access_token=" + Uri.EscapeDataString(accessToken), Request.CallCancelled); graphResponse.EnsureSuccessStatusCode(); text = await graphResponse.Content.ReadAsStringAsync(); - var user = JObject.Parse(text); + var userInfo = JObject.Parse(text); - // Get the Google+ Person Info - graphResponse = await _httpClient.GetAsync( - GooglePlusUserEndpoint + "?access_token=" + Uri.EscapeDataString(accessToken), Request.CallCancelled); - graphResponse.EnsureSuccessStatusCode(); - text = await graphResponse.Content.ReadAsStringAsync(); - var person = JObject.Parse(text); - - var context = new GoogleAuthenticatedContext(Context, user, person, accessToken, expires, refreshToken) + var context = new GoogleAuthenticatedContext(Context, userInfo, accessToken, expires, refreshToken) { Identity = new ClaimsIdentity( Options.AuthenticationType, @@ -124,11 +118,11 @@ namespace Owin.Security.Providers.Google } if (!string.IsNullOrEmpty(context.Name)) { - context.Identity.AddClaim(new Claim("urn:googleplus:name", context.Name, XmlSchemaString, Options.AuthenticationType)); + context.Identity.AddClaim(new Claim("urn:google:name", context.Name, XmlSchemaString, Options.AuthenticationType)); } if (!string.IsNullOrEmpty(context.Link)) { - context.Identity.AddClaim(new Claim("urn:googleplus:url", context.Link, XmlSchemaString, Options.AuthenticationType)); + context.Identity.AddClaim(new Claim("urn:google:url", context.Link, XmlSchemaString, Options.AuthenticationType)); } context.Properties = properties; diff --git a/src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs b/src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs index f4bd555..a307ccc 100644 --- a/src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs +++ b/src/Owin.Security.Providers.Google/GoogleAuthenticationOptions.cs @@ -100,6 +100,7 @@ namespace Owin.Security.Providers.Google AuthenticationMode = AuthenticationMode.Passive; Scope = new List { + "openid", "profile", "email" }; diff --git a/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticatedContext.cs b/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticatedContext.cs index d5194ce..075920d 100644 --- a/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticatedContext.cs +++ b/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticatedContext.cs @@ -2,7 +2,6 @@ using System; using System.Globalization; -using System.Linq; using System.Security.Claims; using Microsoft.Owin; using Microsoft.Owin.Security; @@ -20,16 +19,14 @@ namespace Owin.Security.Providers.Google.Provider /// Initializes a /// /// The OWIN environment - /// The JSON-serialized user - /// - /// Google+ Access token + /// The JSON-serialized user_info. Format described here: https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + /// Google Access token /// Seconds until expiration /// - public GoogleAuthenticatedContext(IOwinContext context, JObject user, JObject person, string accessToken, string expires, string refreshToken) + public GoogleAuthenticatedContext(IOwinContext context, JObject userInfo, string accessToken, string expires, string refreshToken) : base(context) { - User = user; - Person = person; + UserInfo = userInfo; AccessToken = accessToken; RefreshToken = refreshToken; @@ -39,16 +36,15 @@ namespace Owin.Security.Providers.Google.Provider ExpiresIn = TimeSpan.FromSeconds(expiresValue); } - Id = TryGetValue(person, "id"); - Name = TryGetValue(person, "displayName"); - Link = TryGetValue(person, "url"); - UserName = TryGetValue(person, "displayName").Replace(" ", ""); + // See https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims for a list of properties + Id = TryGetValue(userInfo, "sub"); + Name = TryGetValue(userInfo, "name"); + Link = TryGetValue(userInfo, "profile"); + UserName = TryGetValue(userInfo, "name").Replace(" ", ""); - var email = (from e in person["emails"] - where e["type"].ToString() == "account" - select e).FirstOrDefault(); + var email = TryGetValue(userInfo, "email"); if (email != null) - Email = email["value"].ToString(); + Email = email; } /// @@ -57,16 +53,7 @@ namespace Owin.Security.Providers.Google.Provider /// /// Contains the Google user obtained from the endpoint https://www.googleapis.com/oauth2/v3/userinfo /// - public JObject User { get; private set; } - - /// - /// Gets the JSON-serialized person - /// - /// - /// Contains the Google+ person obtained from the endpoint https://www.googleapis.com/plus/v1/people/me. For more information - /// see https://developers.google.com/+/api/latest/people - /// - public JObject Person { get; private set; } + public JObject UserInfo { get; private set; } /// /// Gets the Google OAuth access token @@ -79,12 +66,12 @@ namespace Owin.Security.Providers.Google.Provider public string RefreshToken { get; private set; } /// - /// Gets the Google+ access token expiration time + /// Gets the Google access token expiration time /// public TimeSpan? ExpiresIn { get; set; } /// - /// Gets the Google+ user ID + /// Gets the Google user ID /// public string Id { get; private set; } @@ -96,12 +83,12 @@ namespace Owin.Security.Providers.Google.Provider public string Link { get; private set; } /// - /// Gets the Google+ username + /// Gets the Google username /// public string UserName { get; private set; } /// - /// Gets the Google+ email address for the account + /// Gets the Google email address for the account /// public string Email { get; private set; } From c9e6d86bc8d01c7a2eb07d0a334c14ace1188f2b Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 29 Jan 2019 14:42:35 +0000 Subject: [PATCH 6/7] Update some comments about Google+ -> Google --- .../Provider/GoogleAuthenticationProvider.cs | 2 +- .../Provider/IGoogleAuthenticationProvider.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticationProvider.cs b/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticationProvider.cs index e66beb5..c76f37a 100644 --- a/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticationProvider.cs +++ b/src/Owin.Security.Providers.Google/Provider/GoogleAuthenticationProvider.cs @@ -28,7 +28,7 @@ namespace Owin.Security.Providers.Google.Provider public Func OnReturnEndpoint { get; set; } /// - /// Invoked whenever Google+ successfully authenticates a user + /// Invoked whenever Google successfully authenticates a user /// /// Contains information about the login session as well as the user . /// A representing the completed operation. diff --git a/src/Owin.Security.Providers.Google/Provider/IGoogleAuthenticationProvider.cs b/src/Owin.Security.Providers.Google/Provider/IGoogleAuthenticationProvider.cs index 5ef53b2..2ca246e 100644 --- a/src/Owin.Security.Providers.Google/Provider/IGoogleAuthenticationProvider.cs +++ b/src/Owin.Security.Providers.Google/Provider/IGoogleAuthenticationProvider.cs @@ -8,7 +8,7 @@ namespace Owin.Security.Providers.Google.Provider public interface IGoogleAuthenticationProvider { /// - /// Invoked whenever Google+ successfully authenticates a user + /// Invoked whenever Google successfully authenticates a user /// /// Contains information about the login session as well as the user . /// A representing the completed operation. From 4400102d13dbee409c8c1413d839f3fba417839f Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 29 Jan 2019 15:05:28 +0000 Subject: [PATCH 7/7] Change DefaultAuthenticationType to Google --- src/Owin.Security.Providers.Google/Constants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Owin.Security.Providers.Google/Constants.cs b/src/Owin.Security.Providers.Google/Constants.cs index 527cdbf..e6c4e96 100644 --- a/src/Owin.Security.Providers.Google/Constants.cs +++ b/src/Owin.Security.Providers.Google/Constants.cs @@ -2,6 +2,6 @@ { internal static class Constants { - public const string DefaultAuthenticationType = "GooglePlus"; + public const string DefaultAuthenticationType = "Google"; } } \ No newline at end of file