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
|
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}"
|
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
|
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
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ using Microsoft.Framework.Caching.Memory;
|
||||||
|
|
||||||
namespace CookieSessionSample
|
namespace CookieSessionSample
|
||||||
{
|
{
|
||||||
public class MemoryCacheSessionStore : ITicketStore
|
public class MemoryCacheTicketStore : ITicketStore
|
||||||
{
|
{
|
||||||
private const string KeyPrefix = "AuthSessionStore-";
|
private const string KeyPrefix = "AuthSessionStore-";
|
||||||
private IMemoryCache _cache;
|
private IMemoryCache _cache;
|
||||||
|
|
||||||
public MemoryCacheSessionStore()
|
public MemoryCacheTicketStore()
|
||||||
{
|
{
|
||||||
_cache = new MemoryCache(new MemoryCacheOptions());
|
_cache = new MemoryCache(new MemoryCacheOptions());
|
||||||
}
|
}
|
||||||
|
|
@ -20,11 +20,11 @@ namespace CookieSessionSample
|
||||||
{
|
{
|
||||||
loggerfactory.AddConsole(LogLevel.Information);
|
loggerfactory.AddConsole(LogLevel.Information);
|
||||||
|
|
||||||
app.UseCookieAuthentication(options =>
|
app.UseCookieAuthentication((System.Action<CookieAuthenticationOptions>)(options =>
|
||||||
{
|
{
|
||||||
options.AutomaticAuthentication = true;
|
options.AutomaticAuthentication = true;
|
||||||
options.SessionStore = new MemoryCacheSessionStore();
|
options.SessionStore = new CookieSessionSample.MemoryCacheTicketStore();
|
||||||
});
|
}));
|
||||||
|
|
||||||
app.Run(async context =>
|
app.Run(async context =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,117 +14,90 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
||||||
public class CookieAuthenticationEvents : ICookieAuthenticationEvents
|
public class CookieAuthenticationEvents : ICookieAuthenticationEvents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public Func<CookieValidatePrincipalContext, Task> OnValidatePrincipal { get; set; } = context => Task.FromResult(0);
|
public Func<CookieValidatePrincipalContext, Task> OnValidatePrincipal { get; set; } = context => Task.FromResult(0);
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public Func<CookieSigningInContext, Task> OnSigningIn { get; set; } = context => Task.FromResult(0);
|
public Func<CookieSigningInContext, Task> OnSigningIn { get; set; } = context => Task.FromResult(0);
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public Func<CookieSignedInContext, Task> OnSignedIn { get; set; } = context => Task.FromResult(0);
|
public Func<CookieSignedInContext, Task> OnSignedIn { get; set; } = context => Task.FromResult(0);
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public Func<CookieSigningOutContext, Task> OnSigningOut { get; set; } = context => Task.FromResult(0);
|
public Func<CookieSigningOutContext, Task> OnSigningOut { get; set; } = context => Task.FromResult(0);
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public Func<CookieRedirectContext, Task> OnRedirectToReturnUrl { get; set; } = context =>
|
public Func<CookieRedirectContext, Task> OnRedirect { get; set; } = context =>
|
||||||
{
|
{
|
||||||
context.Response.Redirect(context.RedirectUri);
|
context.Response.Redirect(context.RedirectUri);
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <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> 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
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<CookieExceptionContext, Task> OnException { get; set; } = context => Task.FromResult(0);
|
public Func<CookieExceptionContext, Task> OnException { get; set; } = context => Task.FromResult(0);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements the interface method by invoking the related delegate method
|
/// Implements the interface method by invoking the related delegate method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual Task ValidatePrincipal(CookieValidatePrincipalContext context) => OnValidatePrincipal(context);
|
public virtual Task ValidatePrincipal(CookieValidatePrincipalContext context) => OnValidatePrincipal(context);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements the interface method by invoking the related delegate method
|
/// Implements the interface method by invoking the related delegate method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
public virtual Task SigningIn(CookieSigningInContext context) => OnSigningIn(context);
|
public virtual Task SigningIn(CookieSigningInContext context) => OnSigningIn(context);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements the interface method by invoking the related delegate method
|
/// Implements the interface method by invoking the related delegate method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
public virtual Task SignedIn(CookieSignedInContext context) => OnSignedIn(context);
|
public virtual Task SignedIn(CookieSignedInContext context) => OnSignedIn(context);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements the interface method by invoking the related delegate method
|
/// Implements the interface method by invoking the related delegate method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
public virtual Task SigningOut(CookieSigningOutContext context) => OnSigningOut(context);
|
public virtual Task SigningOut(CookieSigningOutContext context) => OnSigningOut(context);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements the interface method by invoking the related delegate method
|
/// Implements the interface method by invoking the related delegate method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">Contains information about the event</param>
|
/// <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>
|
/// <summary>
|
||||||
/// Implements the interface method by invoking the related delegate method
|
/// Implements the interface method by invoking the related delegate method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">Contains information about the event</param>
|
/// <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>
|
/// <summary>
|
||||||
/// Implements the interface method by invoking the related delegate method
|
/// Implements the interface method by invoking the related delegate method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">Contains information about the event</param>
|
/// <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>
|
/// <summary>
|
||||||
/// Implements the interface method by invoking the related delegate method
|
/// Implements the interface method by invoking the related delegate method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">Contains information about the event</param>
|
/// <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>
|
/// <summary>
|
||||||
/// Implements the interface method by invoking the related delegate method
|
/// Implements the interface method by invoking the related delegate method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">Contains information about the event</param>
|
/// <param name="context">Contains information about the event</param>
|
||||||
public virtual Task Exception(CookieExceptionContext context) => OnException(context);
|
public virtual Task Exception(CookieExceptionContext context) => OnException(context);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using Microsoft.AspNet.Http.Authentication;
|
||||||
namespace Microsoft.AspNet.Authentication.Cookies
|
namespace Microsoft.AspNet.Authentication.Cookies
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Context object passed to the ICookieAuthenticationEvents method ResponseSignIn.
|
/// Context object passed to the ICookieAuthenticationEvents method SigningIn.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CookieSigningInContext : BaseContext<CookieAuthenticationOptions>
|
public class CookieSigningInContext : BaseContext<CookieAuthenticationOptions>
|
||||||
{
|
{
|
||||||
|
|
@ -43,19 +43,19 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains the claims about to be converted into the outgoing cookie.
|
/// 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>
|
/// </summary>
|
||||||
public ClaimsPrincipal Principal { get; set; }
|
public ClaimsPrincipal Principal { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains the extra data about to be contained in the outgoing cookie.
|
/// 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>
|
/// </summary>
|
||||||
public AuthenticationProperties Properties { get; set; }
|
public AuthenticationProperties Properties { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The options for creating the outgoing cookie.
|
/// 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>
|
/// </summary>
|
||||||
public CookieOptions CookieOptions { get; set; }
|
public CookieOptions CookieOptions { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The options for creating the outgoing cookie.
|
/// 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>
|
/// </summary>
|
||||||
public CookieOptions CookieOptions
|
public CookieOptions CookieOptions
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
using Microsoft.AspNet.Http;
|
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)
|
: base(context, options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -4,11 +4,11 @@
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Http;
|
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)
|
: base(context, options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -4,14 +4,14 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// OpenIdConnect bearer token middleware events.
|
/// OpenIdConnect bearer token middleware events.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IOpenIdConnectBearerEvents
|
public interface IJwtBearerEvents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed.
|
/// 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;
|
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)
|
: base(context, options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -6,14 +6,14 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// OpenIdConnect bearer token middleware events.
|
/// OpenIdConnect bearer token middleware events.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OpenIdConnectBearerEvents : IOpenIdConnectBearerEvents
|
public class JwtBearerEvents : IJwtBearerEvents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed.
|
/// 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;
|
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)
|
: base(context, options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
using Microsoft.AspNet.Http;
|
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)
|
: 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Authentication.OpenIdConnectBearer;
|
using Microsoft.AspNet.Authentication.JwtBearer;
|
||||||
using Microsoft.Framework.Internal;
|
using Microsoft.Framework.Internal;
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extension methods to add OpenIdConnect Bearer authentication capabilities to an HTTP application pipeline
|
/// Extension methods to add OpenIdConnect Bearer authentication capabilities to an HTTP application pipeline
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class OpenIdConnectBearerAppBuilderExtensions
|
public static class JwtBearerAppBuilderExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds Bearer token processing to an HTTP application pipeline. This middleware understands appropriately
|
/// 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="app">The application builder</param>
|
||||||
/// <param name="options">Options which control the processing of the bearer header.</param>
|
/// <param name="options">Options which control the processing of the bearer header.</param>
|
||||||
/// <returns>The application builder</returns>
|
/// <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>
|
/// <summary>
|
||||||
|
|
@ -40,14 +40,14 @@ namespace Microsoft.AspNet.Builder
|
||||||
/// <param name="app">The application builder</param>
|
/// <param name="app">The application builder</param>
|
||||||
/// <param name="configureOptions">Used to configure Middleware options.</param>
|
/// <param name="configureOptions">Used to configure Middleware options.</param>
|
||||||
/// <returns>The application builder</returns>
|
/// <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)
|
if (configureOptions != null)
|
||||||
{
|
{
|
||||||
configureOptions(options);
|
configureOptions(options);
|
||||||
}
|
}
|
||||||
return app.UseOpenIdConnectBearerAuthentication(options);
|
return app.UseJwtBearerAuthentication(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// 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>
|
/// <summary>
|
||||||
/// Default values used by authorization server and bearer authentication.
|
/// Default values used by bearer authentication.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class OpenIdConnectBearerDefaults
|
public static class JwtBearerDefaults
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default value for AuthenticationScheme property in the OpenIdConnectBearerAuthenticationOptions and
|
/// Default value for AuthenticationScheme property in the JwtBearerAuthenticationOptions
|
||||||
/// OpenIdConnectAuthorizationServerOptions.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string AuthenticationScheme = "Bearer";
|
public const string AuthenticationScheme = "Bearer";
|
||||||
}
|
}
|
||||||
|
|
@ -10,9 +10,9 @@ using Microsoft.AspNet.Http.Features.Authentication;
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
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;
|
private OpenIdConnectConfiguration _configuration;
|
||||||
|
|
||||||
|
|
@ -10,30 +10,30 @@ using Microsoft.Framework.WebEncoders;
|
||||||
using Microsoft.IdentityModel.Protocols;
|
using Microsoft.IdentityModel.Protocols;
|
||||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bearer authentication middleware component which is added to an HTTP pipeline. This class is not
|
/// 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.
|
/// extension method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OpenIdConnectBearerMiddleware : AuthenticationMiddleware<OpenIdConnectBearerOptions>
|
public class JwtBearerMiddleware : AuthenticationMiddleware<JwtBearerOptions>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bearer authentication component which is added to an HTTP pipeline. This constructor is not
|
/// 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.
|
/// extension method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public OpenIdConnectBearerMiddleware(
|
public JwtBearerMiddleware(
|
||||||
[NotNull] RequestDelegate next,
|
[NotNull] RequestDelegate next,
|
||||||
[NotNull] ILoggerFactory loggerFactory,
|
[NotNull] ILoggerFactory loggerFactory,
|
||||||
[NotNull] IUrlEncoder encoder,
|
[NotNull] IUrlEncoder encoder,
|
||||||
[NotNull] OpenIdConnectBearerOptions options)
|
[NotNull] JwtBearerOptions options)
|
||||||
: base(next, options, loggerFactory, encoder)
|
: base(next, options, loggerFactory, encoder)
|
||||||
{
|
{
|
||||||
if (Options.Events == null)
|
if (Options.Events == null)
|
||||||
{
|
{
|
||||||
Options.Events = new OpenIdConnectBearerEvents();
|
Options.Events = new JwtBearerEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.Audience))
|
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.
|
/// Called by the AuthenticationMiddleware base class to create a per-request handler.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A new instance of the request handler</returns>
|
/// <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;
|
||||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Options class provides information needed to control Bearer Authentication middleware behavior
|
/// Options class provides information needed to control Bearer Authentication middleware behavior
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OpenIdConnectBearerOptions : AuthenticationOptions
|
public class JwtBearerOptions : AuthenticationOptions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates an instance of bearer authentication options with default values.
|
/// Creates an instance of bearer authentication options with default values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public OpenIdConnectBearerOptions() : base()
|
public JwtBearerOptions() : base()
|
||||||
{
|
{
|
||||||
AuthenticationScheme = OpenIdConnectBearerDefaults.AuthenticationScheme;
|
AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -45,14 +45,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the challenge to put in the "WWW-Authenticate" header.
|
/// Gets or sets the challenge to put in the "WWW-Authenticate" header.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Challenge { get; set; } = OpenIdConnectBearerDefaults.AuthenticationScheme;
|
public string Challenge { get; set; } = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The object provided by the application to process events raised by the bearer authentication middleware.
|
/// 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.
|
/// and assign delegates only to the events it wants to process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IOpenIdConnectBearerEvents Events { get; set; } = new OpenIdConnectBearerEvents();
|
public IJwtBearerEvents Events { get; set; } = new JwtBearerEvents();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The HttpMessageHandler used to retrieve metadata.
|
/// The HttpMessageHandler used to retrieve metadata.
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||||
{
|
{
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||||
internal static class Resources
|
internal static class Resources
|
||||||
{
|
{
|
||||||
private static readonly ResourceManager _resourceManager
|
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>
|
/// <summary>
|
||||||
/// The '{0}' option must be provided.
|
/// The '{0}' option must be provided.
|
||||||
|
|
@ -15,9 +15,9 @@ using Microsoft.AspNet.TestHost;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
namespace Microsoft.AspNet.Authentication.JwtBearer
|
||||||
{
|
{
|
||||||
public class OpenIdConnectBearerMiddlewareTests
|
public class JwtBearerMiddlewareTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task BearerTokenValidation()
|
public async Task BearerTokenValidation()
|
||||||
|
|
@ -66,7 +66,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||||
{
|
{
|
||||||
options.AutomaticAuthentication = true;
|
options.AutomaticAuthentication = true;
|
||||||
|
|
||||||
options.Events = new OpenIdConnectBearerEvents()
|
options.Events = new JwtBearerEvents()
|
||||||
{
|
{
|
||||||
OnMessageReceived = context =>
|
OnMessageReceived = context =>
|
||||||
{
|
{
|
||||||
|
|
@ -116,7 +116,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||||
{
|
{
|
||||||
options.AutomaticAuthentication = true;
|
options.AutomaticAuthentication = true;
|
||||||
|
|
||||||
options.Events = new OpenIdConnectBearerEvents()
|
options.Events = new JwtBearerEvents()
|
||||||
{
|
{
|
||||||
OnSecurityTokenReceived = context =>
|
OnSecurityTokenReceived = context =>
|
||||||
{
|
{
|
||||||
|
|
@ -150,7 +150,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||||
{
|
{
|
||||||
options.AutomaticAuthentication = true;
|
options.AutomaticAuthentication = true;
|
||||||
|
|
||||||
options.Events = new OpenIdConnectBearerEvents()
|
options.Events = new JwtBearerEvents()
|
||||||
{
|
{
|
||||||
OnSecurityTokenValidated = context =>
|
OnSecurityTokenValidated = context =>
|
||||||
{
|
{
|
||||||
|
|
@ -187,7 +187,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||||
{
|
{
|
||||||
options.AutomaticAuthentication = true;
|
options.AutomaticAuthentication = true;
|
||||||
|
|
||||||
options.Events = new OpenIdConnectBearerEvents()
|
options.Events = new JwtBearerEvents()
|
||||||
{
|
{
|
||||||
OnMessageReceived = context =>
|
OnMessageReceived = context =>
|
||||||
{
|
{
|
||||||
|
|
@ -224,7 +224,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||||
{
|
{
|
||||||
var server = CreateServer(options =>
|
var server = CreateServer(options =>
|
||||||
{
|
{
|
||||||
options.Events = new OpenIdConnectBearerEvents()
|
options.Events = new JwtBearerEvents()
|
||||||
{
|
{
|
||||||
OnSecurityTokenReceived = context =>
|
OnSecurityTokenReceived = context =>
|
||||||
{
|
{
|
||||||
|
|
@ -255,7 +255,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||||
{
|
{
|
||||||
var server = CreateServer(options =>
|
var server = CreateServer(options =>
|
||||||
{
|
{
|
||||||
options.Events = new OpenIdConnectBearerEvents()
|
options.Events = new JwtBearerEvents()
|
||||||
{
|
{
|
||||||
OnSecurityTokenReceived = context =>
|
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 =>
|
return TestServer.Create(app =>
|
||||||
{
|
{
|
||||||
if (configureOptions != null)
|
if (configureOptions != null)
|
||||||
{
|
{
|
||||||
app.UseOpenIdConnectBearerAuthentication(configureOptions);
|
app.UseJwtBearerAuthentication(configureOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Use(async (context, next) =>
|
app.Use(async (context, next) =>
|
||||||
|
|
@ -359,17 +359,17 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
|
||||||
else if (context.Request.Path == new PathString("/unauthorized"))
|
else if (context.Request.Path == new PathString("/unauthorized"))
|
||||||
{
|
{
|
||||||
// Simulate Authorization failure
|
// Simulate Authorization failure
|
||||||
var result = await context.Authentication.AuthenticateAsync(OpenIdConnectBearerDefaults.AuthenticationScheme);
|
var result = await context.Authentication.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme);
|
||||||
await context.Authentication.ChallengeAsync(OpenIdConnectBearerDefaults.AuthenticationScheme);
|
await context.Authentication.ChallengeAsync(JwtBearerDefaults.AuthenticationScheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (context.Request.Path == new PathString("/signIn"))
|
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"))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-*",
|
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-*",
|
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Authentication.Google": "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.MicrosoftAccount": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*",
|
"Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-*",
|
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-*",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue