diff --git a/NuGet.config b/NuGet.config
index 3bd1c73d64..3cca57b4c2 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -1,8 +1,8 @@
-
+
-
+
diff --git a/Security.sln b/Security.sln
index ee8180ede8..61a335c030 100644
--- a/Security.sln
+++ b/Security.sln
@@ -40,7 +40,7 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentica
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.Test", "test\Microsoft.AspNet.Authentication.Test\Microsoft.AspNet.Authentication.Test.xproj", "{8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.JwtBearer", "src\Microsoft.AspNet.Authentication.JwtBearer\Microsoft.AspNet.Authentication.JwtBearer.xproj", "{2755BFE5-7421-4A31-A644-F817DF5CAA98}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.OpenIdConnectBearer", "src\Microsoft.AspNet.Authentication.JwtBearer\Microsoft.AspNet.Authentication.OpenIdConnectBearer.xproj", "{2755BFE5-7421-4A31-A644-F817DF5CAA98}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authorization.Test", "test\Microsoft.AspNet.Authorization.Test\Microsoft.AspNet.Authorization.Test.xproj", "{7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}"
EndProject
diff --git a/samples/CookieSessionSample/MemoryCacheSessionStore.cs b/samples/CookieSessionSample/MemoryCacheSessionStore.cs
index 854b40fb20..d0e78d1367 100644
--- a/samples/CookieSessionSample/MemoryCacheSessionStore.cs
+++ b/samples/CookieSessionSample/MemoryCacheSessionStore.cs
@@ -6,7 +6,7 @@ using Microsoft.Framework.Caching.Memory;
namespace CookieSessionSample
{
- public class MemoryCacheSessionStore : IAuthenticationSessionStore
+ public class MemoryCacheSessionStore : ITicketStore
{
private const string KeyPrefix = "AuthSessionStore-";
private IMemoryCache _cache;
diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs
index ee397f272c..7e43f83f24 100644
--- a/samples/SocialSample/Startup.cs
+++ b/samples/SocialSample/Startup.cs
@@ -130,7 +130,7 @@ namespace CookieSample
// Retrieving user information is unique to each provider.
Events = new OAuthEvents
{
- OnAuthenticated = async context =>
+ OnCreatingTicket = async context =>
{
// Get the GitHub user
var request = new HttpRequestMessage(HttpMethod.Get, context.Options.UserInformationEndpoint);
diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs
index 24fe12fbe8..4c83699f5d 100644
--- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs
@@ -225,7 +225,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
{
var cookieOptions = BuildCookieOptions();
- var signInContext = new CookieResponseSignInContext(
+ var signInContext = new CookieSigningInContext(
Context,
Options,
Options.AuthenticationScheme,
@@ -249,7 +249,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.ExpireTimeSpan);
}
- await Options.Events.ResponseSignIn(signInContext);
+ await Options.Events.SigningIn(signInContext);
if (signInContext.Properties.IsPersistent)
{
@@ -279,14 +279,14 @@ namespace Microsoft.AspNet.Authentication.Cookies
cookieValue,
signInContext.CookieOptions);
- var signedInContext = new CookieResponseSignedInContext(
+ var signedInContext = new CookieSignedInContext(
Context,
Options,
Options.AuthenticationScheme,
signInContext.Principal,
signInContext.Properties);
- await Options.Events.ResponseSignedIn(signedInContext);
+ await Options.Events.SignedIn(signedInContext);
var shouldLoginRedirect = Options.LoginPath.HasValue && OriginalPath == Options.LoginPath;
ApplyHeaders(shouldLoginRedirect);
@@ -314,12 +314,12 @@ namespace Microsoft.AspNet.Authentication.Cookies
await Options.SessionStore.RemoveAsync(_sessionKey);
}
- var context = new CookieResponseSignOutContext(
+ var context = new CookieSigningOutContext(
Context,
Options,
cookieOptions);
- await Options.Events.ResponseSignOut(context);
+ await Options.Events.SigningOut(context);
Options.CookieManager.DeleteCookie(
Context,
diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs
index b8743d1843..1a1f71bd40 100644
--- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs
+++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs
@@ -146,7 +146,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
/// An optional container in which to store the identity across requests. When used, only a session identifier is sent
/// to the client. This can be used to mitigate potential problems with very large identities.
///
- public IAuthenticationSessionStore SessionStore { get; set; }
+ public ITicketStore SessionStore { get; set; }
CookieAuthenticationOptions IOptions.Value
{
diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieAuthenticationEvents.cs
index 7a96ce99d0..578feb1ca4 100644
--- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieAuthenticationEvents.cs
+++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieAuthenticationEvents.cs
@@ -21,17 +21,17 @@ namespace Microsoft.AspNet.Authentication.Cookies
///
/// A delegate assigned to this property will be invoked when the related method is called
///
- public Func OnResponseSignIn { get; set; } = context => Task.FromResult(0);
+ public Func OnSigningIn { get; set; } = context => Task.FromResult(0);
///
/// A delegate assigned to this property will be invoked when the related method is called
///
- public Func OnResponseSignedIn { get; set; } = context => Task.FromResult(0);
+ public Func OnSignedIn { get; set; } = context => Task.FromResult(0);
///
/// A delegate assigned to this property will be invoked when the related method is called
///
- public Func OnResponseSignOut { get; set; } = context => Task.FromResult(0);
+ public Func OnSigningOut { get; set; } = context => Task.FromResult(0);
///
/// A delegate assigned to this property will be invoked when the related method is called
@@ -58,19 +58,19 @@ namespace Microsoft.AspNet.Authentication.Cookies
/// Implements the interface method by invoking the related delegate method
///
///
- public virtual Task ResponseSignIn(CookieResponseSignInContext context) => OnResponseSignIn(context);
+ public virtual Task SigningIn(CookieSigningInContext context) => OnSigningIn(context);
///
/// Implements the interface method by invoking the related delegate method
///
///
- public virtual Task ResponseSignedIn(CookieResponseSignedInContext context) => OnResponseSignedIn(context);
+ public virtual Task SignedIn(CookieSignedInContext context) => OnSignedIn(context);
///
/// Implements the interface method by invoking the related delegate method
///
///
- public virtual Task ResponseSignOut(CookieResponseSignOutContext context) => OnResponseSignOut(context);
+ public virtual Task SigningOut(CookieSigningOutContext context) => OnSigningOut(context);
///
/// Implements the interface method by invoking the related delegate method
diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieResponseSignedInContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs
similarity index 92%
rename from src/Microsoft.AspNet.Authentication.Cookies/Events/CookieResponseSignedInContext.cs
rename to src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs
index a6a5c3469e..d8ac62a24e 100644
--- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieResponseSignedInContext.cs
+++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs
@@ -8,9 +8,9 @@ using Microsoft.AspNet.Http.Authentication;
namespace Microsoft.AspNet.Authentication.Cookies
{
///
- /// Context object passed to the ICookieAuthenticationEvents method ResponseSignedIn.
+ /// Context object passed to the ICookieAuthenticationEvents method SignedIn.
///
- public class CookieResponseSignedInContext : BaseContext
+ public class CookieSignedInContext : BaseContext
{
///
/// Creates a new instance of the context object.
@@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
/// Initializes AuthenticationScheme property
/// Initializes Principal property
/// Initializes Properties property
- public CookieResponseSignedInContext(
+ public CookieSignedInContext(
HttpContext context,
CookieAuthenticationOptions options,
string authenticationScheme,
diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieResponseSignInContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs
similarity index 91%
rename from src/Microsoft.AspNet.Authentication.Cookies/Events/CookieResponseSignInContext.cs
rename to src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs
index b931a7c484..4ff477b8f3 100644
--- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieResponseSignInContext.cs
+++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs
@@ -8,9 +8,9 @@ using Microsoft.AspNet.Http.Authentication;
namespace Microsoft.AspNet.Authentication.Cookies
{
///
- /// Context object passed to the ICookieAuthenticationProvider method ResponseSignIn.
+ /// Context object passed to the ICookieAuthenticationEvents method ResponseSignIn.
///
- public class CookieResponseSignInContext : BaseContext
+ public class CookieSigningInContext : BaseContext
{
///
/// Creates a new instance of the context object.
@@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
/// Initializes Principal property
/// Initializes Extra property
/// Initializes options for the authentication cookie.
- public CookieResponseSignInContext(
+ public CookieSigningInContext(
HttpContext context,
CookieAuthenticationOptions options,
string authenticationScheme,
diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieResponseSignOutContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs
similarity index 73%
rename from src/Microsoft.AspNet.Authentication.Cookies/Events/CookieResponseSignOutContext.cs
rename to src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs
index f33295af57..d9e960ada9 100644
--- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieResponseSignOutContext.cs
+++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs
@@ -6,9 +6,9 @@ using Microsoft.AspNet.Http;
namespace Microsoft.AspNet.Authentication.Cookies
{
///
- /// Context object passed to the ICookieAuthenticationProvider method ResponseSignOut
+ /// Context object passed to the ICookieAuthenticationEvents method SigningOut
///
- public class CookieResponseSignOutContext : BaseContext
+ public class CookieSigningOutContext : BaseContext
{
///
///
@@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
///
///
///
- public CookieResponseSignOutContext(HttpContext context, CookieAuthenticationOptions options, CookieOptions cookieOptions)
+ public CookieSigningOutContext(HttpContext context, CookieAuthenticationOptions options, CookieOptions cookieOptions)
: base(context, options)
{
CookieOptions = cookieOptions;
diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs
index fef97c6916..9a74f657d9 100644
--- a/src/Microsoft.AspNet.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs
+++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs
@@ -23,13 +23,13 @@ namespace Microsoft.AspNet.Authentication.Cookies
/// implementing this method the claims and extra information that go into the ticket may be altered.
///
/// Contains information about the login session as well as the user .
- Task ResponseSignIn(CookieResponseSignInContext context);
+ Task SigningIn(CookieSigningInContext context);
///
/// Called when an endpoint has provided sign in information after it is converted into a cookie.
///
/// Contains information about the login session as well as the user .
- Task ResponseSignedIn(CookieResponseSignedInContext context);
+ Task SignedIn(CookieSignedInContext context);
///
/// Called when a Challenge, SignIn, or SignOut causes a redirect in the cookie middleware
@@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
/// Called during the sign-out flow to augment the cookie cleanup process.
///
/// Contains information about the login session as well as information about the authentication cookie.
- Task ResponseSignOut(CookieResponseSignOutContext context);
+ Task SigningOut(CookieSigningOutContext context);
///
/// Called when an exception occurs during request or response processing.
diff --git a/src/Microsoft.AspNet.Authentication.Cookies/IAuthenticationSessionStore.cs b/src/Microsoft.AspNet.Authentication.Cookies/ITicketStore.cs
similarity index 97%
rename from src/Microsoft.AspNet.Authentication.Cookies/IAuthenticationSessionStore.cs
rename to src/Microsoft.AspNet.Authentication.Cookies/ITicketStore.cs
index 25de38de11..418dec45e4 100644
--- a/src/Microsoft.AspNet.Authentication.Cookies/IAuthenticationSessionStore.cs
+++ b/src/Microsoft.AspNet.Authentication.Cookies/ITicketStore.cs
@@ -9,7 +9,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
/// while only sending a simple identifier key to the client. This is most commonly used to mitigate
/// issues with serializing large identities into cookies.
///
- public interface IAuthenticationSessionStore
+ public interface ITicketStore
{
///
/// Store the identity ticket and return the associated key.
diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs
index ee6824b451..cd6c2d1f73 100644
--- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs
@@ -62,7 +62,7 @@ namespace Microsoft.AspNet.Authentication.Facebook
var payload = JObject.Parse(await response.Content.ReadAsStringAsync());
- var context = new OAuthAuthenticatedContext(Context, Options, Backchannel, tokens, payload)
+ var context = new OAuthCreatingTicketContext(Context, Options, Backchannel, tokens, payload)
{
Properties = properties,
Principal = new ClaimsPrincipal(identity)
@@ -104,7 +104,7 @@ namespace Microsoft.AspNet.Authentication.Facebook
identity.AddClaim(new Claim("urn:facebook:link", link, ClaimValueTypes.String, Options.ClaimsIssuer));
}
- await Options.Events.Authenticated(context);
+ await Options.Events.CreatingTicket(context);
return new AuthenticationTicket(context.Principal, context.Properties, context.Options.AuthenticationScheme);
}
diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs
index e688dc8562..1d692b4549 100644
--- a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs
@@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Authentication.Google
var payload = JObject.Parse(await response.Content.ReadAsStringAsync());
- var context = new OAuthAuthenticatedContext(Context, Options, Backchannel, tokens, payload)
+ var context = new OAuthCreatingTicketContext(Context, Options, Backchannel, tokens, payload)
{
Properties = properties,
Principal = new ClaimsPrincipal(identity)
@@ -74,7 +74,7 @@ namespace Microsoft.AspNet.Authentication.Google
identity.AddClaim(new Claim("urn:google:profile", profile, ClaimValueTypes.String, Options.ClaimsIssuer));
}
- await Options.Events.Authenticated(context);
+ await Options.Events.CreatingTicket(context);
return new AuthenticationTicket(context.Principal, context.Properties, context.Options.AuthenticationScheme);
}
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationChallengeContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationChallengeContext.cs
index 44f44d5b3e..e7b0df4ef8 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationChallengeContext.cs
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationChallengeContext.cs
@@ -3,11 +3,11 @@
using Microsoft.AspNet.Http;
-namespace Microsoft.AspNet.Authentication.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
- public class AuthenticationChallengeContext : BaseControlContext
+ public class AuthenticationChallengeContext : BaseControlContext
{
- public AuthenticationChallengeContext(HttpContext context, JwtBearerOptions options)
+ public AuthenticationChallengeContext(HttpContext context, OpenIdConnectBearerOptions options)
: base(context, options)
{
}
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs
index 2ac80c4f73..e894ed2a14 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/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.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
- public class AuthenticationFailedContext : BaseControlContext
+ public class AuthenticationFailedContext : BaseControlContext
{
- public AuthenticationFailedContext(HttpContext context, JwtBearerOptions options)
+ public AuthenticationFailedContext(HttpContext context, OpenIdConnectBearerOptions options)
: base(context, options)
{
}
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/IJwtBearerEvents.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/IOpenIdConnectBearerEvents.cs
similarity index 80%
rename from src/Microsoft.AspNet.Authentication.JwtBearer/Events/IJwtBearerEvents.cs
rename to src/Microsoft.AspNet.Authentication.JwtBearer/Events/IOpenIdConnectBearerEvents.cs
index 0ec2a9c247..973b5c9178 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/IJwtBearerEvents.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.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
///
- /// Jwt bearer token middleware events.
+ /// OpenIdConnect bearer token middleware events.
///
- public interface IJwtBearerEvents
+ public interface IOpenIdConnectBearerEvents
{
///
/// 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.JwtBearer/Events/MessageReceivedContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/MessageReceivedContext.cs
index cd940ef679..5b28b109ae 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/MessageReceivedContext.cs
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/MessageReceivedContext.cs
@@ -3,11 +3,11 @@
using Microsoft.AspNet.Http;
-namespace Microsoft.AspNet.Authentication.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
- public class MessageReceivedContext : BaseControlContext
+ public class MessageReceivedContext : BaseControlContext
{
- public MessageReceivedContext(HttpContext context, JwtBearerOptions options)
+ public MessageReceivedContext(HttpContext context, OpenIdConnectBearerOptions options)
: base(context, options)
{
}
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/OpenIdConnectBearerEvents.cs
similarity index 87%
rename from src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.cs
rename to src/Microsoft.AspNet.Authentication.JwtBearer/Events/OpenIdConnectBearerEvents.cs
index a6976228cd..e53dbd8bc1 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.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.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
///
- /// Jwt bearer token middleware events.
+ /// OpenIdConnect bearer token middleware events.
///
- public class JwtBearerEvents : IJwtBearerEvents
+ public class OpenIdConnectBearerEvents : IOpenIdConnectBearerEvents
{
///
/// 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.JwtBearer/Events/SecurityTokenReceivedContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenReceivedContext.cs
index 5aedda1d84..81ec1522c6 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenReceivedContext.cs
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenReceivedContext.cs
@@ -3,11 +3,11 @@
using Microsoft.AspNet.Http;
-namespace Microsoft.AspNet.Authentication.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
- public class SecurityTokenReceivedContext : BaseControlContext
+ public class SecurityTokenReceivedContext : BaseControlContext
{
- public SecurityTokenReceivedContext(HttpContext context, JwtBearerOptions options)
+ public SecurityTokenReceivedContext(HttpContext context, OpenIdConnectBearerOptions options)
: base(context, options)
{
}
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenValidatedContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenValidatedContext.cs
index 488e8e6b02..78f3a81f4e 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenValidatedContext.cs
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/SecurityTokenValidatedContext.cs
@@ -3,11 +3,11 @@
using Microsoft.AspNet.Http;
-namespace Microsoft.AspNet.Authentication.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
- public class SecurityTokenValidatedContext : BaseControlContext
+ public class SecurityTokenValidatedContext : BaseControlContext
{
- public SecurityTokenValidatedContext(HttpContext context, JwtBearerOptions options)
+ public SecurityTokenValidatedContext(HttpContext context, OpenIdConnectBearerOptions options)
: base(context, options)
{
}
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.JwtBearer.xproj b/src/Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.OpenIdConnectBearer.xproj
similarity index 100%
rename from src/Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.JwtBearer.xproj
rename to src/Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.OpenIdConnectBearer.xproj
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerAppBuilderExtensions.cs
similarity index 74%
rename from src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs
rename to src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerAppBuilderExtensions.cs
index 55f6cb5b2b..148d3d892c 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerAppBuilderExtensions.cs
@@ -2,16 +2,16 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Microsoft.AspNet.Authentication.JwtBearer;
+using Microsoft.AspNet.Authentication.OpenIdConnectBearer;
using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Builder
{
///
- /// Extension methods to add Jwt Bearer authentication capabilities to an HTTP application pipeline
+ /// Extension methods to add OpenIdConnect Bearer authentication capabilities to an HTTP application pipeline
///
- public static class JwtBearerAppBuilderExtensions
+ public static class OpenIdConnectBearerAppBuilderExtensions
{
///
/// 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 UseJwtBearerAuthentication([NotNull] this IApplicationBuilder app, [NotNull] JwtBearerOptions options)
+ public static IApplicationBuilder UseOpenIdConnectBearerAuthentication([NotNull] this IApplicationBuilder app, [NotNull] OpenIdConnectBearerOptions 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 UseJwtBearerAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions)
+ public static IApplicationBuilder UseOpenIdConnectBearerAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions)
{
- var options = new JwtBearerOptions();
+ var options = new OpenIdConnectBearerOptions();
if (configureOptions != null)
{
configureOptions(options);
}
- return app.UseJwtBearerAuthentication(options);
+ return app.UseOpenIdConnectBearerAuthentication(options);
}
}
}
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerDefaults.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerDefaults.cs
similarity index 68%
rename from src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerDefaults.cs
rename to src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerDefaults.cs
index c39bf6cb9e..b271709f98 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerDefaults.cs
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerDefaults.cs
@@ -1,16 +1,16 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-namespace Microsoft.AspNet.Authentication.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
///
/// Default values used by authorization server and bearer authentication.
///
- public static class JwtBearerDefaults
+ public static class OpenIdConnectBearerDefaults
{
///
- /// Default value for AuthenticationScheme property in the JwtBearerAuthenticationOptions and
- /// JwtAuthorizationServerOptions.
+ /// Default value for AuthenticationScheme property in the OpenIdConnectBearerAuthenticationOptions and
+ /// OpenIdConnectAuthorizationServerOptions.
///
public const string AuthenticationScheme = "Bearer";
}
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerHandler.cs
similarity index 97%
rename from src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs
rename to src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerHandler.cs
index 0f420f7fc4..9a84dcfb36 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerHandler.cs
@@ -10,9 +10,9 @@ using Microsoft.AspNet.Http.Features.Authentication;
using Microsoft.Framework.Logging;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
-namespace Microsoft.AspNet.Authentication.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
- public class JwtBearerHandler : AuthenticationHandler
+ internal class OpenIdConnectBearerHandler : AuthenticationHandler
{
private OpenIdConnectConfiguration _configuration;
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerMiddleware.cs
similarity index 83%
rename from src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs
rename to src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerMiddleware.cs
index 0c67c632e7..fee6e11430 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerMiddleware.cs
@@ -6,35 +6,34 @@ using System.Net.Http;
using Microsoft.AspNet.Builder;
using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging;
-using Microsoft.Framework.OptionsModel;
using Microsoft.Framework.WebEncoders;
using Microsoft.IdentityModel.Protocols;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
-namespace Microsoft.AspNet.Authentication.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
///
/// 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 UseJwtBearerAuthentication
+ /// created by application code directly, instead it is added by calling the the IAppBuilder UseOpenIdConnectBearerAuthentication
/// extension method.
///
- public class JwtBearerMiddleware : AuthenticationMiddleware
+ public class OpenIdConnectBearerMiddleware : 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 UseJwtBearerAuthentication
+ /// called by application code directly, instead it is added by calling the the IAppBuilder UseOpenIdConnectBearerAuthentication
/// extension method.
///
- public JwtBearerMiddleware(
+ public OpenIdConnectBearerMiddleware(
[NotNull] RequestDelegate next,
[NotNull] ILoggerFactory loggerFactory,
[NotNull] IUrlEncoder encoder,
- [NotNull] JwtBearerOptions options)
+ [NotNull] OpenIdConnectBearerOptions options)
: base(next, options, loggerFactory, encoder)
{
if (Options.Events == null)
{
- Options.Events = new JwtBearerEvents();
+ Options.Events = new OpenIdConnectBearerEvents();
}
if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.Audience))
@@ -74,9 +73,9 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
/// 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 JwtBearerHandler();
+ return new OpenIdConnectBearerHandler();
}
}
}
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerOptions.cs
similarity index 86%
rename from src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs
rename to src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerOptions.cs
index a6df42ec6b..f47a436ee0 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/OpenIdConnectBearerOptions.cs
@@ -9,19 +9,19 @@ using System.Net.Http;
using Microsoft.IdentityModel.Protocols;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
-namespace Microsoft.AspNet.Authentication.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
///
/// Options class provides information needed to control Bearer Authentication middleware behavior
///
- public class JwtBearerOptions : AuthenticationOptions
+ public class OpenIdConnectBearerOptions : AuthenticationOptions
{
///
/// Creates an instance of bearer authentication options with default values.
///
- public JwtBearerOptions() : base()
+ public OpenIdConnectBearerOptions() : base()
{
- AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme;
+ AuthenticationScheme = OpenIdConnectBearerDefaults.AuthenticationScheme;
}
///
@@ -35,24 +35,24 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
public string Authority { get; set; }
///
- /// Gets or sets the audience for any received JWT token.
+ /// Gets or sets the audience for any received OpenIdConnect token.
///
///
- /// The expected audience for any received JWT token.
+ /// The expected audience for any received OpenIdConnect token.
///
public string Audience { get; set; }
///
/// Gets or sets the challenge to put in the "WWW-Authenticate" header.
///
- public string Challenge { get; set; } = JwtBearerDefaults.AuthenticationScheme;
+ public string Challenge { get; set; } = OpenIdConnectBearerDefaults.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 JwtBearerAuthenticationEvents
+ /// The application may implement the interface fully, or it may create an instance of OpenIdConnectBearerAuthenticationEvents
/// and assign delegates only to the events it wants to process.
///
- public IJwtBearerEvents Events { get; set; } = new JwtBearerEvents();
+ public IOpenIdConnectBearerEvents Events { get; set; } = new OpenIdConnectBearerEvents();
///
/// The HttpMessageHandler used to retrieve metadata.
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Properties/Resources.Designer.cs
index 79bbbe4497..bafcd6d0d6 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/Properties/Resources.Designer.cs
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Properties/Resources.Designer.cs
@@ -1,5 +1,5 @@
//
-namespace Microsoft.AspNet.Authentication.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
using System.Globalization;
using System.Reflection;
@@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
internal static class Resources
{
private static readonly ResourceManager _resourceManager
- = new ResourceManager("Microsoft.AspNet.Authentication.JwtBearer.Resources", typeof(Resources).GetTypeInfo().Assembly);
+ = new ResourceManager("Microsoft.AspNet.Authentication.OpenIdConnectBearer.Resources", typeof(Resources).GetTypeInfo().Assembly);
///
/// The '{0}' option must be provided.
diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/project.json b/src/Microsoft.AspNet.Authentication.JwtBearer/project.json
index f92c6b6f4a..f05599e083 100644
--- a/src/Microsoft.AspNet.Authentication.JwtBearer/project.json
+++ b/src/Microsoft.AspNet.Authentication.JwtBearer/project.json
@@ -1,6 +1,6 @@
{
"version": "1.0.0-*",
- "description": "ASP.NET 5 middleware that enables an application to receive a Jwt bearer token.",
+ "description": "ASP.NET 5 middleware that enables an application to receive a OpenIdConnect bearer token.",
"repository": {
"type": "git",
"url": "git://github.com/aspnet/security"
diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs
index adac9be9dc..940b115444 100644
--- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs
@@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount
var payload = JObject.Parse(await response.Content.ReadAsStringAsync());
- var context = new OAuthAuthenticatedContext(Context, Options, Backchannel, tokens, payload)
+ var context = new OAuthCreatingTicketContext(Context, Options, Backchannel, tokens, payload)
{
Properties = properties,
Principal = new ClaimsPrincipal(identity)
@@ -54,7 +54,7 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount
identity.AddClaim(new Claim(ClaimTypes.Email, email, ClaimValueTypes.String, Options.ClaimsIssuer));
}
- await Options.Events.Authenticated(context);
+ await Options.Events.CreatingTicket(context);
return new AuthenticationTicket(context.Principal, context.Properties, context.Options.AuthenticationScheme);
}
diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/IOAuthEvents.cs b/src/Microsoft.AspNet.Authentication.OAuth/Events/IOAuthEvents.cs
index d5acd3bbca..9f161f344c 100644
--- a/src/Microsoft.AspNet.Authentication.OAuth/Events/IOAuthEvents.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/IOAuthEvents.cs
@@ -16,19 +16,19 @@ namespace Microsoft.AspNet.Authentication.OAuth
///
/// Contains information about the login session.
/// A representing the completed operation.
- Task Authenticated(OAuthAuthenticatedContext context);
+ Task CreatingTicket(OAuthCreatingTicketContext context);
///
/// Invoked prior to the being saved in a local cookie and the browser being redirected to the originally requested URL.
///
///
/// A representing the completed operation.
- Task ReturnEndpoint(OAuthReturnEndpointContext context);
+ Task SigningIn(SigningInContext context);
///
/// Called when a Challenge causes a redirect to the authorize endpoint.
///
/// Contains redirect URI and of the challenge.
- Task ApplyRedirect(OAuthApplyRedirectContext context);
+ Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationEndpointContext context);
}
}
diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthAuthenticatedContext.cs b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthAuthenticatedContext.cs
index 3aa4f8b6a8..2bbacbfd2e 100644
--- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthAuthenticatedContext.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthAuthenticatedContext.cs
@@ -15,16 +15,16 @@ namespace Microsoft.AspNet.Authentication.OAuth
///
/// Contains information about the login session as well as the user .
///
- public class OAuthAuthenticatedContext : BaseContext
+ public class OAuthCreatingTicketContext : BaseContext
{
///
- /// Initializes a new .
+ /// Initializes a new .
///
/// The HTTP environment.
/// The options used by the authentication middleware.
/// The HTTP client used by the authentication middleware
/// The tokens returned from the token endpoint.
- public OAuthAuthenticatedContext(
+ public OAuthCreatingTicketContext(
[NotNull] HttpContext context,
[NotNull] OAuthOptions options,
[NotNull] HttpClient backchannel,
@@ -34,14 +34,14 @@ namespace Microsoft.AspNet.Authentication.OAuth
}
///
- /// Initializes a new .
+ /// Initializes a new .
///
/// The HTTP environment.
/// The options used by the authentication middleware.
/// The HTTP client used by the authentication middleware
/// The tokens returned from the token endpoint.
/// The JSON-serialized user.
- public OAuthAuthenticatedContext(
+ public OAuthCreatingTicketContext(
[NotNull] HttpContext context,
[NotNull] OAuthOptions options,
[NotNull] HttpClient backchannel,
diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthEvents.cs b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthEvents.cs
index 9f8e064ae4..364d6c2edf 100644
--- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthEvents.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthEvents.cs
@@ -14,17 +14,17 @@ namespace Microsoft.AspNet.Authentication.OAuth
///
/// Gets or sets the function that is invoked when the Authenticated method is invoked.
///
- public Func OnAuthenticated { get; set; } = context => Task.FromResult(0);
+ public Func OnCreatingTicket { get; set; } = context => Task.FromResult(0);
///
/// Gets or sets the function that is invoked when the ReturnEndpoint method is invoked.
///
- public Func OnReturnEndpoint { get; set; } = context => Task.FromResult(0);
+ public Func OnSigningIn { get; set; } = context => Task.FromResult(0);
///
- /// Gets or sets the delegate that is invoked when the ApplyRedirect method is invoked.
+ /// Gets or sets the delegate that is invoked when the RedirectToAuthorizationEndpoint method is invoked.
///
- public Func OnApplyRedirect { get; set; } = context =>
+ public Func OnRedirectToAuthorizationEndpoint { get; set; } = context =>
{
context.Response.Redirect(context.RedirectUri);
return Task.FromResult(0);
@@ -35,19 +35,19 @@ namespace Microsoft.AspNet.Authentication.OAuth
///
/// Contains information about the login session as well as the user .
/// A representing the completed operation.
- public virtual Task Authenticated(OAuthAuthenticatedContext context) => OnAuthenticated(context);
+ public virtual Task CreatingTicket(OAuthCreatingTicketContext context) => OnCreatingTicket(context);
///
/// Invoked prior to the being saved in a local cookie and the browser being redirected to the originally requested URL.
///
/// Contains information about the login session as well as the user
/// A representing the completed operation.
- public virtual Task ReturnEndpoint(OAuthReturnEndpointContext context) => OnReturnEndpoint(context);
+ public virtual Task SigningIn(SigningInContext context) => OnSigningIn(context);
///
/// Called when a Challenge causes a redirect to authorize endpoint in the OAuth middleware.
///
/// Contains redirect URI and of the challenge.
- public virtual Task ApplyRedirect(OAuthApplyRedirectContext context) => OnApplyRedirect(context);
+ public virtual Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationEndpointContext context) => OnRedirectToAuthorizationEndpoint(context);
}
}
diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthApplyRedirectContext.cs b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRedirectToAuthorizationEndpointContext.cs
similarity index 80%
rename from src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthApplyRedirectContext.cs
rename to src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRedirectToAuthorizationEndpointContext.cs
index 83629708f8..0bfbd26f7b 100644
--- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthApplyRedirectContext.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRedirectToAuthorizationEndpointContext.cs
@@ -7,9 +7,9 @@ using Microsoft.AspNet.Http.Authentication;
namespace Microsoft.AspNet.Authentication.OAuth
{
///
- /// Context passed when a Challenge causes a redirect to authorize endpoint in the Microsoft account middleware.
+ /// Context passed when a Challenge causes a redirect to authorize endpoint in the middleware.
///
- public class OAuthApplyRedirectContext : BaseContext
+ public class OAuthRedirectToAuthorizationEndpointContext : BaseContext
{
///
/// Creates a new context object.
@@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Authentication.OAuth
/// The HTTP request context.
/// The authentication properties of the challenge.
/// The initial redirect URI.
- public OAuthApplyRedirectContext(HttpContext context, OAuthOptions options, AuthenticationProperties properties, string redirectUri)
+ public OAuthRedirectToAuthorizationEndpointContext(HttpContext context, OAuthOptions options, AuthenticationProperties properties, string redirectUri)
: base(context, options)
{
RedirectUri = redirectUri;
diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRequestTokenContext.cs b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRequestTokenContext.cs
deleted file mode 100644
index 54a3dac80a..0000000000
--- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRequestTokenContext.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.AspNet.Http;
-
-namespace Microsoft.AspNet.Authentication.OAuth
-{
- ///
- /// Specifies the HTTP request header for the bearer authentication scheme.
- ///
- public class OAuthRequestTokenContext : BaseContext
- {
- ///
- /// Initializes a new
- ///
- /// HTTP environment
- /// The authorization header value.
- public OAuthRequestTokenContext(
- HttpContext context,
- string token)
- : base(context)
- {
- Token = token;
- }
-
- ///
- /// The authorization header value
- ///
- public string Token { get; set; }
- }
-}
diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthReturnEndpointContext.cs b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthReturnEndpointContext.cs
index dcf9f2d366..2c59fdd183 100644
--- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthReturnEndpointContext.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthReturnEndpointContext.cs
@@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.OAuth
///
/// Provides context information to middleware providers.
///
- public class OAuthReturnEndpointContext : ReturnEndpointContext
+ public class OAuthReturnEndpointContext : SigningInContext
{
///
/// Initializes a new .
diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs
index 7a9e636916..8449d75d23 100644
--- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs
@@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Authentication.OAuth
};
ticket.Properties.RedirectUri = null;
- await Options.Events.ReturnEndpoint(context);
+ await Options.Events.SigningIn(context);
if (context.SignInScheme != null && context.Principal != null)
{
@@ -183,13 +183,13 @@ namespace Microsoft.AspNet.Authentication.OAuth
protected virtual async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens)
{
- var context = new OAuthAuthenticatedContext(Context, Options, Backchannel, tokens)
+ var context = new OAuthCreatingTicketContext(Context, Options, Backchannel, tokens)
{
Principal = new ClaimsPrincipal(identity),
Properties = properties
};
- await Options.Events.Authenticated(context);
+ await Options.Events.CreatingTicket(context);
if (context.Principal?.Identity == null)
{
@@ -212,10 +212,10 @@ namespace Microsoft.AspNet.Authentication.OAuth
var authorizationEndpoint = BuildChallengeUrl(properties, BuildRedirectUri(Options.CallbackPath));
- var redirectContext = new OAuthApplyRedirectContext(
+ var redirectContext = new OAuthRedirectToAuthorizationEndpointContext(
Context, Options,
properties, authorizationEndpoint);
- await Options.Events.ApplyRedirect(redirectContext);
+ await Options.Events.RedirectToAuthorizationEndpoint(redirectContext);
return true;
}
@@ -263,7 +263,7 @@ namespace Microsoft.AspNet.Authentication.OAuth
var nonceBytes = new byte[32];
CryptoRandom.GetBytes(nonceBytes);
- var correlationId = TextEncodings.Base64Url.Encode(nonceBytes);
+ var correlationId = Base64UrlTextEncoder.Encode(nonceBytes);
var cookieOptions = new CookieOptions
{
diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs
index 9f1ea06519..ad4d927208 100644
--- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs
@@ -160,7 +160,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
// order for local RedirectUri
// 1. challenge.Properties.RedirectUri
// 2. CurrentUri if Options.DefaultToCurrentUriOnRedirect is true)
- AuthenticationProperties properties = new AuthenticationProperties(context.Properties);
+ var properties = new AuthenticationProperties(context.Properties);
if (!string.IsNullOrEmpty(properties.RedirectUri))
{
@@ -491,7 +491,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
ticket = ValidateToken(tokenEndpointResponse.ProtocolMessage.IdToken, message, properties, validationParameters, out jwt);
- await ValidateOpenIdConnectProtocolAsync(null, message);
+ ValidateOpenIdConnectProtocol(null, message);
var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(message, ticket, tokenEndpointResponse);
if (authenticationValidatedContext.HandledResponse)
@@ -522,7 +522,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
var validationParameters = Options.TokenValidationParameters.Clone();
var ticket = ValidateToken(message.IdToken, message, properties, validationParameters, out jwt);
- await ValidateOpenIdConnectProtocolAsync(jwt, message);
+ ValidateOpenIdConnectProtocol(jwt, message);
var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(message, ticket, tokenEndpointResponse: null);
if (authenticationValidatedContext.HandledResponse)
@@ -588,7 +588,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
/// Authentication ticket with identity with additional claims, if any.
protected virtual async Task GetUserInformationAsync(OpenIdConnectMessage message, AuthenticationTicket ticket)
{
- string userInfoEndpoint = _configuration?.UserInfoEndpoint;
+ var userInfoEndpoint = _configuration?.UserInfoEndpoint;
if (string.IsNullOrEmpty(userInfoEndpoint))
{
@@ -734,7 +734,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
var nonceBytes = new byte[32];
CryptoRandom.GetBytes(nonceBytes);
- var correlationId = TextEncodings.Base64Url.Encode(nonceBytes);
+ var correlationId = Base64UrlTextEncoder.Encode(nonceBytes);
var cookieOptions = new CookieOptions
{
@@ -1023,7 +1023,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
return ticket;
}
- private async Task ValidateOpenIdConnectProtocolAsync(JwtSecurityToken jwt, OpenIdConnectMessage message)
+ private void ValidateOpenIdConnectProtocol(JwtSecurityToken jwt, OpenIdConnectMessage message)
{
string nonce = jwt?.Payload.Nonce;
if (!string.IsNullOrEmpty(nonce))
diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs
index 7aeca5efba..d2ccf3c1a9 100644
--- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs
+++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs
@@ -72,7 +72,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
Options.AuthenticationScheme,
"v1");
- Options.StringDataFormat = new SecureDataFormat(new StringSerializer(), dataProtector, TextEncodings.Base64Url);
+ Options.StringDataFormat = new SecureDataFormat(new StringSerializer(), dataProtector);
}
// if the user has not set the AuthorizeCallback, set it from the redirect_uri
diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/ITwitterEvents.cs b/src/Microsoft.AspNet.Authentication.Twitter/Events/ITwitterEvents.cs
index c96eec4687..cb793eb994 100644
--- a/src/Microsoft.AspNet.Authentication.Twitter/Events/ITwitterEvents.cs
+++ b/src/Microsoft.AspNet.Authentication.Twitter/Events/ITwitterEvents.cs
@@ -15,19 +15,19 @@ namespace Microsoft.AspNet.Authentication.Twitter
///
/// Contains information about the login session as well as the user .
/// A representing the completed operation.
- Task Authenticated(TwitterAuthenticatedContext context);
+ Task CreatingTicket(TwitterCreatingTicketContext context);
///
/// Invoked prior to the being saved in a local cookie and the browser being redirected to the originally requested URL.
///
///
/// A representing the completed operation.
- Task ReturnEndpoint(TwitterReturnEndpointContext context);
+ Task SigningIn(SigningInContext context);
///
/// Called when a Challenge causes a redirect to authorize endpoint in the Twitter middleware
///
/// Contains redirect URI and of the challenge
- Task ApplyRedirect(TwitterApplyRedirectContext context);
+ Task RedirectToAuthorizationEndpoint(TwitterRedirectToAuthorizationEndpointContext context);
}
}
diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterAuthenticatedContext.cs b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs
similarity index 92%
rename from src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterAuthenticatedContext.cs
rename to src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs
index 0ebd2bf91c..d002554cda 100644
--- a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterAuthenticatedContext.cs
+++ b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs
@@ -10,17 +10,17 @@ namespace Microsoft.AspNet.Authentication.Twitter
///
/// Contains information about the login session as well as the user .
///
- public class TwitterAuthenticatedContext : BaseContext
+ public class TwitterCreatingTicketContext : BaseContext
{
///
- /// Initializes a
+ /// Initializes a
///
/// The HTTP environment
/// Twitter user ID
/// Twitter screen name
/// Twitter access token
/// Twitter access token secret
- public TwitterAuthenticatedContext(
+ public TwitterCreatingTicketContext(
HttpContext context,
string userId,
string screenName,
diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterEvents.cs b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterEvents.cs
index a3bdfff6ef..f73e4b617f 100644
--- a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterEvents.cs
+++ b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterEvents.cs
@@ -14,17 +14,17 @@ namespace Microsoft.AspNet.Authentication.Twitter
///
/// Gets or sets the function that is invoked when the Authenticated method is invoked.
///
- public Func OnAuthenticated { get; set; } = context => Task.FromResult(0);
+ public Func OnCreatingTicket { get; set; } = context => Task.FromResult(0);
///
/// Gets or sets the function that is invoked when the ReturnEndpoint method is invoked.
///
- public Func OnReturnEndpoint { get; set; } = context => Task.FromResult(0);
+ public Func OnSigningIn { get; set; } = context => Task.FromResult(0);
///
/// Gets or sets the delegate that is invoked when the ApplyRedirect method is invoked.
///
- public Func OnApplyRedirect { get; set; } = context =>
+ public Func OnRedirectToAuthorizationEndpoint { get; set; } = context =>
{
context.Response.Redirect(context.RedirectUri);
return Task.FromResult(0);
@@ -35,19 +35,19 @@ namespace Microsoft.AspNet.Authentication.Twitter
///
/// Contains information about the login session as well as the user .
/// A representing the completed operation.
- public virtual Task Authenticated(TwitterAuthenticatedContext context) => OnAuthenticated(context);
+ public virtual Task CreatingTicket(TwitterCreatingTicketContext context) => OnCreatingTicket(context);
///
/// Invoked prior to the being saved in a local cookie and the browser being redirected to the originally requested URL.
///
///
/// A representing the completed operation.
- public virtual Task ReturnEndpoint(TwitterReturnEndpointContext context) => OnReturnEndpoint(context);
+ public virtual Task SigningIn(SigningInContext context) => OnSigningIn(context);
///
/// Called when a Challenge causes a redirect to authorize endpoint in the Twitter middleware
///
/// Contains redirect URI and of the challenge
- public virtual Task ApplyRedirect(TwitterApplyRedirectContext context) => OnApplyRedirect(context);
+ public virtual Task RedirectToAuthorizationEndpoint(TwitterRedirectToAuthorizationEndpointContext context) => OnRedirectToAuthorizationEndpoint(context);
}
}
diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterApplyRedirectContext.cs b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs
similarity index 87%
rename from src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterApplyRedirectContext.cs
rename to src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs
index ab4f1aecac..4a26ce6ebe 100644
--- a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterApplyRedirectContext.cs
+++ b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs
@@ -9,7 +9,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
///
/// The Context passed when a Challenge causes a redirect to authorize endpoint in the Twitter middleware.
///
- public class TwitterApplyRedirectContext : BaseContext
+ public class TwitterRedirectToAuthorizationEndpointContext : BaseContext
{
///
/// Creates a new context object.
@@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
/// The Twitter middleware options.
/// The authentication properties of the challenge.
/// The initial redirect URI.
- public TwitterApplyRedirectContext(HttpContext context, TwitterOptions options,
+ public TwitterRedirectToAuthorizationEndpointContext(HttpContext context, TwitterOptions options,
AuthenticationProperties properties, string redirectUri)
: base(context, options)
{
diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterReturnEndpointContext.cs b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterReturnEndpointContext.cs
deleted file mode 100644
index f6786988e3..0000000000
--- a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterReturnEndpointContext.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.AspNet.Http;
-
-namespace Microsoft.AspNet.Authentication.Twitter
-{
- ///
- /// Provides context information to middleware providers.
- ///
- public class TwitterReturnEndpointContext : ReturnEndpointContext
- {
- ///
- /// Initializes a new .
- ///
- /// HTTP environment
- /// The authentication ticket
- public TwitterReturnEndpointContext(
- HttpContext context,
- AuthenticationTicket ticket)
- : base(context, ticket)
- {
- }
- }
-}
diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Messages/Serializers.cs b/src/Microsoft.AspNet.Authentication.Twitter/Messages/Serializers.cs
deleted file mode 100644
index 2476dac5ec..0000000000
--- a/src/Microsoft.AspNet.Authentication.Twitter/Messages/Serializers.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace Microsoft.AspNet.Authentication.Twitter
-{
- ///
- /// Provides access to a request token serializer.
- ///
- public static class Serializers
- {
- static Serializers()
- {
- RequestToken = new RequestTokenSerializer();
- }
-
- ///
- /// Gets or sets a statically-avaliable serializer object. The value for this property will be by default.
- ///
- public static IDataSerializer RequestToken { get; private set; }
- }
-}
diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs
index b8ecef66a8..c6e2ac1ea9 100644
--- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs
@@ -117,13 +117,13 @@ namespace Microsoft.AspNet.Authentication.Twitter
protected virtual async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, AccessToken token)
{
- var context = new TwitterAuthenticatedContext(Context, token.UserId, token.ScreenName, token.Token, token.TokenSecret)
+ var context = new TwitterCreatingTicketContext(Context, token.UserId, token.ScreenName, token.Token, token.TokenSecret)
{
Principal = new ClaimsPrincipal(identity),
Properties = properties
};
- await Options.Events.Authenticated(context);
+ await Options.Events.CreatingTicket(context);
if (context.Principal?.Identity == null)
{
@@ -154,10 +154,10 @@ namespace Microsoft.AspNet.Authentication.Twitter
Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions);
- var redirectContext = new TwitterApplyRedirectContext(
+ var redirectContext = new TwitterRedirectToAuthorizationEndpointContext(
Context, Options,
properties, twitterAuthenticationEndpoint);
- await Options.Events.ApplyRedirect(redirectContext);
+ await Options.Events.RedirectToAuthorizationEndpoint(redirectContext);
return true;
}
else
@@ -177,14 +177,14 @@ namespace Microsoft.AspNet.Authentication.Twitter
return true;
}
- var context = new TwitterReturnEndpointContext(Context, model)
+ var context = new SigningInContext(Context, model)
{
SignInScheme = Options.SignInScheme,
RedirectUri = model.Properties.RedirectUri
};
model.Properties.RedirectUri = null;
- await Options.Events.ReturnEndpoint(context);
+ await Options.Events.SigningIn(context);
if (context.SignInScheme != null && context.Principal != null)
{
diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs
index b00ca44219..ce5693f92e 100644
--- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs
+++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs
@@ -59,9 +59,8 @@ namespace Microsoft.AspNet.Authentication.Twitter
var dataProtector = dataProtectionProvider.CreateProtector(
typeof(TwitterMiddleware).FullName, Options.AuthenticationScheme, "v1");
Options.StateDataFormat = new SecureDataFormat(
- Serializers.RequestToken,
- dataProtector,
- TextEncodings.Base64Url);
+ new RequestTokenSerializer(),
+ dataProtector);
}
if (string.IsNullOrEmpty(Options.SignInScheme))
diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/Base64TextEncoder.cs b/src/Microsoft.AspNet.Authentication/DataHandler/Base64TextEncoder.cs
deleted file mode 100644
index f56b6f2088..0000000000
--- a/src/Microsoft.AspNet.Authentication/DataHandler/Base64TextEncoder.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-
-using System;
-
-namespace Microsoft.AspNet.Authentication
-{
- public class Base64TextEncoder : ITextEncoder
- {
- public string Encode(byte[] data)
- {
- return Convert.ToBase64String(data);
- }
-
- public byte[] Decode(string text)
- {
- return Convert.FromBase64String(text);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/DataSerializers.cs b/src/Microsoft.AspNet.Authentication/DataHandler/DataSerializers.cs
deleted file mode 100644
index eda821414a..0000000000
--- a/src/Microsoft.AspNet.Authentication/DataHandler/DataSerializers.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.AspNet.Http.Authentication;
-
-namespace Microsoft.AspNet.Authentication
-{
- public static class DataSerializers
- {
- static DataSerializers()
- {
- Properties = new PropertiesSerializer();
- Ticket = new TicketSerializer();
- }
-
- public static IDataSerializer Properties { get; private set; }
-
- public static IDataSerializer Ticket { get; private set; }
- }
-}
diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/ITextEncoder.cs b/src/Microsoft.AspNet.Authentication/DataHandler/ITextEncoder.cs
deleted file mode 100644
index 2bcf3f8bac..0000000000
--- a/src/Microsoft.AspNet.Authentication/DataHandler/ITextEncoder.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace Microsoft.AspNet.Authentication
-{
- public interface ITextEncoder
- {
- string Encode(byte[] data);
- byte[] Decode(string text);
- }
-}
diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/PropertiesDataFormat.cs b/src/Microsoft.AspNet.Authentication/DataHandler/PropertiesDataFormat.cs
index d02b0c30b7..956794815e 100644
--- a/src/Microsoft.AspNet.Authentication/DataHandler/PropertiesDataFormat.cs
+++ b/src/Microsoft.AspNet.Authentication/DataHandler/PropertiesDataFormat.cs
@@ -9,7 +9,7 @@ namespace Microsoft.AspNet.Authentication
public class PropertiesDataFormat : SecureDataFormat
{
public PropertiesDataFormat(IDataProtector protector)
- : base(DataSerializers.Properties, protector, TextEncodings.Base64Url)
+ : base(new PropertiesSerializer(), protector)
{
}
}
diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/SecureDataFormat.cs b/src/Microsoft.AspNet.Authentication/DataHandler/SecureDataFormat.cs
index 258bba52ea..3ede386433 100644
--- a/src/Microsoft.AspNet.Authentication/DataHandler/SecureDataFormat.cs
+++ b/src/Microsoft.AspNet.Authentication/DataHandler/SecureDataFormat.cs
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNet.DataProtection;
@@ -10,20 +11,18 @@ namespace Microsoft.AspNet.Authentication
{
private readonly IDataSerializer _serializer;
private readonly IDataProtector _protector;
- private readonly ITextEncoder _encoder;
- public SecureDataFormat(IDataSerializer serializer, IDataProtector protector, ITextEncoder encoder)
+ public SecureDataFormat(IDataSerializer serializer, IDataProtector protector)
{
_serializer = serializer;
_protector = protector;
- _encoder = encoder;
}
public string Protect(TData data)
{
byte[] userData = _serializer.Serialize(data);
byte[] protectedData = _protector.Protect(userData);
- string protectedText = _encoder.Encode(protectedData);
+ string protectedText = Base64UrlTextEncoder.Encode(protectedData);
return protectedText;
}
@@ -37,7 +36,7 @@ namespace Microsoft.AspNet.Authentication
return default(TData);
}
- byte[] protectedData = _encoder.Decode(protectedText);
+ byte[] protectedData = Base64UrlTextEncoder.Decode(protectedText);
if (protectedData == null)
{
return default(TData);
diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/Base64UrlTextEncoder.cs b/src/Microsoft.AspNet.Authentication/DataHandler/TextEncoder.cs
similarity index 79%
rename from src/Microsoft.AspNet.Authentication/DataHandler/Base64UrlTextEncoder.cs
rename to src/Microsoft.AspNet.Authentication/DataHandler/TextEncoder.cs
index df3319d9f6..009413ed0a 100644
--- a/src/Microsoft.AspNet.Authentication/DataHandler/Base64UrlTextEncoder.cs
+++ b/src/Microsoft.AspNet.Authentication/DataHandler/TextEncoder.cs
@@ -2,18 +2,17 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Authentication
{
- public class Base64UrlTextEncoder : ITextEncoder
+ public static class Base64UrlTextEncoder
{
- public string Encode([NotNull] byte[] data)
+ public static string Encode(byte[] data)
{
return Convert.ToBase64String(data).TrimEnd('=').Replace('+', '-').Replace('/', '_');
}
- public byte[] Decode([NotNull] string text)
+ public static byte[] Decode(string text)
{
return Convert.FromBase64String(Pad(text.Replace('-', '+').Replace('_', '/')));
}
@@ -27,5 +26,6 @@ namespace Microsoft.AspNet.Authentication
}
return text + new string('=', padding);
}
+
}
}
diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/TextEncodings.cs b/src/Microsoft.AspNet.Authentication/DataHandler/TextEncodings.cs
deleted file mode 100644
index ddb11f5999..0000000000
--- a/src/Microsoft.AspNet.Authentication/DataHandler/TextEncodings.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace Microsoft.AspNet.Authentication
-{
- public static class TextEncodings
- {
- private static readonly ITextEncoder Base64Instance = new Base64TextEncoder();
- private static readonly ITextEncoder Base64UrlInstance = new Base64UrlTextEncoder();
-
- public static ITextEncoder Base64
- {
- get { return Base64Instance; }
- }
-
- public static ITextEncoder Base64Url
- {
- get { return Base64UrlInstance; }
- }
- }
-}
diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/TicketDataFormat.cs b/src/Microsoft.AspNet.Authentication/DataHandler/TicketDataFormat.cs
index 0f4dbd44fc..a252b138ca 100644
--- a/src/Microsoft.AspNet.Authentication/DataHandler/TicketDataFormat.cs
+++ b/src/Microsoft.AspNet.Authentication/DataHandler/TicketDataFormat.cs
@@ -7,7 +7,7 @@ namespace Microsoft.AspNet.Authentication
{
public class TicketDataFormat : SecureDataFormat
{
- public TicketDataFormat(IDataProtector protector) : base(DataSerializers.Ticket, protector, TextEncodings.Base64Url)
+ public TicketDataFormat(IDataProtector protector) : base(new TicketSerializer(), protector)
{
}
}
diff --git a/src/Microsoft.AspNet.Authentication/Events/EndpointContext.cs b/src/Microsoft.AspNet.Authentication/Events/EndpointContext.cs
deleted file mode 100644
index e8b93e9e38..0000000000
--- a/src/Microsoft.AspNet.Authentication/Events/EndpointContext.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.AspNet.Http;
-
-namespace Microsoft.AspNet.Authentication
-{
- public abstract class EndpointContext : BaseContext
- {
- protected EndpointContext(HttpContext context)
- : base(context)
- {
- }
-
- public bool IsRequestCompleted { get; private set; }
-
- public void RequestCompleted()
- {
- IsRequestCompleted = true;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.Authentication/Events/EndpointContext`1.cs b/src/Microsoft.AspNet.Authentication/Events/EndpointContext`1.cs
deleted file mode 100644
index 3f56a3a176..0000000000
--- a/src/Microsoft.AspNet.Authentication/Events/EndpointContext`1.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-
-using Microsoft.AspNet.Http;
-
-namespace Microsoft.AspNet.Authentication
-{
- ///
- /// Base class used for certain event contexts
- ///
- public abstract class EndpointContext : BaseContext
- {
- ///
- /// Creates an instance of this context
- ///
- protected EndpointContext(HttpContext context, TOptions options)
- : base(context, options)
- {
- }
-
- ///
- /// True if the request should not be processed further by other components.
- ///
- public bool IsRequestCompleted { get; private set; }
-
- ///
- /// Prevents the request from being processed further by other components.
- /// IsRequestCompleted becomes true after calling.
- ///
- public void RequestCompleted()
- {
- IsRequestCompleted = true;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.Authentication/Events/ReturnEndpointContext.cs b/src/Microsoft.AspNet.Authentication/Events/SigningInContext.cs
similarity index 74%
rename from src/Microsoft.AspNet.Authentication/Events/ReturnEndpointContext.cs
rename to src/Microsoft.AspNet.Authentication/Events/SigningInContext.cs
index 77c903f457..30d38ae7f7 100644
--- a/src/Microsoft.AspNet.Authentication/Events/ReturnEndpointContext.cs
+++ b/src/Microsoft.AspNet.Authentication/Events/SigningInContext.cs
@@ -8,9 +8,12 @@ using Microsoft.AspNet.Http.Authentication;
namespace Microsoft.AspNet.Authentication
{
- public abstract class ReturnEndpointContext : EndpointContext
+ ///
+ /// Provides context information to middleware providers.
+ ///
+ public class SigningInContext : BaseContext
{
- protected ReturnEndpointContext(
+ public SigningInContext(
HttpContext context,
AuthenticationTicket ticket)
: base(context)
@@ -25,6 +28,13 @@ namespace Microsoft.AspNet.Authentication
public ClaimsPrincipal Principal { get; set; }
public AuthenticationProperties Properties { get; set; }
+ public bool IsRequestCompleted { get; private set; }
+
+ public void RequestCompleted()
+ {
+ IsRequestCompleted = true;
+ }
+
public string SignInScheme { get; set; }
[SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "By design")]
diff --git a/src/Microsoft.AspNet.Authentication/SubjectPublicKeyInfoAlgorithm.cs b/src/Microsoft.AspNet.Authentication/SubjectPublicKeyInfoAlgorithm.cs
deleted file mode 100644
index fa5704f345..0000000000
--- a/src/Microsoft.AspNet.Authentication/SubjectPublicKeyInfoAlgorithm.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-
-namespace Microsoft.AspNet.Authentication
-{
- ///
- /// The algorithm used to generate the subject public key information blob hashes.
- ///
- public enum SubjectPublicKeyInfoAlgorithm
- {
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sha", Justification = "It is correct.")] Sha1,
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sha", Justification = "It is correct.")] Sha256
- }
-}
diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs
index 668f6a7ace..a097d98292 100644
--- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs
+++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs
@@ -484,7 +484,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
options.SlidingExpiration = false;
options.Events = new CookieAuthenticationEvents()
{
- OnResponseSignIn = context =>
+ OnSigningIn = context =>
{
context.Properties.ExpiresUtc = clock.UtcNow.Add(TimeSpan.FromMinutes(5));
return Task.FromResult(0);
diff --git a/test/Microsoft.AspNet.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs b/test/Microsoft.AspNet.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs
index 9cbe2bd006..8e62684303 100644
--- a/test/Microsoft.AspNet.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs
+++ b/test/Microsoft.AspNet.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs
@@ -10,7 +10,6 @@ namespace Microsoft.AspNet.Authentication
[Fact]
public void DataOfVariousLengthRoundTripCorrectly()
{
- var encoder = new Base64UrlTextEncoder();
for (int length = 0; length != 256; ++length)
{
var data = new byte[length];
@@ -18,8 +17,8 @@ namespace Microsoft.AspNet.Authentication
{
data[index] = (byte)(5 + length + (index * 23));
}
- string text = encoder.Encode(data);
- byte[] result = encoder.Decode(text);
+ string text = Base64UrlTextEncoder.Encode(data);
+ byte[] result = Base64UrlTextEncoder.Decode(text);
for (int index = 0; index != length; ++index)
{
diff --git a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs
index ed1723f3a4..f0cefe6561 100644
--- a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs
+++ b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs
@@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Authentication.Facebook
options.AppSecret = "Test App Secret";
options.Events = new OAuthEvents
{
- OnApplyRedirect = context =>
+ OnRedirectToAuthorizationEndpoint = context =>
{
context.Response.Redirect(context.RedirectUri + "&custom=test");
return Task.FromResult(0);
diff --git a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs
index d6d2b7053a..617b6862a3 100644
--- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs
+++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs
@@ -199,7 +199,7 @@ namespace Microsoft.AspNet.Authentication.Google
options.ClientSecret = "Test Secret";
options.Events = new OAuthEvents
{
- OnApplyRedirect = context =>
+ OnRedirectToAuthorizationEndpoint = context =>
{
context.Response.Redirect(context.RedirectUri + "&custom=test");
return Task.FromResult(0);
@@ -416,7 +416,7 @@ namespace Microsoft.AspNet.Authentication.Google
};
options.Events = new OAuthEvents
{
- OnAuthenticated = context =>
+ OnCreatingTicket = context =>
{
var refreshToken = context.RefreshToken;
context.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Google") }, "Google"));
@@ -457,7 +457,7 @@ namespace Microsoft.AspNet.Authentication.Google
options.AccessType = "offline";
options.Events = new OAuthEvents()
{
- OnAuthenticated = context =>
+ OnCreatingTicket = context =>
{
Assert.NotNull(context.User);
Assert.Equal(context.AccessToken, "Test Access Token");
diff --git a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs
index 24bc6ccec4..f51fcaaf31 100644
--- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.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.JwtBearer
+namespace Microsoft.AspNet.Authentication.OpenIdConnectBearer
{
- public class JwtBearerMiddlewareTests
+ public class OpenIdConnectBearerMiddlewareTests
{
[Fact]
public async Task BearerTokenValidation()
@@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
options.AutomaticAuthentication = true;
options.Authority = "https://login.windows.net/tushartest.onmicrosoft.com";
- options.Audience = "https://TusharTest.onmicrosoft.com/TodoListService-ManualJwt";
+ options.Audience = "https://TusharTest.onmicrosoft.com/TodoListService-ManualOpenIdConnect";
options.TokenValidationParameters.ValidateLifetime = false;
});
@@ -66,7 +66,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
{
options.AutomaticAuthentication = true;
- options.Events = new JwtBearerEvents()
+ options.Events = new OpenIdConnectBearerEvents()
{
OnMessageReceived = context =>
{
@@ -116,7 +116,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
{
options.AutomaticAuthentication = true;
- options.Events = new JwtBearerEvents()
+ options.Events = new OpenIdConnectBearerEvents()
{
OnSecurityTokenReceived = context =>
{
@@ -150,7 +150,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
{
options.AutomaticAuthentication = true;
- options.Events = new JwtBearerEvents()
+ options.Events = new OpenIdConnectBearerEvents()
{
OnSecurityTokenValidated = context =>
{
@@ -187,7 +187,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
{
options.AutomaticAuthentication = true;
- options.Events = new JwtBearerEvents()
+ options.Events = new OpenIdConnectBearerEvents()
{
OnMessageReceived = context =>
{
@@ -224,7 +224,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
{
var server = CreateServer(options =>
{
- options.Events = new JwtBearerEvents()
+ options.Events = new OpenIdConnectBearerEvents()
{
OnSecurityTokenReceived = context =>
{
@@ -255,7 +255,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
{
var server = CreateServer(options =>
{
- options.Events = new JwtBearerEvents()
+ options.Events = new OpenIdConnectBearerEvents()
{
OnSecurityTokenReceived = context =>
{
@@ -323,13 +323,13 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
}
}
- 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.UseJwtBearerAuthentication(configureOptions);
+ app.UseOpenIdConnectBearerAuthentication(configureOptions);
}
app.Use(async (context, next) =>
@@ -359,17 +359,17 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
else if (context.Request.Path == new PathString("/unauthorized"))
{
// Simulate Authorization failure
- var result = await context.Authentication.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme);
- await context.Authentication.ChallengeAsync(JwtBearerDefaults.AuthenticationScheme);
+ var result = await context.Authentication.AuthenticateAsync(OpenIdConnectBearerDefaults.AuthenticationScheme);
+ await context.Authentication.ChallengeAsync(OpenIdConnectBearerDefaults.AuthenticationScheme);
}
else if (context.Request.Path == new PathString("/signIn"))
{
- await Assert.ThrowsAsync(() => context.Authentication.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal()));
+ await Assert.ThrowsAsync(() => context.Authentication.SignInAsync(OpenIdConnectBearerDefaults.AuthenticationScheme, new ClaimsPrincipal()));
}
else if (context.Request.Path == new PathString("/signOut"))
{
- await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync(JwtBearerDefaults.AuthenticationScheme));
+ await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync(OpenIdConnectBearerDefaults.AuthenticationScheme));
}
else
{
diff --git a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs
index 4972086ff3..8ad48c8fde 100644
--- a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs
+++ b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs
@@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount
options.ClientSecret = "Test Client Secret";
options.Events = new OAuthEvents
{
- OnApplyRedirect = context =>
+ OnRedirectToAuthorizationEndpoint = context =>
{
context.Response.Redirect(context.RedirectUri + "&custom=test");
return Task.FromResult(0);
@@ -146,7 +146,7 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount
};
options.Events = new OAuthEvents
{
- OnAuthenticated = context =>
+ OnCreatingTicket = context =>
{
var refreshToken = context.RefreshToken;
context.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Microsoft") }, "Microsoft"));
diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs
index 2345d74318..c3b15e2160 100644
--- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs
+++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs
@@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens;
-using System.IdentityModel.Tokens.Jwt;
+using System.IdentityModel.Tokens.OpenIdConnect;
using System.Linq;
using System.Net.Http;
using System.Security.Claims;
@@ -26,8 +26,8 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
///
public class OpenIdConnectHandlerTests
{
- private const string nonceForJwt = "abc";
- private static SecurityToken specCompliantJwt = new JwtSecurityToken("issuer", "audience", new List { new Claim("iat", EpochTime.GetIntDate(DateTime.UtcNow).ToString()), new Claim("nonce", nonceForJwt) }, DateTime.UtcNow, DateTime.UtcNow + TimeSpan.FromDays(1));
+ private const string nonceForOpenIdConnect = "abc";
+ private static SecurityToken specCompliantOpenIdConnect = new OpenIdConnectSecurityToken("issuer", "audience", new List { new Claim("iat", EpochTime.GetIntDate(DateTime.UtcNow).ToString()), new Claim("nonce", nonceForOpenIdConnect) }, DateTime.UtcNow, DateTime.UtcNow + TimeSpan.FromDays(1));
private const string ExpectedStateParameter = "expectedState";
///
diff --git a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs
index 380158ef6c..9b73806a90 100644
--- a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs
+++ b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs
@@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
options.ConsumerSecret = "Test Consumer Secret";
options.Events = new TwitterEvents
{
- OnApplyRedirect = context =>
+ OnRedirectToAuthorizationEndpoint = context =>
{
context.Response.Redirect(context.RedirectUri + "&custom=test");
return Task.FromResult(0);
diff --git a/test/Microsoft.AspNet.Authentication.Test/project.json b/test/Microsoft.AspNet.Authentication.Test/project.json
index 10f0e221a2..c56539e8e1 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.JwtBearer": "1.0.0-*",
+ "Microsoft.AspNet.Authentication.OpenIdConnectBearer": "1.0.0-*",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-*",
"Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-*",