Add Configure overloads for Auth for config/name

This commit is contained in:
Hao Kung 2015-03-06 12:37:34 -08:00
parent ce8caf0b9a
commit 5e7f1d7eff
8 changed files with 133 additions and 10 deletions

View File

@ -3,6 +3,7 @@
using System;
using Microsoft.AspNet.Authentication.Cookies;
using Microsoft.Framework.ConfigurationModel;
using Microsoft.Framework.DependencyInjection;
namespace Microsoft.Framework.DependencyInjection
@ -14,7 +15,22 @@ namespace Microsoft.Framework.DependencyInjection
{
public static IServiceCollection ConfigureCookieAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<CookieAuthenticationOptions> configure)
{
return services.Configure(configure);
return services.ConfigureCookieAuthentication(configure, optionsName: "");
}
public static IServiceCollection ConfigureCookieAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<CookieAuthenticationOptions> configure, string optionsName)
{
return services.Configure(configure, optionsName);
}
public static IServiceCollection ConfigureCookieAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config)
{
return services.ConfigureCookieAuthentication(config, optionsName: "");
}
public static IServiceCollection ConfigureCookieAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config, string optionsName)
{
return services.Configure<CookieAuthenticationOptions>(config, optionsName);
}
}
}

View File

@ -1,9 +1,9 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Authentication.Facebook;
using Microsoft.Framework.OptionsModel;
using System;
using Microsoft.AspNet.Authentication.Facebook;
using Microsoft.Framework.ConfigurationModel;
namespace Microsoft.Framework.DependencyInjection
{
@ -14,7 +14,22 @@ namespace Microsoft.Framework.DependencyInjection
{
public static IServiceCollection ConfigureFacebookAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<FacebookAuthenticationOptions> configure)
{
return services.Configure(configure);
return services.ConfigureFacebookAuthentication(configure, optionsName: "");
}
public static IServiceCollection ConfigureFacebookAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<FacebookAuthenticationOptions> configure, string optionsName)
{
return services.Configure(configure, optionsName);
}
public static IServiceCollection ConfigureFacebookAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config)
{
return services.ConfigureFacebookAuthentication(config, optionsName: "");
}
public static IServiceCollection ConfigureFacebookAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config, string optionsName)
{
return services.Configure<FacebookAuthenticationOptions>(config, optionsName);
}
}
}

View File

@ -3,6 +3,7 @@
using System;
using Microsoft.AspNet.Authentication.Google;
using Microsoft.Framework.ConfigurationModel;
namespace Microsoft.Framework.DependencyInjection
{
@ -13,7 +14,22 @@ namespace Microsoft.Framework.DependencyInjection
{
public static IServiceCollection ConfigureGoogleAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<GoogleAuthenticationOptions> configure)
{
return services.Configure(configure);
return services.ConfigureGoogleAuthentication(configure, optionsName: "");
}
public static IServiceCollection ConfigureGoogleAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<GoogleAuthenticationOptions> configure, string optionsName)
{
return services.Configure(configure, optionsName);
}
public static IServiceCollection ConfigureGoogleAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config)
{
return services.ConfigureGoogleAuthentication(config, optionsName: "");
}
public static IServiceCollection ConfigureGoogleAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config, string optionsName)
{
return services.Configure<GoogleAuthenticationOptions>(config, optionsName);
}
}
}

View File

@ -3,6 +3,7 @@
using System;
using Microsoft.AspNet.Authentication.MicrosoftAccount;
using Microsoft.Framework.ConfigurationModel;
namespace Microsoft.Framework.DependencyInjection
{
@ -13,7 +14,22 @@ namespace Microsoft.Framework.DependencyInjection
{
public static IServiceCollection ConfigureMicrosoftAccountAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<MicrosoftAccountAuthenticationOptions> configure)
{
return services.Configure(configure);
return services.ConfigureMicrosoftAccountAuthentication(configure, optionsName: "");
}
public static IServiceCollection ConfigureMicrosoftAccountAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<MicrosoftAccountAuthenticationOptions> configure, string optionsName)
{
return services.Configure(configure, optionsName);
}
public static IServiceCollection ConfigureMicrosoftAccountAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config)
{
return services.ConfigureMicrosoftAccountAuthentication(config, optionsName: "");
}
public static IServiceCollection ConfigureMicrosoftAccountAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config, string optionsName)
{
return services.Configure<MicrosoftAccountAuthenticationOptions>(config, optionsName);
}
}
}

View File

@ -3,6 +3,7 @@
using System;
using Microsoft.AspNet.Authentication.OAuthBearer;
using Microsoft.Framework.ConfigurationModel;
namespace Microsoft.Framework.DependencyInjection
{
@ -13,7 +14,22 @@ namespace Microsoft.Framework.DependencyInjection
{
public static IServiceCollection ConfigureOAuthBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<OAuthBearerAuthenticationOptions> configure)
{
return services.ConfigureOptions(configure);
return services.ConfigureOAuthBearerAuthentication(configure, optionsName: "");
}
public static IServiceCollection ConfigureOAuthBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<OAuthBearerAuthenticationOptions> configure, string optionsName)
{
return services.Configure(configure, optionsName);
}
public static IServiceCollection ConfigureOAuthBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config)
{
return services.ConfigureOAuthBearerAuthentication(config, optionsName: "");
}
public static IServiceCollection ConfigureOAuthBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config, string optionsName)
{
return services.Configure<OAuthBearerAuthenticationOptions>(config, optionsName);
}
}
}

View File

@ -0,0 +1,12 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.AspNet.Authentication.OpenIdConnect
{
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)]
internal sealed class NotNullAttribute : Attribute
{
}
}

View File

@ -3,6 +3,7 @@
using System;
using Microsoft.AspNet.Authentication.OpenIdConnect;
using Microsoft.Framework.ConfigurationModel;
namespace Microsoft.Framework.DependencyInjection
{
@ -11,9 +12,24 @@ namespace Microsoft.Framework.DependencyInjection
/// </summary>
public static class OpenIdConnectServiceCollectionExtensions
{
public static IServiceCollection ConfigureOpenIdConnect(this IServiceCollection services, Action<OpenIdConnectAuthenticationOptions> configure)
public static IServiceCollection ConfigureOpenIdConnectAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<OpenIdConnectAuthenticationOptions> configure)
{
return services.ConfigureOptions(configure);
return services.ConfigureOpenIdConnectAuthentication(configure, optionsName: "");
}
public static IServiceCollection ConfigureOpenIdConnectAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<OpenIdConnectAuthenticationOptions> configure, string optionsName)
{
return services.Configure(configure, optionsName);
}
public static IServiceCollection ConfigureOpenIdConnectAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config)
{
return services.ConfigureOpenIdConnectAuthentication(config, optionsName: "");
}
public static IServiceCollection ConfigureOpenIdConnectAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config, string optionsName)
{
return services.Configure<OpenIdConnectAuthenticationOptions>(config, optionsName);
}
}
}

View File

@ -3,6 +3,7 @@
using System;
using Microsoft.AspNet.Authentication.Twitter;
using Microsoft.Framework.ConfigurationModel;
namespace Microsoft.Framework.DependencyInjection
{
@ -13,7 +14,22 @@ namespace Microsoft.Framework.DependencyInjection
{
public static IServiceCollection ConfigureTwitterAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<TwitterAuthenticationOptions> configure)
{
return services.Configure(configure);
return services.ConfigureTwitterAuthentication(configure, optionsName: "");
}
public static IServiceCollection ConfigureTwitterAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<TwitterAuthenticationOptions> configure, string optionsName)
{
return services.Configure(configure, optionsName);
}
public static IServiceCollection ConfigureTwitterAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config)
{
return services.ConfigureTwitterAuthentication(config, optionsName: "");
}
public static IServiceCollection ConfigureTwitterAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config, string optionsName)
{
return services.Configure<TwitterAuthenticationOptions>(config, optionsName);
}
}
}