From 0c529e18feb06db19d653a89a99582f341c3c20f Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 29 Jan 2019 11:26:51 +0000 Subject: [PATCH] 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