Rename back to jwtBearer
This commit is contained in:
parent
b189475551
commit
644a4002a9
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
@ -20,11 +20,11 @@ namespace CookieSessionSample
|
|||
{
|
||||
loggerfactory.AddConsole(LogLevel.Information);
|
||||
|
||||
app.UseCookieAuthentication(options =>
|
||||
app.UseCookieAuthentication((System.Action<CookieAuthenticationOptions>)(options =>
|
||||
{
|
||||
options.AutomaticAuthentication = true;
|
||||
options.SessionStore = new MemoryCacheSessionStore();
|
||||
});
|
||||
options.SessionStore = new CookieSessionSample.MemoryCacheTicketStore();
|
||||
}));
|
||||
|
||||
app.Run(async context =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,117 +14,90 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
public class CookieAuthenticationEvents : ICookieAuthenticationEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public Func<CookieValidatePrincipalContext, Task> OnValidatePrincipal { get; set; } = context => Task.FromResult(0);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public Func<CookieSigningInContext, Task> OnSigningIn { get; set; } = context => Task.FromResult(0);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public Func<CookieSignedInContext, Task> OnSignedIn { get; set; } = context => Task.FromResult(0);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public Func<CookieSigningOutContext, Task> OnSigningOut { get; set; } = context => Task.FromResult(0);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public Func<CookieRedirectContext, Task> OnRedirectToReturnUrl { get; set; } = context =>
|
||||
public Func<CookieRedirectContext, Task> OnRedirect { get; set; } = context =>
|
||||
{
|
||||
context.Response.Redirect(context.RedirectUri);
|
||||
return Task.FromResult(0);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// A delegate assigned to this property will be invoked when the related method is called
|
||||
/// </summary>
|
||||
public Func<CookieRedirectContext, Task> OnRedirectToAccessDenied { get; set; } = context =>
|
||||
{
|
||||
context.Response.Redirect(context.RedirectUri);
|
||||
return Task.FromResult(0);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// A delegate assigned to this property will be invoked when the related method is called
|
||||
/// </summary>
|
||||
public Func<CookieRedirectContext, Task> OnRedirectToLogin { get; set; } = context =>
|
||||
{
|
||||
context.Response.Redirect(context.RedirectUri);
|
||||
return Task.FromResult(0);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// A delegate assigned to this property will be invoked when the related method is called
|
||||
/// </summary>
|
||||
public Func<CookieRedirectContext, Task> OnRedirectToLogout { get; set; } = context =>
|
||||
{
|
||||
context.Response.Redirect(context.RedirectUri);
|
||||
return Task.FromResult(0);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public Func<CookieExceptionContext, Task> OnException { get; set; } = context => Task.FromResult(0);
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method by invoking the related delegate method
|
||||
/// Implements the interface method by invoking the related delegate method.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public virtual Task ValidatePrincipal(CookieValidatePrincipalContext context) => OnValidatePrincipal(context);
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method by invoking the related delegate method
|
||||
/// Implements the interface method by invoking the related delegate method.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public virtual Task SigningIn(CookieSigningInContext context) => OnSigningIn(context);
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method by invoking the related delegate method
|
||||
/// Implements the interface method by invoking the related delegate method.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public virtual Task SignedIn(CookieSignedInContext context) => OnSignedIn(context);
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method by invoking the related delegate method
|
||||
/// Implements the interface method by invoking the related delegate method.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public virtual Task SigningOut(CookieSigningOutContext context) => OnSigningOut(context);
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method by invoking the related delegate method
|
||||
/// Implements the interface method by invoking the related delegate method.
|
||||
/// </summary>
|
||||
/// <param name="context">Contains information about the event</param>
|
||||
public virtual Task RedirectToLogout(CookieRedirectContext context) => OnRedirectToLogout(context);
|
||||
public virtual Task RedirectToLogout(CookieRedirectContext context) => OnRedirect(context);
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method by invoking the related delegate method
|
||||
/// Implements the interface method by invoking the related delegate method.
|
||||
/// </summary>
|
||||
/// <param name="context">Contains information about the event</param>
|
||||
public virtual Task RedirectToLogin(CookieRedirectContext context) => OnRedirectToLogin(context);
|
||||
public virtual Task RedirectToLogin(CookieRedirectContext context) => OnRedirect(context);
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method by invoking the related delegate method
|
||||
/// Implements the interface method by invoking the related delegate method.
|
||||
/// </summary>
|
||||
/// <param name="context">Contains information about the event</param>
|
||||
public virtual Task RedirectToReturnUrl(CookieRedirectContext context) => OnRedirectToReturnUrl(context);
|
||||
public virtual Task RedirectToReturnUrl(CookieRedirectContext context) => OnRedirect(context);
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method by invoking the related delegate method
|
||||
/// Implements the interface method by invoking the related delegate method.
|
||||
/// </summary>
|
||||
/// <param name="context">Contains information about the event</param>
|
||||
public virtual Task RedirectToAccessDenied(CookieRedirectContext context) => OnRedirectToAccessDenied(context);
|
||||
public virtual Task RedirectToAccessDenied(CookieRedirectContext context) => OnRedirect(context);
|
||||
|
||||
/// <summary>
|
||||
/// Implements the interface method by invoking the related delegate method
|
||||
/// Implements the interface method by invoking the related delegate method.
|
||||
/// </summary>
|
||||
/// <param name="context">Contains information about the event</param>
|
||||
public virtual Task Exception(CookieExceptionContext context) => OnException(context);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Microsoft.AspNet.Http.Authentication;
|
|||
namespace Microsoft.AspNet.Authentication.Cookies
|
||||
{
|
||||
/// <summary>
|
||||
/// Context object passed to the ICookieAuthenticationEvents method ResponseSignIn.
|
||||
/// Context object passed to the ICookieAuthenticationEvents method SigningIn.
|
||||
/// </summary>
|
||||
public class CookieSigningInContext : BaseContext<CookieAuthenticationOptions>
|
||||
{
|
||||
|
|
@ -43,19 +43,19 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public ClaimsPrincipal Principal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public AuthenticationProperties Properties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public CookieOptions CookieOptions { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public CookieOptions CookieOptions
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||
{
|
||||
public class AuthenticationChallengeContext : BaseControlContext<OpenIdConnectBearerOptions>
|
||||
public class AuthenticationChallengeContext : BaseControlContext<JwtBearerOptions>
|
||||
{
|
||||
public AuthenticationChallengeContext(HttpContext context, OpenIdConnectBearerOptions options)
|
||||
public AuthenticationChallengeContext(HttpContext context, JwtBearerOptions options)
|
||||
: base(context, options)
|
||||
{
|
||||
}
|
||||
|
|
@ -4,11 +4,11 @@
|
|||
using System;
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||
{
|
||||
public class AuthenticationFailedContext : BaseControlContext<OpenIdConnectBearerOptions>
|
||||
public class AuthenticationFailedContext : BaseControlContext<JwtBearerOptions>
|
||||
{
|
||||
public AuthenticationFailedContext(HttpContext context, OpenIdConnectBearerOptions options)
|
||||
public AuthenticationFailedContext(HttpContext context, JwtBearerOptions options)
|
||||
: base(context, options)
|
||||
{
|
||||
}
|
||||
|
|
@ -4,14 +4,14 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies events which the <see cref="OpenIdConnectBearerAuthenticationMiddleware"></see> invokes to enable developer control over the authentication process. />
|
||||
/// Specifies events which the <see cref="JwtBearerAuthenticationMiddleware"></see> invokes to enable developer control over the authentication process. />
|
||||
/// </summary>
|
||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||
{
|
||||
/// <summary>
|
||||
/// OpenIdConnect bearer token middleware events.
|
||||
/// </summary>
|
||||
public interface IOpenIdConnectBearerEvents
|
||||
public interface IJwtBearerEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed.
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||
{
|
||||
public class MessageReceivedContext : BaseControlContext<OpenIdConnectBearerOptions>
|
||||
public class MessageReceivedContext : BaseControlContext<JwtBearerOptions>
|
||||
{
|
||||
public MessageReceivedContext(HttpContext context, OpenIdConnectBearerOptions options)
|
||||
public MessageReceivedContext(HttpContext context, JwtBearerOptions options)
|
||||
: base(context, options)
|
||||
{
|
||||
}
|
||||
|
|
@ -6,14 +6,14 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNet.Http;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies events which the <see cref="OpenIdConnectBearerAuthenticationMiddleware"></see> invokes to enable developer control over the authentication process. />
|
||||
/// Specifies events which the <see cref="JwtBearerAuthenticationMiddleware"></see> invokes to enable developer control over the authentication process. />
|
||||
/// </summary>
|
||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||
{
|
||||
/// <summary>
|
||||
/// OpenIdConnect bearer token middleware events.
|
||||
/// </summary>
|
||||
public class OpenIdConnectBearerEvents : IOpenIdConnectBearerEvents
|
||||
public class JwtBearerEvents : IJwtBearerEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed.
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||
{
|
||||
public class SecurityTokenReceivedContext : BaseControlContext<OpenIdConnectBearerOptions>
|
||||
public class SecurityTokenReceivedContext : BaseControlContext<JwtBearerOptions>
|
||||
{
|
||||
public SecurityTokenReceivedContext(HttpContext context, OpenIdConnectBearerOptions options)
|
||||
public SecurityTokenReceivedContext(HttpContext context, JwtBearerOptions options)
|
||||
: base(context, options)
|
||||
{
|
||||
}
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||
{
|
||||
public class SecurityTokenValidatedContext : BaseControlContext<OpenIdConnectBearerOptions>
|
||||
public class SecurityTokenValidatedContext : BaseControlContext<JwtBearerOptions>
|
||||
{
|
||||
public SecurityTokenValidatedContext(HttpContext context, OpenIdConnectBearerOptions options)
|
||||
public SecurityTokenValidatedContext(HttpContext context, JwtBearerOptions options)
|
||||
: base(context, options)
|
||||
{
|
||||
}
|
||||
|
|
@ -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
|
|||
/// <summary>
|
||||
/// Extension methods to add OpenIdConnect Bearer authentication capabilities to an HTTP application pipeline
|
||||
/// </summary>
|
||||
public static class OpenIdConnectBearerAppBuilderExtensions
|
||||
public static class JwtBearerAppBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds Bearer token processing to an HTTP application pipeline. This middleware understands appropriately
|
||||
|
|
@ -24,9 +24,9 @@ namespace Microsoft.AspNet.Builder
|
|||
/// <param name="app">The application builder</param>
|
||||
/// <param name="options">Options which control the processing of the bearer header.</param>
|
||||
/// <returns>The application builder</returns>
|
||||
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<OpenIdConnectBearerMiddleware>(options);
|
||||
return app.UseMiddleware<JwtBearerMiddleware>(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -40,14 +40,14 @@ namespace Microsoft.AspNet.Builder
|
|||
/// <param name="app">The application builder</param>
|
||||
/// <param name="configureOptions">Used to configure Middleware options.</param>
|
||||
/// <returns>The application builder</returns>
|
||||
public static IApplicationBuilder UseOpenIdConnectBearerAuthentication([NotNull] this IApplicationBuilder app, Action<OpenIdConnectBearerOptions> configureOptions)
|
||||
public static IApplicationBuilder UseJwtBearerAuthentication([NotNull] this IApplicationBuilder app, Action<JwtBearerOptions> configureOptions)
|
||||
{
|
||||
var options = new OpenIdConnectBearerOptions();
|
||||
var options = new JwtBearerOptions();
|
||||
if (configureOptions != null)
|
||||
{
|
||||
configureOptions(options);
|
||||
}
|
||||
return app.UseOpenIdConnectBearerAuthentication(options);
|
||||
return app.UseJwtBearerAuthentication(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Default values used by authorization server and bearer authentication.
|
||||
/// Default values used by bearer authentication.
|
||||
/// </summary>
|
||||
public static class OpenIdConnectBearerDefaults
|
||||
public static class JwtBearerDefaults
|
||||
{
|
||||
/// <summary>
|
||||
/// Default value for AuthenticationScheme property in the OpenIdConnectBearerAuthenticationOptions and
|
||||
/// OpenIdConnectAuthorizationServerOptions.
|
||||
/// Default value for AuthenticationScheme property in the JwtBearerAuthenticationOptions
|
||||
/// </summary>
|
||||
public const string AuthenticationScheme = "Bearer";
|
||||
}
|
||||
|
|
@ -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<OpenIdConnectBearerOptions>
|
||||
internal class JwtBearerHandler : AuthenticationHandler<JwtBearerOptions>
|
||||
{
|
||||
private OpenIdConnectConfiguration _configuration;
|
||||
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public class OpenIdConnectBearerMiddleware : AuthenticationMiddleware<OpenIdConnectBearerOptions>
|
||||
public class JwtBearerMiddleware : AuthenticationMiddleware<JwtBearerOptions>
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the request handler</returns>
|
||||
protected override AuthenticationHandler<OpenIdConnectBearerOptions> CreateHandler()
|
||||
protected override AuthenticationHandler<JwtBearerOptions> CreateHandler()
|
||||
{
|
||||
return new OpenIdConnectBearerHandler();
|
||||
return new JwtBearerHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Options class provides information needed to control Bearer Authentication middleware behavior
|
||||
/// </summary>
|
||||
public class OpenIdConnectBearerOptions : AuthenticationOptions
|
||||
public class JwtBearerOptions : AuthenticationOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an instance of bearer authentication options with default values.
|
||||
/// </summary>
|
||||
public OpenIdConnectBearerOptions() : base()
|
||||
public JwtBearerOptions() : base()
|
||||
{
|
||||
AuthenticationScheme = OpenIdConnectBearerDefaults.AuthenticationScheme;
|
||||
AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -45,14 +45,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
|||
/// <summary>
|
||||
/// Gets or sets the challenge to put in the "WWW-Authenticate" header.
|
||||
/// </summary>
|
||||
public string Challenge { get; set; } = OpenIdConnectBearerDefaults.AuthenticationScheme;
|
||||
public string Challenge { get; set; } = JwtBearerDefaults.AuthenticationScheme;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public IOpenIdConnectBearerEvents Events { get; set; } = new OpenIdConnectBearerEvents();
|
||||
public IJwtBearerEvents Events { get; set; } = new JwtBearerEvents();
|
||||
|
||||
/// <summary>
|
||||
/// The HttpMessageHandler used to retrieve metadata.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// <auto-generated />
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// The '{0}' option must be provided.
|
||||
|
|
@ -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<OpenIdConnectBearerOptions> configureOptions, Func<HttpContext, bool> handler = null)
|
||||
private static TestServer CreateServer(Action<JwtBearerOptions> configureOptions, Func<HttpContext, bool> 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<NotSupportedException>(() => context.Authentication.SignInAsync(OpenIdConnectBearerDefaults.AuthenticationScheme, new ClaimsPrincipal()));
|
||||
await Assert.ThrowsAsync<NotSupportedException>(() => context.Authentication.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal()));
|
||||
}
|
||||
else if (context.Request.Path == new PathString("/signOut"))
|
||||
{
|
||||
await Assert.ThrowsAsync<NotSupportedException>(() => context.Authentication.SignOutAsync(OpenIdConnectBearerDefaults.AuthenticationScheme));
|
||||
await Assert.ThrowsAsync<NotSupportedException>(() => context.Authentication.SignOutAsync(JwtBearerDefaults.AuthenticationScheme));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -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-*",
|
||||
|
|
|
|||
Loading…
Reference in New Issue