Move extension methods to proper namespaces
Also add sugar for OpenIdConnect Fixes https://github.com/aspnet/Security/issues/107 Fixes https://github.com/aspnet/Security/issues/113
This commit is contained in:
parent
e2bb76280f
commit
aacc00aaee
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using Microsoft.AspNet.Authentication.Cookies;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
|
||||
namespace Microsoft.AspNet.Builder
|
||||
|
|
@ -11,13 +10,8 @@ namespace Microsoft.AspNet.Builder
|
|||
/// <summary>
|
||||
/// Extension methods provided by the cookies authentication middleware
|
||||
/// </summary>
|
||||
public static class CookieAuthenticationExtensions
|
||||
public static class CookieAppBuilderExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureCookieAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<CookieAuthenticationOptions> configure)
|
||||
{
|
||||
return services.Configure(configure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a cookie-based authentication middleware to your web application pipeline.
|
||||
/// </summary>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// 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;
|
||||
using Microsoft.AspNet.Authentication.Cookies;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
|
||||
namespace Microsoft.Framework.DependencyInjection
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods provided by the cookies authentication middleware
|
||||
/// </summary>
|
||||
public static class CookieServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureCookieAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<CookieAuthenticationOptions> configure)
|
||||
{
|
||||
return services.Configure(configure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +1,17 @@
|
|||
// 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.DependencyInjection;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using System;
|
||||
using Microsoft.AspNet.Authentication.Facebook;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
|
||||
namespace Microsoft.AspNet.Builder
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for using <see cref="FacebookAuthenticationMiddleware"/>.
|
||||
/// </summary>
|
||||
public static class FacebookAuthenticationExtensions
|
||||
public static class FacebookAppBuilderExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureFacebookAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<FacebookAuthenticationOptions> configure)
|
||||
{
|
||||
return services.Configure(configure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authenticate users using Facebook.
|
||||
/// </summary>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// 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;
|
||||
|
||||
namespace Microsoft.Framework.DependencyInjection
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for using <see cref="FacebookAuthenticationMiddleware"/>.
|
||||
/// </summary>
|
||||
public static class FacebookServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureFacebookAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<FacebookAuthenticationOptions> configure)
|
||||
{
|
||||
return services.Configure(configure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +1,17 @@
|
|||
// 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.Google;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using System;
|
||||
using Microsoft.AspNet.Authentication.Google;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
|
||||
namespace Microsoft.AspNet.Builder
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for using <see cref="GoogleAuthenticationMiddleware"/>.
|
||||
/// </summary>
|
||||
public static class GoogleAuthenticationExtensions
|
||||
public static class GoogleAppBuilderExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureGoogleAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<GoogleAuthenticationOptions> configure)
|
||||
{
|
||||
return services.Configure(configure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authenticate users using Google OAuth 2.0.
|
||||
/// </summary>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// 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;
|
||||
using Microsoft.AspNet.Authentication.Google;
|
||||
|
||||
namespace Microsoft.Framework.DependencyInjection
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for using <see cref="GoogleAuthenticationMiddleware"/>.
|
||||
/// </summary>
|
||||
public static class GoogleServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureGoogleAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<GoogleAuthenticationOptions> configure)
|
||||
{
|
||||
return services.Configure(configure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Authentication.MicrosoftAccount;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using System;
|
||||
|
||||
|
|
@ -13,11 +12,6 @@ namespace Microsoft.AspNet.Builder
|
|||
/// </summary>
|
||||
public static class MicrosoftAccountAuthenticationExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureMicrosoftAccountAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<MicrosoftAccountAuthenticationOptions> configure)
|
||||
{
|
||||
return services.Configure(configure);
|
||||
}
|
||||
|
||||
public static IApplicationBuilder UseMicrosoftAccountAuthentication([NotNull] this IApplicationBuilder app, Action<MicrosoftAccountAuthenticationOptions> configureOptions = null, string optionsName = "")
|
||||
{
|
||||
return app.UseMiddleware<MicrosoftAccountAuthenticationMiddleware>(
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// 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;
|
||||
using Microsoft.AspNet.Authentication.MicrosoftAccount;
|
||||
|
||||
namespace Microsoft.Framework.DependencyInjection
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for using <see cref="MicrosoftAccountAuthenticationMiddleware"/>
|
||||
/// </summary>
|
||||
public static class MicrosoftAccountServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureMicrosoftAccountAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<MicrosoftAccountAuthenticationOptions> configure)
|
||||
{
|
||||
return services.Configure(configure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using Microsoft.AspNet.Authentication.OAuthBearer;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
|
||||
namespace Microsoft.AspNet.Builder
|
||||
|
|
@ -11,13 +10,8 @@ namespace Microsoft.AspNet.Builder
|
|||
/// <summary>
|
||||
/// Extension methods to add OAuth Bearer authentication capabilities to an HTTP application pipeline
|
||||
/// </summary>
|
||||
public static class OAuthBearerAuthenticationExtensions
|
||||
public static class OAuthBearerAppBuilderExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureOAuthBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<OAuthBearerAuthenticationOptions> configure)
|
||||
{
|
||||
return services.ConfigureOptions(configure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Bearer token processing to an HTTP application pipeline. This middleware understands appropriately
|
||||
/// formatted and secured tokens which appear in the request header. If the Options.AuthenticationMode is Active, the
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// 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;
|
||||
using Microsoft.AspNet.Authentication.OAuthBearer;
|
||||
|
||||
namespace Microsoft.Framework.DependencyInjection
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to add OAuth Bearer authentication capabilities to an HTTP application pipeline
|
||||
/// </summary>
|
||||
public static class OAuthBearerServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureOAuthBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<OAuthBearerAuthenticationOptions> configure)
|
||||
{
|
||||
return services.ConfigureOptions(configure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// 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;
|
||||
using Microsoft.AspNet.Authentication.OpenIdConnect;
|
||||
|
||||
namespace Microsoft.Framework.DependencyInjection
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to configure OpenIdConnect authentication options
|
||||
/// </summary>
|
||||
public static class OpenIdConnectServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureOpenIdConnect(this IServiceCollection services, Action<OpenIdConnectAuthenticationOptions> configure)
|
||||
{
|
||||
return services.ConfigureOptions(configure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,17 @@
|
|||
// 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;
|
||||
using Microsoft.AspNet.Authentication.Twitter;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using System;
|
||||
using Microsoft.AspNet.Authentication.Twitter;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
|
||||
namespace Microsoft.AspNet.Builder
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for using <see cref="TwitterAuthenticationMiddleware"/>
|
||||
/// </summary>
|
||||
public static class TwitterAuthenticationExtensions
|
||||
public static class TwitterAppBuilderExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureTwitterAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<TwitterAuthenticationOptions> configure)
|
||||
{
|
||||
return services.Configure(configure);
|
||||
}
|
||||
|
||||
public static IApplicationBuilder UseTwitterAuthentication([NotNull] this IApplicationBuilder app, Action<TwitterAuthenticationOptions> configureOptions = null, string optionsName = "")
|
||||
{
|
||||
return app.UseMiddleware<TwitterAuthenticationMiddleware>(
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// 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;
|
||||
using Microsoft.AspNet.Authentication.Twitter;
|
||||
|
||||
namespace Microsoft.Framework.DependencyInjection
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for using <see cref="TwitterAuthenticationMiddleware"/>
|
||||
/// </summary>
|
||||
public static class TwitterAuthenticationExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureTwitterAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<TwitterAuthenticationOptions> configure)
|
||||
{
|
||||
return services.Configure(configure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,14 +8,9 @@ using System.Net.Http;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Authentication.Cookies;
|
||||
using Microsoft.AspNet.Authentication.Twitter;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using Newtonsoft.Json;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue