Rename GooglePlus to Google

This commit is contained in:
Gwilym Kuiper
2019-01-29 11:26:51 +00:00
parent 334ba8664f
commit 0c529e18fe
10 changed files with 74 additions and 74 deletions

View File

@@ -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
});
}
}
}

View File

@@ -13,7 +13,7 @@ using Owin.Security.Providers.Google.Provider;
namespace Owin.Security.Providers.Google
{
public class GooglePlusAuthenticationHandler : AuthenticationHandler<GooglePlusAuthenticationOptions>
public class GoogleAuthenticationHandler : AuthenticationHandler<GoogleAuthenticationOptions>
{
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

View File

@@ -11,13 +11,13 @@ using Owin.Security.Providers.Google.Provider;
namespace Owin.Security.Providers.Google
{
public class GooglePlusAuthenticationMiddleware : AuthenticationMiddleware<GooglePlusAuthenticationOptions>
public class GoogleAuthenticationMiddleware : AuthenticationMiddleware<GoogleAuthenticationOptions>
{
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<GooglePlusAuthenticationMiddleware>();
_logger = app.CreateLogger<GoogleAuthenticationMiddleware>();
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 <see cref="T:Microsoft.Owin.Security.Infrastructure.AuthenticationHandler" /> configured with the
/// <see cref="T:Owin.Security.Providers.GooglePlus.GooglePlusAuthenticationOptions" /> supplied to the constructor.
/// </returns>
protected override AuthenticationHandler<GooglePlusAuthenticationOptions> CreateHandler()
protected override AuthenticationHandler<GoogleAuthenticationOptions> 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();

View File

@@ -7,7 +7,7 @@ using Owin.Security.Providers.Google.Provider;
namespace Owin.Security.Providers.Google
{
public class GooglePlusAuthenticationOptions : AuthenticationOptions
public class GoogleAuthenticationOptions : AuthenticationOptions
{
/// <summary>
/// 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<string> MomentTypes { get; private set; }
/// <summary>
/// Gets or sets the <see cref="IGooglePlusAuthenticationProvider" /> used in the authentication events
/// Gets or sets the <see cref="IGoogleAuthenticationProvider" /> used in the authentication events
/// </summary>
public IGooglePlusAuthenticationProvider Provider { get; set; }
public IGoogleAuthenticationProvider Provider { get; set; }
/// <summary>
/// Gets or sets whether to request offline access. If offline access is requested the <see cref="GooglePlusAuthenticatedContext"/> will contain a Refresh Token.
/// Gets or sets whether to request offline access. If offline access is requested the <see cref="GoogleAuthenticatedContext"/> will contain a Refresh Token.
/// </summary>
public bool RequestOfflineAccess { get; set; }
@@ -96,9 +96,9 @@ namespace Owin.Security.Providers.Google
public ISecureDataFormat<AuthenticationProperties> StateDataFormat { get; set; }
/// <summary>
/// Initializes a new <see cref="GooglePlusAuthenticationOptions" />
/// Initializes a new <see cref="GoogleAuthenticationOptions" />
/// </summary>
public GooglePlusAuthenticationOptions()
public GoogleAuthenticationOptions()
: base("GooglePlus")
{
Caption = Constants.DefaultAuthenticationType;

View File

@@ -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
});
}
}
}

View File

@@ -61,14 +61,14 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Constants.cs" />
<Compile Include="GooglePlusAuthenticationExtensions.cs" />
<Compile Include="GooglePlusAuthenticationHandler.cs" />
<Compile Include="GooglePlusAuthenticationMiddleware.cs" />
<Compile Include="GooglePlusAuthenticationOptions.cs" />
<Compile Include="Provider\GooglePlusAuthenticatedContext.cs" />
<Compile Include="Provider\GooglePlusAuthenticationProvider.cs" />
<Compile Include="Provider\GooglePlusReturnEndpointContext.cs" />
<Compile Include="Provider\IGooglePlusAuthenticationProvider.cs" />
<Compile Include="GoogleAuthenticationExtensions.cs" />
<Compile Include="GoogleAuthenticationHandler.cs" />
<Compile Include="GoogleAuthenticationMiddleware.cs" />
<Compile Include="GoogleAuthenticationOptions.cs" />
<Compile Include="Provider\GoogleAuthenticatedContext.cs" />
<Compile Include="Provider\GoogleAuthenticationProvider.cs" />
<Compile Include="Provider\GoogleReturnEndpointContext.cs" />
<Compile Include="Provider\IGoogleAuthenticationProvider.cs" />
<Compile Include="Resources.Designer.cs">
<DependentUpon>Resources.resx</DependentUpon>
<AutoGen>True</AutoGen>

View File

@@ -14,10 +14,10 @@ namespace Owin.Security.Providers.Google.Provider
/// <summary>
/// Contains information about the login session as well as the user <see cref="System.Security.Claims.ClaimsIdentity"/>.
/// </summary>
public class GooglePlusAuthenticatedContext : BaseContext
public class GoogleAuthenticatedContext : BaseContext
{
/// <summary>
/// Initializes a <see cref="GooglePlusAuthenticatedContext"/>
/// Initializes a <see cref="GoogleAuthenticatedContext"/>
/// </summary>
/// <param name="context">The OWIN environment</param>
/// <param name="user">The JSON-serialized user</param>
@@ -25,7 +25,7 @@ namespace Owin.Security.Providers.Google.Provider
/// <param name="accessToken">Google+ Access token</param>
/// <param name="expires">Seconds until expiration</param>
/// <param name="refreshToken"></param>
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; }
/// <summary>
/// Gets the Google OAuth refresh token. This is only available when the RequestOfflineAccess property of <see cref="GooglePlusAuthenticationOptions"/> is set to true
/// Gets the Google OAuth refresh token. This is only available when the RequestOfflineAccess property of <see cref="GoogleAuthenticationOptions"/> is set to true
/// </summary>
public string RefreshToken { get; private set; }

View File

@@ -4,14 +4,14 @@ using System.Threading.Tasks;
namespace Owin.Security.Providers.Google.Provider
{
/// <summary>
/// Default <see cref="IGooglePlusAuthenticationProvider"/> implementation.
/// Default <see cref="IGoogleAuthenticationProvider"/> implementation.
/// </summary>
public class GooglePlusAuthenticationProvider : IGooglePlusAuthenticationProvider
public class GoogleAuthenticationProvider : IGoogleAuthenticationProvider
{
/// <summary>
/// Initializes a <see cref="GooglePlusAuthenticationProvider"/>
/// Initializes a <see cref="GoogleAuthenticationProvider"/>
/// </summary>
public GooglePlusAuthenticationProvider()
public GoogleAuthenticationProvider()
{
OnAuthenticated = context => Task.FromResult<object>(null);
OnReturnEndpoint = context => Task.FromResult<object>(null);
@@ -20,19 +20,19 @@ namespace Owin.Security.Providers.Google.Provider
/// <summary>
/// Gets or sets the function that is invoked when the Authenticated method is invoked.
/// </summary>
public Func<GooglePlusAuthenticatedContext, Task> OnAuthenticated { get; set; }
public Func<GoogleAuthenticatedContext, Task> OnAuthenticated { get; set; }
/// <summary>
/// Gets or sets the function that is invoked when the ReturnEndpoint method is invoked.
/// </summary>
public Func<GooglePlusReturnEndpointContext, Task> OnReturnEndpoint { get; set; }
public Func<GoogleReturnEndpointContext, Task> OnReturnEndpoint { get; set; }
/// <summary>
/// Invoked whenever Google+ successfully authenticates a user
/// </summary>
/// <param name="context">Contains information about the login session as well as the user <see cref="System.Security.Claims.ClaimsIdentity"/>.</param>
/// <returns>A <see cref="Task"/> representing the completed operation.</returns>
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
/// </summary>
/// <param name="context"></param>
/// <returns>A <see cref="Task"/> representing the completed operation.</returns>
public virtual Task ReturnEndpoint(GooglePlusReturnEndpointContext context)
public virtual Task ReturnEndpoint(GoogleReturnEndpointContext context)
{
return OnReturnEndpoint(context);
}

View File

@@ -9,14 +9,14 @@ namespace Owin.Security.Providers.Google.Provider
/// <summary>
/// Provides context information to middleware providers.
/// </summary>
public class GooglePlusReturnEndpointContext : ReturnEndpointContext
public class GoogleReturnEndpointContext : ReturnEndpointContext
{
/// <summary>
///
/// </summary>
/// <param name="context">OWIN environment</param>
/// <param name="ticket">The authentication ticket</param>
public GooglePlusReturnEndpointContext(
public GoogleReturnEndpointContext(
IOwinContext context,
AuthenticationTicket ticket)
: base(context, ticket)

View File

@@ -3,22 +3,22 @@
namespace Owin.Security.Providers.Google.Provider
{
/// <summary>
/// Specifies callback methods which the <see cref="GooglePlusAuthenticationMiddleware"></see> invokes to enable developer control over the authentication process. />
/// Specifies callback methods which the <see cref="GoogleAuthenticationMiddleware"></see> invokes to enable developer control over the authentication process. />
/// </summary>
public interface IGooglePlusAuthenticationProvider
public interface IGoogleAuthenticationProvider
{
/// <summary>
/// Invoked whenever Google+ successfully authenticates a user
/// </summary>
/// <param name="context">Contains information about the login session as well as the user <see cref="System.Security.Claims.ClaimsIdentity"/>.</param>
/// <returns>A <see cref="Task"/> representing the completed operation.</returns>
Task Authenticated(GooglePlusAuthenticatedContext context);
Task Authenticated(GoogleAuthenticatedContext context);
/// <summary>
/// Invoked prior to the <see cref="System.Security.Claims.ClaimsIdentity"/> being saved in a local cookie and the browser being redirected to the originally requested URL.
/// </summary>
/// <param name="context"></param>
/// <returns>A <see cref="Task"/> representing the completed operation.</returns>
Task ReturnEndpoint(GooglePlusReturnEndpointContext context);
Task ReturnEndpoint(GoogleReturnEndpointContext context);
}
}