diff --git a/Security.sln b/Security.sln index 0818558307..289a79139a 100644 --- a/Security.sln +++ b/Security.sln @@ -48,7 +48,7 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.CookiePoli EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.CookiePolicy.Test", "test\Microsoft.AspNet.CookiePolicy.Test\Microsoft.AspNet.CookiePolicy.Test.xproj", "{1790E052-646F-4529-B90E-6FEA95520D69}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.OpenIdConnectBearer", "src\Microsoft.AspNet.Authentication.OpenIdConnectBearer\Microsoft.AspNet.Authentication.OpenIdConnectBearer.xproj", "{2755BFE5-7421-4A31-A644-F817DF5CAA98}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.JwtBearer", "src\Microsoft.AspNet.Authentication.OpenIdConnectBearer\Microsoft.AspNet.Authentication.JwtBearer.xproj", "{2755BFE5-7421-4A31-A644-F817DF5CAA98}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/samples/CookieSessionSample/MemoryCacheSessionStore.cs b/samples/CookieSessionSample/MemoryCacheTicketStore.cs similarity index 94% rename from samples/CookieSessionSample/MemoryCacheSessionStore.cs rename to samples/CookieSessionSample/MemoryCacheTicketStore.cs index d0e78d1367..e308825edc 100644 --- a/samples/CookieSessionSample/MemoryCacheSessionStore.cs +++ b/samples/CookieSessionSample/MemoryCacheTicketStore.cs @@ -6,12 +6,12 @@ using Microsoft.Framework.Caching.Memory; namespace CookieSessionSample { - public class MemoryCacheSessionStore : ITicketStore + public class MemoryCacheTicketStore : ITicketStore { private const string KeyPrefix = "AuthSessionStore-"; private IMemoryCache _cache; - public MemoryCacheSessionStore() + public MemoryCacheTicketStore() { _cache = new MemoryCache(new MemoryCacheOptions()); } diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 1bfc635cc9..8e0cbcad45 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -20,11 +20,11 @@ namespace CookieSessionSample { loggerfactory.AddConsole(LogLevel.Information); - app.UseCookieAuthentication(options => + app.UseCookieAuthentication((System.Action)(options => { options.AutomaticAuthentication = true; - options.SessionStore = new MemoryCacheSessionStore(); - }); + options.SessionStore = new CookieSessionSample.MemoryCacheTicketStore(); + })); app.Run(async context => { diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieAuthenticationEvents.cs index 21881824ea..b8b88060b5 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieAuthenticationEvents.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieAuthenticationEvents.cs @@ -14,117 +14,90 @@ namespace Microsoft.AspNet.Authentication.Cookies public class CookieAuthenticationEvents : ICookieAuthenticationEvents { /// - /// A delegate assigned to this property will be invoked when the related method is called + /// A delegate assigned to this property will be invoked when the related method is called. /// public Func OnValidatePrincipal { get; set; } = context => Task.FromResult(0); /// - /// A delegate assigned to this property will be invoked when the related method is called + /// A delegate assigned to this property will be invoked when the related method is called. /// public Func OnSigningIn { get; set; } = context => Task.FromResult(0); /// - /// A delegate assigned to this property will be invoked when the related method is called + /// A delegate assigned to this property will be invoked when the related method is called. /// public Func OnSignedIn { get; set; } = context => Task.FromResult(0); /// - /// A delegate assigned to this property will be invoked when the related method is called + /// A delegate assigned to this property will be invoked when the related method is called. /// public Func OnSigningOut { get; set; } = context => Task.FromResult(0); /// - /// A delegate assigned to this property will be invoked when the related method is called + /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnRedirectToReturnUrl { get; set; } = context => + public Func OnRedirect { get; set; } = context => { context.Response.Redirect(context.RedirectUri); return Task.FromResult(0); }; /// - /// A delegate assigned to this property will be invoked when the related method is called - /// - public Func OnRedirectToAccessDenied { get; set; } = context => - { - context.Response.Redirect(context.RedirectUri); - return Task.FromResult(0); - }; - - /// - /// A delegate assigned to this property will be invoked when the related method is called - /// - public Func OnRedirectToLogin { get; set; } = context => - { - context.Response.Redirect(context.RedirectUri); - return Task.FromResult(0); - }; - - /// - /// A delegate assigned to this property will be invoked when the related method is called - /// - public Func OnRedirectToLogout { get; set; } = context => - { - context.Response.Redirect(context.RedirectUri); - return Task.FromResult(0); - }; - - /// - /// A delegate assigned to this property will be invoked when the related method is called + /// A delegate assigned to this property will be invoked when the related method is called. /// public Func OnException { get; set; } = context => Task.FromResult(0); /// - /// Implements the interface method by invoking the related delegate method + /// Implements the interface method by invoking the related delegate method. /// /// /// public virtual Task ValidatePrincipal(CookieValidatePrincipalContext context) => OnValidatePrincipal(context); /// - /// Implements the interface method by invoking the related delegate method + /// Implements the interface method by invoking the related delegate method. /// /// public virtual Task SigningIn(CookieSigningInContext context) => OnSigningIn(context); /// - /// Implements the interface method by invoking the related delegate method + /// Implements the interface method by invoking the related delegate method. /// /// public virtual Task SignedIn(CookieSignedInContext context) => OnSignedIn(context); /// - /// Implements the interface method by invoking the related delegate method + /// Implements the interface method by invoking the related delegate method. /// /// public virtual Task SigningOut(CookieSigningOutContext context) => OnSigningOut(context); /// - /// Implements the interface method by invoking the related delegate method + /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToLogout(CookieRedirectContext context) => OnRedirectToLogout(context); + public virtual Task RedirectToLogout(CookieRedirectContext context) => OnRedirect(context); /// - /// Implements the interface method by invoking the related delegate method + /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToLogin(CookieRedirectContext context) => OnRedirectToLogin(context); + public virtual Task RedirectToLogin(CookieRedirectContext context) => OnRedirect(context); /// - /// Implements the interface method by invoking the related delegate method + /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToReturnUrl(CookieRedirectContext context) => OnRedirectToReturnUrl(context); + public virtual Task RedirectToReturnUrl(CookieRedirectContext context) => OnRedirect(context); /// - /// Implements the interface method by invoking the related delegate method + /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToAccessDenied(CookieRedirectContext context) => OnRedirectToAccessDenied(context); + public virtual Task RedirectToAccessDenied(CookieRedirectContext context) => OnRedirect(context); /// - /// Implements the interface method by invoking the related delegate method + /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event public virtual Task Exception(CookieExceptionContext context) => OnException(context); diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs index 4ff477b8f3..9bac7dc534 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs @@ -8,7 +8,7 @@ using Microsoft.AspNet.Http.Authentication; namespace Microsoft.AspNet.Authentication.Cookies { /// - /// Context object passed to the ICookieAuthenticationEvents method ResponseSignIn. + /// Context object passed to the ICookieAuthenticationEvents method SigningIn. /// public class CookieSigningInContext : BaseContext { @@ -43,19 +43,19 @@ namespace Microsoft.AspNet.Authentication.Cookies /// /// Contains the claims about to be converted into the outgoing cookie. - /// May be replaced or altered during the ResponseSignIn call. + /// May be replaced or altered during the SigningIn call. /// public ClaimsPrincipal Principal { get; set; } /// /// Contains the extra data about to be contained in the outgoing cookie. - /// May be replaced or altered during the ResponseSignIn call. + /// May be replaced or altered during the SigningIn call. /// public AuthenticationProperties Properties { get; set; } /// /// The options for creating the outgoing cookie. - /// May be replace or altered during the ResponseSignIn call. + /// May be replace or altered during the SigningIn call. /// public CookieOptions CookieOptions { get; set; } } diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs index d9e960ada9..a529060ada 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs @@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Authentication.Cookies /// /// The options for creating the outgoing cookie. - /// May be replace or altered during the ResponseSignOut call. + /// May be replace or altered during the SigningOut call. /// public CookieOptions CookieOptions { diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieValidateIdentityContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Events/CookieValidateIdentityContext.cs rename to src/Microsoft.AspNet.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/AuthenticationChallengeContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationChallengeContext.cs similarity index 74% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/AuthenticationChallengeContext.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationChallengeContext.cs index e7b0df4ef8..44f44d5b3e 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/AuthenticationChallengeContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationChallengeContext.cs @@ -3,11 +3,11 @@ using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { - public class AuthenticationChallengeContext : BaseControlContext + public class AuthenticationChallengeContext : BaseControlContext { - public AuthenticationChallengeContext(HttpContext context, OpenIdConnectBearerOptions options) + public AuthenticationChallengeContext(HttpContext context, JwtBearerOptions options) : base(context, options) { } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs similarity index 78% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/AuthenticationFailedContext.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs index e894ed2a14..2ac80c4f73 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs @@ -4,11 +4,11 @@ using System; using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { - public class AuthenticationFailedContext : BaseControlContext + public class AuthenticationFailedContext : BaseControlContext { - public AuthenticationFailedContext(HttpContext context, OpenIdConnectBearerOptions options) + public AuthenticationFailedContext(HttpContext context, JwtBearerOptions options) : base(context, options) { } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/IOpenIdConnectBearerEvents.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/IOpenIdConnectBearerEvents.cs similarity index 83% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/IOpenIdConnectBearerEvents.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Events/IOpenIdConnectBearerEvents.cs index 973b5c9178..d4d280484d 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/IOpenIdConnectBearerEvents.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/IOpenIdConnectBearerEvents.cs @@ -4,14 +4,14 @@ using System.Threading.Tasks; /// -/// 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.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { /// /// OpenIdConnect bearer token middleware events. /// - public interface IOpenIdConnectBearerEvents + public interface IJwtBearerEvents { /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/MessageReceivedContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/MessageReceivedContext.cs similarity index 65% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/MessageReceivedContext.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Events/MessageReceivedContext.cs index 5b28b109ae..cd940ef679 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/MessageReceivedContext.cs @@ -3,11 +3,11 @@ using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { - public class MessageReceivedContext : BaseControlContext + public class MessageReceivedContext : BaseControlContext { - public MessageReceivedContext(HttpContext context, OpenIdConnectBearerOptions options) + public MessageReceivedContext(HttpContext context, JwtBearerOptions options) : base(context, options) { } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/OpenIdConnectBearerEvents.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/OpenIdConnectBearerEvents.cs similarity index 89% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/OpenIdConnectBearerEvents.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Events/OpenIdConnectBearerEvents.cs index e53dbd8bc1..e4aa6ed8e0 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/OpenIdConnectBearerEvents.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/OpenIdConnectBearerEvents.cs @@ -6,14 +6,14 @@ 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.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { /// /// OpenIdConnect bearer token middleware events. /// - public class OpenIdConnectBearerEvents : IOpenIdConnectBearerEvents + public class JwtBearerEvents : IJwtBearerEvents { /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/SecurityTokenReceivedContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenReceivedContext.cs similarity index 77% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/SecurityTokenReceivedContext.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenReceivedContext.cs index 81ec1522c6..5aedda1d84 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/SecurityTokenReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenReceivedContext.cs @@ -3,11 +3,11 @@ using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { - public class SecurityTokenReceivedContext : BaseControlContext + public class SecurityTokenReceivedContext : BaseControlContext { - public SecurityTokenReceivedContext(HttpContext context, OpenIdConnectBearerOptions options) + public SecurityTokenReceivedContext(HttpContext context, JwtBearerOptions options) : base(context, options) { } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/SecurityTokenValidatedContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenValidatedContext.cs similarity index 75% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/SecurityTokenValidatedContext.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenValidatedContext.cs index 78f3a81f4e..488e8e6b02 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Events/SecurityTokenValidatedContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenValidatedContext.cs @@ -3,11 +3,11 @@ using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { - public class SecurityTokenValidatedContext : BaseControlContext + public class SecurityTokenValidatedContext : BaseControlContext { - public SecurityTokenValidatedContext(HttpContext context, OpenIdConnectBearerOptions options) + public SecurityTokenValidatedContext(HttpContext context, JwtBearerOptions options) : base(context, options) { } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs similarity index 78% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerAppBuilderExtensions.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index 148d3d892c..be2d51b1b9 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication.OpenIdConnectBearer; +using Microsoft.AspNet.Authentication.JwtBearer; using Microsoft.Framework.Internal; using Microsoft.Framework.OptionsModel; @@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Builder /// /// Extension methods to add OpenIdConnect Bearer authentication capabilities to an HTTP application pipeline /// - public static class OpenIdConnectBearerAppBuilderExtensions + public static class JwtBearerAppBuilderExtensions { /// /// Adds Bearer token processing to an HTTP application pipeline. This middleware understands appropriately @@ -24,9 +24,9 @@ namespace Microsoft.AspNet.Builder /// The application builder /// Options which control the processing of the bearer header. /// The application builder - public static IApplicationBuilder UseOpenIdConnectBearerAuthentication([NotNull] this IApplicationBuilder app, [NotNull] OpenIdConnectBearerOptions options) + public static IApplicationBuilder UseJwtBearerAuthentication([NotNull] this IApplicationBuilder app, [NotNull] JwtBearerOptions options) { - return app.UseMiddleware(options); + return app.UseMiddleware(options); } /// @@ -40,14 +40,14 @@ namespace Microsoft.AspNet.Builder /// The application builder /// Used to configure Middleware options. /// The application builder - public static IApplicationBuilder UseOpenIdConnectBearerAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions) + public static IApplicationBuilder UseJwtBearerAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions) { - var options = new OpenIdConnectBearerOptions(); + var options = new JwtBearerOptions(); if (configureOptions != null) { configureOptions(options); } - return app.UseOpenIdConnectBearerAuthentication(options); + return app.UseJwtBearerAuthentication(options); } } } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerDefaults.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerDefaults.cs similarity index 57% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerDefaults.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerDefaults.cs index b271709f98..5b73bf1569 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerDefaults.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerDefaults.cs @@ -1,16 +1,15 @@ // 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.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { /// - /// Default values used by authorization server and bearer authentication. + /// Default values used by bearer authentication. /// - public static class OpenIdConnectBearerDefaults + public static class JwtBearerDefaults { /// - /// Default value for AuthenticationScheme property in the OpenIdConnectBearerAuthenticationOptions and - /// OpenIdConnectAuthorizationServerOptions. + /// Default value for AuthenticationScheme property in the JwtBearerAuthenticationOptions /// public const string AuthenticationScheme = "Bearer"; } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerHandler.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs similarity index 97% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerHandler.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs index 9a84dcfb36..2577f897eb 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs @@ -10,9 +10,9 @@ using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.Framework.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { - internal class OpenIdConnectBearerHandler : AuthenticationHandler + internal class JwtBearerHandler : AuthenticationHandler { private OpenIdConnectConfiguration _configuration; diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerMiddleware.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs similarity index 83% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerMiddleware.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs index fee6e11430..ce919a9206 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs @@ -10,30 +10,30 @@ using Microsoft.Framework.WebEncoders; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer +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 UseOpenIdConnectBearerAuthentication + /// created by application code directly, instead it is added by calling the the IAppBuilder UseJwtBearerAuthentication /// extension method. /// - public class OpenIdConnectBearerMiddleware : AuthenticationMiddleware + public class JwtBearerMiddleware : 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 UseOpenIdConnectBearerAuthentication + /// called by application code directly, instead it is added by calling the the IAppBuilder UseJwtBearerAuthentication /// extension method. /// - public OpenIdConnectBearerMiddleware( + public JwtBearerMiddleware( [NotNull] RequestDelegate next, [NotNull] ILoggerFactory loggerFactory, [NotNull] IUrlEncoder encoder, - [NotNull] OpenIdConnectBearerOptions options) + [NotNull] JwtBearerOptions options) : base(next, options, loggerFactory, encoder) { if (Options.Events == null) { - Options.Events = new OpenIdConnectBearerEvents(); + Options.Events = new JwtBearerEvents(); } if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.Audience)) @@ -73,9 +73,9 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer /// 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 OpenIdConnectBearerHandler(); + return new JwtBearerHandler(); } } } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerOptions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs similarity index 89% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerOptions.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs index f47a436ee0..5aca4a1392 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/OpenIdConnectBearerOptions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs @@ -9,19 +9,19 @@ using System.Net.Http; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { /// /// Options class provides information needed to control Bearer Authentication middleware behavior /// - public class OpenIdConnectBearerOptions : AuthenticationOptions + public class JwtBearerOptions : AuthenticationOptions { /// /// Creates an instance of bearer authentication options with default values. /// - public OpenIdConnectBearerOptions() : base() + public JwtBearerOptions() : base() { - AuthenticationScheme = OpenIdConnectBearerDefaults.AuthenticationScheme; + AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme; } /// @@ -45,14 +45,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer /// /// Gets or sets the challenge to put in the "WWW-Authenticate" header. /// - public string Challenge { get; set; } = OpenIdConnectBearerDefaults.AuthenticationScheme; + public string Challenge { get; set; } = JwtBearerDefaults.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 OpenIdConnectBearerAuthenticationEvents + /// The application may implement the interface fully, or it may create an instance of JwtBearerAuthenticationEvents /// and assign delegates only to the events it wants to process. /// - public IOpenIdConnectBearerEvents Events { get; set; } = new OpenIdConnectBearerEvents(); + public IJwtBearerEvents Events { get; set; } = new JwtBearerEvents(); /// /// The HttpMessageHandler used to retrieve metadata. diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Microsoft.AspNet.Authentication.OpenIdConnectBearer.xproj b/src/Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.JwtBearer.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Microsoft.AspNet.Authentication.OpenIdConnectBearer.xproj rename to src/Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.JwtBearer.xproj diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Properties/Resources.Designer.cs similarity index 93% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Properties/Resources.Designer.cs rename to src/Microsoft.AspNet.Authentication.JwtBearer/Properties/Resources.Designer.cs index bafcd6d0d6..79bbbe4497 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Authentication.OpenIdConnectBearer.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.AspNet.Authentication.JwtBearer.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// The '{0}' option must be provided. diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Resources.resx b/src/Microsoft.AspNet.Authentication.JwtBearer/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/Resources.resx rename to src/Microsoft.AspNet.Authentication.JwtBearer/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/project.json b/src/Microsoft.AspNet.Authentication.JwtBearer/project.json similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnectBearer/project.json rename to src/Microsoft.AspNet.Authentication.JwtBearer/project.json diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnectBearer/OpenIdConnectBearerMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs similarity index 94% rename from test/Microsoft.AspNet.Authentication.Test/OpenIdConnectBearer/OpenIdConnectBearerMiddlewareTests.cs rename to test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 596a6e61fa..24bc6ccec4 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnectBearer/OpenIdConnectBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -15,9 +15,9 @@ using Microsoft.AspNet.TestHost; using Microsoft.Framework.DependencyInjection; using Xunit; -namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer +namespace Microsoft.AspNet.Authentication.JwtBearer { - public class OpenIdConnectBearerMiddlewareTests + public class JwtBearerMiddlewareTests { [Fact] public async Task BearerTokenValidation() @@ -66,7 +66,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer { options.AutomaticAuthentication = true; - options.Events = new OpenIdConnectBearerEvents() + options.Events = new JwtBearerEvents() { OnMessageReceived = context => { @@ -116,7 +116,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer { options.AutomaticAuthentication = true; - options.Events = new OpenIdConnectBearerEvents() + options.Events = new JwtBearerEvents() { OnSecurityTokenReceived = context => { @@ -150,7 +150,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer { options.AutomaticAuthentication = true; - options.Events = new OpenIdConnectBearerEvents() + options.Events = new JwtBearerEvents() { OnSecurityTokenValidated = context => { @@ -187,7 +187,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer { options.AutomaticAuthentication = true; - options.Events = new OpenIdConnectBearerEvents() + options.Events = new JwtBearerEvents() { OnMessageReceived = context => { @@ -224,7 +224,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer { var server = CreateServer(options => { - options.Events = new OpenIdConnectBearerEvents() + options.Events = new JwtBearerEvents() { OnSecurityTokenReceived = context => { @@ -255,7 +255,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer { var server = CreateServer(options => { - options.Events = new OpenIdConnectBearerEvents() + options.Events = new JwtBearerEvents() { OnSecurityTokenReceived = context => { @@ -323,13 +323,13 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer } } - 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.UseOpenIdConnectBearerAuthentication(configureOptions); + app.UseJwtBearerAuthentication(configureOptions); } app.Use(async (context, next) => @@ -359,17 +359,17 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer else if (context.Request.Path == new PathString("/unauthorized")) { // Simulate Authorization failure - var result = await context.Authentication.AuthenticateAsync(OpenIdConnectBearerDefaults.AuthenticationScheme); - await context.Authentication.ChallengeAsync(OpenIdConnectBearerDefaults.AuthenticationScheme); + var result = await context.Authentication.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme); + await context.Authentication.ChallengeAsync(JwtBearerDefaults.AuthenticationScheme); } else if (context.Request.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.Authentication.SignInAsync(OpenIdConnectBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.Authentication.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); } else if (context.Request.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync(OpenIdConnectBearerDefaults.AuthenticationScheme)); + await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync(JwtBearerDefaults.AuthenticationScheme)); } else { diff --git a/test/Microsoft.AspNet.Authentication.Test/project.json b/test/Microsoft.AspNet.Authentication.Test/project.json index c56539e8e1..10f0e221a2 100644 --- a/test/Microsoft.AspNet.Authentication.Test/project.json +++ b/test/Microsoft.AspNet.Authentication.Test/project.json @@ -6,7 +6,7 @@ "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNet.Authentication.Facebook": "1.0.0-*", "Microsoft.AspNet.Authentication.Google": "1.0.0-*", - "Microsoft.AspNet.Authentication.OpenIdConnectBearer": "1.0.0-*", + "Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-*", "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-*", "Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNet.Authentication.Twitter": "1.0.0-*",