From bcf8a45340413f85d81e3489f1a9ae2fb4ea0d3f Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 1 Sep 2015 12:23:51 -0700 Subject: [PATCH] #413 Rename OAuthBearer to JwtBearer. --- Security.sln | 4 +-- .../JwtBearerAppBuilderExtensions.cs} | 12 +++---- .../JwtBearerAuthenticationDefaults.cs} | 8 ++--- .../JwtBearerAuthenticationHandler.cs} | 14 ++++---- .../JwtBearerAuthenticationMiddleware.cs} | 22 ++++++------ .../JwtBearerAuthenticationOptions.cs} | 14 ++++---- .../JwtBearerServiceCollectionExtensions.cs | 36 +++++++++++++++++++ ...oft.AspNet.Authentication.JwtBearer.xproj} | 0 .../AuthenticationChallengeNotification.cs | 2 +- .../JwtBearerAuthenticationNotifications.cs} | 22 ++++++------ .../Properties/AssemblyInfo.cs | 0 .../Resources.Designer.cs | 4 +-- .../Resources.resx | 0 .../project.json | 2 +- .../OAuthBearerServiceCollectionExtensions.cs | 36 ------------------- .../JwtBearerMiddlewareTests.cs} | 16 ++++----- .../project.json | 2 +- 17 files changed, 97 insertions(+), 97 deletions(-) rename src/{Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAppBuilderExtensions.cs => Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs} (69%) rename src/{Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationDefaults.cs => Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationDefaults.cs} (70%) rename src/{Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs => Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationHandler.cs} (93%) rename src/{Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs => Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationMiddleware.cs} (84%) rename src/{Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs => Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationOptions.cs} (89%) create mode 100644 src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerServiceCollectionExtensions.cs rename src/{Microsoft.AspNet.Authentication.OAuthBearer/Microsoft.AspNet.Authentication.OAuthBearer.xproj => Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.JwtBearer.xproj} (100%) rename src/{Microsoft.AspNet.Authentication.OAuthBearer => Microsoft.AspNet.Authentication.JwtBearer}/Notifications/AuthenticationChallengeNotification.cs (89%) rename src/{Microsoft.AspNet.Authentication.OAuthBearer/Notifications/OAuthBearerAuthenticationNotifications.cs => Microsoft.AspNet.Authentication.JwtBearer/Notifications/JwtBearerAuthenticationNotifications.cs} (65%) rename src/{Microsoft.AspNet.Authentication.OAuthBearer => Microsoft.AspNet.Authentication.JwtBearer}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuthBearer => Microsoft.AspNet.Authentication.JwtBearer}/Resources.Designer.cs (95%) rename src/{Microsoft.AspNet.Authentication.OAuthBearer => Microsoft.AspNet.Authentication.JwtBearer}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authentication.OAuthBearer => Microsoft.AspNet.Authentication.JwtBearer}/project.json (95%) delete mode 100644 src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerServiceCollectionExtensions.cs rename test/Microsoft.AspNet.Authentication.Test/{OAuthBearer/OAuthBearerMiddlewareTests.cs => JwtBearer/JwtBearerMiddlewareTests.cs} (95%) diff --git a/Security.sln b/Security.sln index 8f65fe16bd..7fd810f8b7 100644 --- a/Security.sln +++ b/Security.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22605.0 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -40,7 +40,7 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentica EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.Test", "test\Microsoft.AspNet.Authentication.Test\Microsoft.AspNet.Authentication.Test.xproj", "{8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.OAuthBearer", "src\Microsoft.AspNet.Authentication.OAuthBearer\Microsoft.AspNet.Authentication.OAuthBearer.xproj", "{2755BFE5-7421-4A31-A644-F817DF5CAA98}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.JwtBearer", "src\Microsoft.AspNet.Authentication.JwtBearer\Microsoft.AspNet.Authentication.JwtBearer.xproj", "{2755BFE5-7421-4A31-A644-F817DF5CAA98}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authorization.Test", "test\Microsoft.AspNet.Authorization.Test\Microsoft.AspNet.Authorization.Test.xproj", "{7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}" EndProject diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs similarity index 69% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAppBuilderExtensions.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index f50b2a401a..4b14d7ab78 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -2,16 +2,16 @@ // 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; +using Microsoft.AspNet.Authentication.JwtBearer; using Microsoft.Framework.Internal; using Microsoft.Framework.OptionsModel; namespace Microsoft.AspNet.Builder { /// - /// Extension methods to add OAuth Bearer authentication capabilities to an HTTP application pipeline + /// Extension methods to add Jwt Bearer authentication capabilities to an HTTP application pipeline /// - public static class OAuthBearerAppBuilderExtensions + public static class JwtBearerAppBuilderExtensions { /// /// Adds Bearer token processing to an HTTP application pipeline. This middleware understands appropriately @@ -24,10 +24,10 @@ namespace Microsoft.AspNet.Builder /// The application builder /// Options which control the processing of the bearer header. /// The application builder - public static IApplicationBuilder UseOAuthBearerAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions = null, string optionsName = "") + public static IApplicationBuilder UseJwtBearerAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions = null, string optionsName = "") { - return app.UseMiddleware( - new ConfigureOptions(configureOptions ?? (o => { })) + return app.UseMiddleware( + new ConfigureOptions(configureOptions ?? (o => { })) { Name = optionsName }); diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationDefaults.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationDefaults.cs similarity index 70% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationDefaults.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationDefaults.cs index 2dc1797e96..d6cb381976 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationDefaults.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationDefaults.cs @@ -1,16 +1,16 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Authentication.OAuthBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { /// /// Default values used by authorization server and bearer authentication. /// - public static class OAuthBearerAuthenticationDefaults + public static class JwtBearerAuthenticationDefaults { /// - /// Default value for AuthenticationScheme property in the OAuthBearerAuthenticationOptions and - /// OAuthAuthorizationServerOptions. + /// Default value for AuthenticationScheme property in the JwtBearerAuthenticationOptions and + /// JwtAuthorizationServerOptions. /// public const string AuthenticationScheme = "Bearer"; } diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationHandler.cs similarity index 93% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationHandler.cs index c72f0b1b33..6b740c5d0b 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationHandler.cs @@ -11,9 +11,9 @@ using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.Framework.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.OAuthBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { - public class OAuthBearerAuthenticationHandler : AuthenticationHandler + public class JwtBearerAuthenticationHandler : AuthenticationHandler { private OpenIdConnectConfiguration _configuration; @@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer { // Give application opportunity to find from a different location, adjust, or reject token var messageReceivedNotification = - new MessageReceivedNotification(Context, Options) + new MessageReceivedNotification(Context, Options) { ProtocolMessage = Context, }; @@ -72,7 +72,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer // notify user token was received var securityTokenReceivedNotification = - new SecurityTokenReceivedNotification(Context, Options) + new SecurityTokenReceivedNotification(Context, Options) { ProtocolMessage = Context, SecurityToken = token, @@ -117,7 +117,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer { var principal = validator.ValidateToken(token, validationParameters, out validatedToken); var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Options.AuthenticationScheme); - var securityTokenValidatedNotification = new SecurityTokenValidatedNotification(Context, Options) + var securityTokenValidatedNotification = new SecurityTokenValidatedNotification(Context, Options) { ProtocolMessage = Context, AuthenticationTicket = ticket @@ -151,7 +151,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer } var authenticationFailedNotification = - new AuthenticationFailedNotification(Context, Options) + new AuthenticationFailedNotification(Context, Options) { ProtocolMessage = Context, Exception = ex @@ -175,7 +175,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { Response.StatusCode = 401; - await Options.Notifications.ApplyChallenge(new AuthenticationChallengeNotification(Context, Options)); + await Options.Notifications.ApplyChallenge(new AuthenticationChallengeNotification(Context, Options)); return false; } diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationMiddleware.cs similarity index 84% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationMiddleware.cs index 2fa9ddd2b0..973c6f80d0 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationMiddleware.cs @@ -12,31 +12,31 @@ using Microsoft.Framework.WebEncoders; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.OAuthBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { /// /// Bearer authentication middleware component which is added to an HTTP pipeline. This class is not - /// created by application code directly, instead it is added by calling the the IAppBuilder UseOAuthBearerAuthentication + /// created by application code directly, instead it is added by calling the the IAppBuilder UseJwtBearerAuthentication /// extension method. /// - public class OAuthBearerAuthenticationMiddleware : AuthenticationMiddleware + public class JwtBearerAuthenticationMiddleware : AuthenticationMiddleware { /// /// Bearer authentication component which is added to an HTTP pipeline. This constructor is not - /// called by application code directly, instead it is added by calling the the IAppBuilder UseOAuthBearerAuthentication + /// called by application code directly, instead it is added by calling the the IAppBuilder UseJwtBearerAuthentication /// extension method. /// - public OAuthBearerAuthenticationMiddleware( + public JwtBearerAuthenticationMiddleware( [NotNull] RequestDelegate next, [NotNull] ILoggerFactory loggerFactory, [NotNull] IUrlEncoder encoder, - [NotNull] IOptions options, - ConfigureOptions configureOptions) + [NotNull] IOptions options, + ConfigureOptions configureOptions) : base(next, options, loggerFactory, encoder, configureOptions) { if (Options.Notifications == null) { - Options.Notifications = new OAuthBearerAuthenticationNotifications(); + Options.Notifications = new JwtBearerAuthenticationNotifications(); } if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.Audience)) @@ -76,13 +76,13 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer /// Called by the AuthenticationMiddleware base class to create a per-request handler. /// /// A new instance of the request handler - protected override AuthenticationHandler CreateHandler() + protected override AuthenticationHandler CreateHandler() { - return new OAuthBearerAuthenticationHandler(); + return new JwtBearerAuthenticationHandler(); } [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Managed by caller")] - private static HttpMessageHandler ResolveHttpMessageHandler(OAuthBearerAuthenticationOptions options) + private static HttpMessageHandler ResolveHttpMessageHandler(JwtBearerAuthenticationOptions options) { HttpMessageHandler handler = options.BackchannelHttpHandler ?? #if DNX451 diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationOptions.cs similarity index 89% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationOptions.cs index 456236f4a2..8e9c51e8b3 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAuthenticationOptions.cs @@ -9,19 +9,19 @@ using System.Net.Http; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.OAuthBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { /// /// Options class provides information needed to control Bearer Authentication middleware behavior /// - public class OAuthBearerAuthenticationOptions : AuthenticationOptions + public class JwtBearerAuthenticationOptions : AuthenticationOptions { /// /// Creates an instance of bearer authentication options with default values. /// - public OAuthBearerAuthenticationOptions() : base() + public JwtBearerAuthenticationOptions() : base() { - AuthenticationScheme = OAuthBearerAuthenticationDefaults.AuthenticationScheme; + AuthenticationScheme = JwtBearerAuthenticationDefaults.AuthenticationScheme; } /// @@ -45,14 +45,14 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer /// /// Gets or sets the challenge to put in the "WWW-Authenticate" header. /// - public string Challenge { get; set; } = OAuthBearerAuthenticationDefaults.AuthenticationScheme; + public string Challenge { get; set; } = JwtBearerAuthenticationDefaults.AuthenticationScheme; /// /// The object provided by the application to process events raised by the bearer authentication middleware. - /// The application may implement the interface fully, or it may create an instance of OAuthBearerAuthenticationProvider + /// The application may implement the interface fully, or it may create an instance of JwtBearerAuthenticationProvider /// and assign delegates only to the events it wants to process. /// - public OAuthBearerAuthenticationNotifications Notifications { get; set; } = new OAuthBearerAuthenticationNotifications(); + public JwtBearerAuthenticationNotifications Notifications { get; set; } = new JwtBearerAuthenticationNotifications(); /// /// The HttpMessageHandler used to retrieve metadata. diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerServiceCollectionExtensions.cs new file mode 100644 index 0000000000..f026908667 --- /dev/null +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerServiceCollectionExtensions.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. 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.JwtBearer; +using Microsoft.Framework.Configuration; +using Microsoft.Framework.Internal; + +namespace Microsoft.Framework.DependencyInjection +{ + /// + /// Extension methods to add Jwt Bearer authentication capabilities to an HTTP application pipeline + /// + public static class JwtBearerServiceCollectionExtensions + { + public static IServiceCollection ConfigureJwtBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] Action configure) + { + return services.ConfigureJwtBearerAuthentication(configure, optionsName: ""); + } + + public static IServiceCollection ConfigureJwtBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] Action configure, string optionsName) + { + return services.Configure(configure, optionsName); + } + + public static IServiceCollection ConfigureJwtBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config) + { + return services.ConfigureJwtBearerAuthentication(config, optionsName: ""); + } + + public static IServiceCollection ConfigureJwtBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] IConfiguration config, string optionsName) + { + return services.Configure(config, optionsName); + } + } +} diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/Microsoft.AspNet.Authentication.OAuthBearer.xproj b/src/Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.JwtBearer.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/Microsoft.AspNet.Authentication.OAuthBearer.xproj rename to src/Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.JwtBearer.xproj diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/Notifications/AuthenticationChallengeNotification.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Notifications/AuthenticationChallengeNotification.cs similarity index 89% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/Notifications/AuthenticationChallengeNotification.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Notifications/AuthenticationChallengeNotification.cs index f9a4b8b87f..4be4376c20 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/Notifications/AuthenticationChallengeNotification.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Notifications/AuthenticationChallengeNotification.cs @@ -3,7 +3,7 @@ using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Authentication.OAuthBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { public class AuthenticationChallengeNotification : BaseNotification { diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/Notifications/OAuthBearerAuthenticationNotifications.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Notifications/JwtBearerAuthenticationNotifications.cs similarity index 65% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/Notifications/OAuthBearerAuthenticationNotifications.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Notifications/JwtBearerAuthenticationNotifications.cs index 8dad8dca3a..06984332ad 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/Notifications/OAuthBearerAuthenticationNotifications.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Notifications/JwtBearerAuthenticationNotifications.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; /// -/// Specifies events which the invokes to enable developer control over the authentication process. /> +/// Specifies events which the invokes to enable developer control over the authentication process. /> /// -namespace Microsoft.AspNet.Authentication.OAuthBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { /// - /// OAuth bearer token middleware provider + /// Jwt bearer token middleware provider /// - public class OAuthBearerAuthenticationNotifications + public class JwtBearerAuthenticationNotifications { /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// - public OAuthBearerAuthenticationNotifications() + public JwtBearerAuthenticationNotifications() { ApplyChallenge = notification => { notification.HttpContext.Response.Headers.Append("WWW-Authenticate", notification.Options.Challenge); return Task.FromResult(0); }; AuthenticationFailed = notification => Task.FromResult(0); @@ -30,26 +30,26 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. /// - public Func, Task> AuthenticationFailed { get; set; } + public Func, Task> AuthenticationFailed { get; set; } /// /// Invoked when a protocol message is first received. /// - public Func, Task> MessageReceived { get; set; } + public Func, Task> MessageReceived { get; set; } /// /// Invoked with the security token that has been extracted from the protocol message. /// - public Func, Task> SecurityTokenReceived { get; set; } + public Func, Task> SecurityTokenReceived { get; set; } /// /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. /// - public Func, Task> SecurityTokenValidated { get; set; } + public Func, Task> SecurityTokenValidated { get; set; } /// /// Invoked to apply a challenge sent back to the caller. /// - public Func, Task> ApplyChallenge { get; set; } + public Func, Task> ApplyChallenge { get; set; } } } diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/Resources.Designer.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Resources.Designer.cs similarity index 95% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/Resources.Designer.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Resources.Designer.cs index 27298f47d8..44a3ea8be5 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/Resources.Designer.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Microsoft.AspNet.Authentication.OAuthBearer { +namespace Microsoft.AspNet.Authentication.JwtBearer { using System; @@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.Authentication.OAuth.Resources", System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(Resources)).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.Authentication.Jwt.Resources", System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(Resources)).Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/Resources.resx b/src/Microsoft.AspNet.Authentication.JwtBearer/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/Resources.resx rename to src/Microsoft.AspNet.Authentication.JwtBearer/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/project.json b/src/Microsoft.AspNet.Authentication.JwtBearer/project.json similarity index 95% rename from src/Microsoft.AspNet.Authentication.OAuthBearer/project.json rename to src/Microsoft.AspNet.Authentication.JwtBearer/project.json index 252d34bc99..048c770808 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/project.json +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/project.json @@ -1,6 +1,6 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 middleware that enables an application to receive a OAuth bearer token.", + "description": "ASP.NET 5 middleware that enables an application to receive a Jwt bearer token.", "repository": { "type": "git", "url": "git://github.com/aspnet/security" diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerServiceCollectionExtensions.cs deleted file mode 100644 index 76fb362d34..0000000000 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerServiceCollectionExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) .NET Foundation. 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; -using Microsoft.Framework.Configuration; -using Microsoft.Framework.Internal; - -namespace Microsoft.Framework.DependencyInjection -{ - /// - /// Extension methods to add OAuth Bearer authentication capabilities to an HTTP application pipeline - /// - public static class OAuthBearerServiceCollectionExtensions - { - public static IServiceCollection ConfigureOAuthBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] Action configure) - { - return services.ConfigureOAuthBearerAuthentication(configure, optionsName: ""); - } - - public static IServiceCollection ConfigureOAuthBearerAuthentication([NotNull] this IServiceCollection services, [NotNull] Action 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(config, optionsName); - } - } -} diff --git a/test/Microsoft.AspNet.Authentication.Test/OAuthBearer/OAuthBearerMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs similarity index 95% rename from test/Microsoft.AspNet.Authentication.Test/OAuthBearer/OAuthBearerMiddlewareTests.cs rename to test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 2331c9816f..a6639e823c 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OAuthBearer/OAuthBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -16,9 +16,9 @@ using Microsoft.Framework.DependencyInjection; using Shouldly; using Xunit; -namespace Microsoft.AspNet.Authentication.OAuthBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { - public class OAuthBearerMiddlewareTests + public class JwtBearerMiddlewareTests { [Fact] public async Task BearerTokenValidation() @@ -309,13 +309,13 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer } } - private static TestServer CreateServer(Action configureOptions, Func handler = null) + private static TestServer CreateServer(Action configureOptions, Func handler = null) { return TestServer.Create(app => { if (configureOptions != null) { - app.UseOAuthBearerAuthentication(configureOptions); + app.UseJwtBearerAuthentication(configureOptions); } app.Use(async (context, next) => @@ -345,17 +345,17 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer else if (context.Request.Path == new PathString("/unauthorized")) { // Simulate Authorization failure - var result = await context.Authentication.AuthenticateAsync(OAuthBearerAuthenticationDefaults.AuthenticationScheme); - await context.Authentication.ChallengeAsync(OAuthBearerAuthenticationDefaults.AuthenticationScheme); + var result = await context.Authentication.AuthenticateAsync(JwtBearerAuthenticationDefaults.AuthenticationScheme); + await context.Authentication.ChallengeAsync(JwtBearerAuthenticationDefaults.AuthenticationScheme); } else if (context.Request.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.Authentication.SignInAsync(OAuthBearerAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.Authentication.SignInAsync(JwtBearerAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal())); } else if (context.Request.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync(OAuthBearerAuthenticationDefaults.AuthenticationScheme)); + await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync(JwtBearerAuthenticationDefaults.AuthenticationScheme)); } else { diff --git a/test/Microsoft.AspNet.Authentication.Test/project.json b/test/Microsoft.AspNet.Authentication.Test/project.json index c7f594c4fe..f2eb49c8e9 100644 --- a/test/Microsoft.AspNet.Authentication.Test/project.json +++ b/test/Microsoft.AspNet.Authentication.Test/project.json @@ -6,8 +6,8 @@ "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNet.Authentication.Facebook": "1.0.0-*", "Microsoft.AspNet.Authentication.Google": "1.0.0-*", + "Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-*", "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-*", - "Microsoft.AspNet.Authentication.OAuthBearer": "1.0.0-*", "Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNet.Authentication.Twitter": "1.0.0-*", "Microsoft.AspNet.DataProtection": "1.0.0-*",