+
+
+ +

This sample demonstrates how to take advantage of ADAL JS for adding Azure AD authentication to your AngularJS apps.

+
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + diff --git a/samples/JwtBearerSample/wwwroot/web.config b/samples/JwtBearerSample/wwwroot/web.config new file mode 100644 index 0000000000..8485f6719f --- /dev/null +++ b/samples/JwtBearerSample/wwwroot/web.config @@ -0,0 +1,9 @@ + + + + + + + + + From f24c35f1a93ed0d6de3cda2b4ab15906f5f6d56b Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 7 Dec 2015 13:37:56 -0800 Subject: [PATCH 419/900] Promote SaveTokensAsClaims to RemoteAuthOptions --- .../FacebookOptions.cs | 1 - .../GoogleOptions.cs | 1 - .../MicrosoftAccountOptions.cs | 1 - src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs | 8 -------- .../OpenIdConnectOptions.cs | 7 ------- .../TwitterOptions.cs | 8 -------- .../RemoteAuthenticationOptions.cs | 8 ++++++++ 7 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs index 0bf6a37166..b6ceb5f0f0 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs @@ -24,7 +24,6 @@ namespace Microsoft.AspNet.Authentication.Facebook AuthorizationEndpoint = FacebookDefaults.AuthorizationEndpoint; TokenEndpoint = FacebookDefaults.TokenEndpoint; UserInformationEndpoint = FacebookDefaults.UserInformationEndpoint; - SaveTokensAsClaims = false; Fields = new List(); } diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs index ca736f34e5..2c00278c78 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs @@ -22,7 +22,6 @@ namespace Microsoft.AspNet.Authentication.Google AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint; TokenEndpoint = GoogleDefaults.TokenEndpoint; UserInformationEndpoint = GoogleDefaults.UserInformationEndpoint; - SaveTokensAsClaims = false; } /// diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs index 8c89ef20d5..3339cf4ccd 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -22,7 +22,6 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint; TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; UserInformationEndpoint = MicrosoftAccountDefaults.UserInformationEndpoint; - SaveTokensAsClaims = false; } } } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs index fa1471bb21..ba689e66b1 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs @@ -64,13 +64,5 @@ namespace Microsoft.AspNet.Authentication.OAuth /// Gets or sets the type used to secure data handled by the middleware. /// public ISecureDataFormat StateDataFormat { get; set; } - - /// - /// Defines whether access and refresh tokens should be stored in the - /// after a successful authentication. - /// You can set this property to false to reduce the size of the final - /// authentication cookie. Note that social providers set this property to false by default. - /// - public bool SaveTokensAsClaims { get; set; } = true; } } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index a139f96515..dc2cce9964 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -189,12 +189,5 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect /// This is disabled by default. /// public bool UseTokenLifetime { get; set; } - - /// - /// Defines whether access and refresh tokens should be stored in the - /// after a successful authentication. - /// You can set this property to false to reduce the size of the final authentication cookie. - /// - public bool SaveTokensAsClaims { get; set; } = true; } } diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs index dae6fa6b20..85e266326a 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs @@ -49,13 +49,5 @@ namespace Microsoft.AspNet.Authentication.Twitter get { return (ITwitterEvents)base.Events; } set { base.Events = value; } } - - /// - /// Defines whether access tokens should be stored in the - /// after a successful authentication. - /// This property is set to false by default to reduce - /// the size of the final authentication cookie. - /// - public bool SaveTokensAsClaims { get; set; } } } diff --git a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs index f5dad7267f..5fb3b4caf6 100644 --- a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs @@ -48,6 +48,14 @@ namespace Microsoft.AspNet.Authentication set { Description.DisplayName = value; } } + /// + /// Defines whether access and refresh tokens should be stored in the + /// after a successful authentication. + /// This property is set to false by default to reduce + /// the size of the final authentication cookie. + /// + public bool SaveTokensAsClaims { get; set; } + public IRemoteAuthenticationEvents Events = new RemoteAuthenticationEvents(); } } \ No newline at end of file From 4c1943b281cb97c440fc66018112819061b9d0a3 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sun, 6 Dec 2015 18:32:28 -0800 Subject: [PATCH 420/900] Reacting to verbose rename --- .../OpenIdConnectHandler.cs | 66 +++++++++---------- .../TwitterHandler.cs | 4 +- .../AuthenticationHandler.cs | 2 +- .../RemoteAuthenticationHandler.cs | 4 +- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index eb88f43696..5780bccfe7 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -107,12 +107,12 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect await Options.Events.RedirectToEndSessionEndpoint(redirectContext); if (redirectContext.HandledResponse) { - Logger.LogVerbose(1, "RedirectToEndSessionEndpoint.HandledResponse"); + Logger.LogDebug(1, "RedirectToEndSessionEndpoint.HandledResponse"); return; } else if (redirectContext.Skipped) { - Logger.LogVerbose(2, "RedirectToEndSessionEndpoint.Skipped"); + Logger.LogDebug(2, "RedirectToEndSessionEndpoint.Skipped"); return; } @@ -170,7 +170,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect throw new ArgumentNullException(nameof(context)); } - Logger.LogDebug(4, "Entering {0}." + nameof(HandleUnauthorizedAsync), GetType()); + Logger.LogTrace(4, "Entering {0}." + nameof(HandleUnauthorizedAsync), GetType()); // order for local RedirectUri // 1. challenge.Properties.RedirectUri @@ -181,7 +181,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { properties.RedirectUri = CurrentUri; } - Logger.LogDebug(5, "Using properties.RedirectUri for 'local redirect' post authentication: '{0}'.", properties.RedirectUri); + Logger.LogTrace(5, "Using properties.RedirectUri for 'local redirect' post authentication: '{0}'.", properties.RedirectUri); if (_configuration == null && Options.ConfigurationManager != null) { @@ -223,12 +223,12 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect await Options.Events.RedirectToAuthenticationEndpoint(redirectContext); if (redirectContext.HandledResponse) { - Logger.LogVerbose(6, "RedirectToAuthenticationEndpoint.HandledResponse"); + Logger.LogDebug(6, "RedirectToAuthenticationEndpoint.HandledResponse"); return true; } else if (redirectContext.Skipped) { - Logger.LogVerbose(7, "RedirectToAuthenticationEndpoint.Skipped"); + Logger.LogDebug(7, "RedirectToAuthenticationEndpoint.Skipped"); return false; } @@ -294,7 +294,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect /// Uses log id's OIDCH-0000 - OIDCH-0025 protected override async Task HandleRemoteAuthenticateAsync() { - Logger.LogDebug(10, "Entering: {0}." + nameof(HandleRemoteAuthenticateAsync), GetType()); + Logger.LogTrace(10, "Entering: {0}." + nameof(HandleRemoteAuthenticateAsync), GetType()); OpenIdConnectMessage message = null; @@ -344,7 +344,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect if (string.IsNullOrEmpty(message.State)) { // This wasn't a valid ODIC message, it may not have been intended for us. - Logger.LogVerbose(11, "message.State is null or empty."); + Logger.LogDebug(11, "message.State is null or empty."); return AuthenticateResult.Failed(Resources.MessageStateIsNullOrEmpty); } @@ -374,11 +374,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect if (_configuration == null && Options.ConfigurationManager != null) { - Logger.LogVerbose(14, "Updating configuration"); + Logger.LogDebug(14, "Updating configuration"); _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); } - Logger.LogDebug(15, "Authorization response received."); + Logger.LogTrace(15, "Authorization response received."); var authorizationResponseReceivedContext = new AuthorizationResponseReceivedContext(Context, Options) { ProtocolMessage = message, @@ -387,12 +387,12 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect await Options.Events.AuthorizationResponseReceived(authorizationResponseReceivedContext); if (authorizationResponseReceivedContext.HandledResponse) { - Logger.LogVerbose(16, "AuthorizationResponseReceived.HandledResponse"); + Logger.LogDebug(16, "AuthorizationResponseReceived.HandledResponse"); return AuthenticateResult.Success(authorizationResponseReceivedContext.AuthenticationTicket); } else if (authorizationResponseReceivedContext.Skipped) { - Logger.LogVerbose(17, "AuthorizationResponseReceived.Skipped"); + Logger.LogDebug(17, "AuthorizationResponseReceived.Skipped"); return AuthenticateResult.Success(ticket: null); } message = authorizationResponseReceivedContext.ProtocolMessage; @@ -408,7 +408,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } else { - Logger.LogDebug(18, "Cannot process the message. Both id_token and code are missing."); + Logger.LogTrace(18, "Cannot process the message. Both id_token and code are missing."); return AuthenticateResult.Failed(Resources.IdTokenCodeMissing); } } @@ -421,7 +421,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { if (Options.ConfigurationManager != null) { - Logger.LogVerbose(20, "exception of type 'SecurityTokenSignatureKeyNotFoundException' thrown, Options.ConfigurationManager.RequestRefresh() called."); + Logger.LogDebug(20, "exception of type 'SecurityTokenSignatureKeyNotFoundException' thrown, Options.ConfigurationManager.RequestRefresh() called."); Options.ConfigurationManager.RequestRefresh(); } } @@ -465,7 +465,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var code = authorizationCodeReceivedContext.Code; // Redeeming authorization code for tokens - Logger.LogDebug(21, "Id Token is null. Redeeming code '{0}' for tokens.", code); + Logger.LogTrace(21, "Id Token is null. Redeeming code '{0}' for tokens.", code); var tokenEndpointResponse = await RedeemAuthorizationCodeAsync(code, authorizationCodeReceivedContext.RedirectUri); @@ -521,7 +521,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect if (Options.GetClaimsFromUserInfoEndpoint) { - Logger.LogDebug(22, "Sending request to user info endpoint for retrieving claims."); + Logger.LogTrace(22, "Sending request to user info endpoint for retrieving claims."); ticket = await GetUserInformationAsync(tokenEndpointResponse, jwt, ticket); } @@ -531,7 +531,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect // Implicit Flow or Hybrid Flow private async Task HandleIdTokenFlows(OpenIdConnectMessage message, AuthenticationProperties properties) { - Logger.LogDebug(23, "'id_token' received: '{0}'", message.IdToken); + Logger.LogTrace(23, "'id_token' received: '{0}'", message.IdToken); JwtSecurityToken jwt = null; var validationParameters = Options.TokenValidationParameters.Clone(); @@ -925,7 +925,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect private async Task RunMessageReceivedEventAsync(OpenIdConnectMessage message) { - Logger.LogDebug(29, "MessageReceived: '{0}'", message.BuildRedirectUrl()); + Logger.LogTrace(29, "MessageReceived: '{0}'", message.BuildRedirectUrl()); var messageReceivedContext = new MessageReceivedContext(Context, Options) { ProtocolMessage = message @@ -934,11 +934,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect await Options.Events.MessageReceived(messageReceivedContext); if (messageReceivedContext.HandledResponse) { - Logger.LogVerbose(30, "MessageReceivedContext.HandledResponse"); + Logger.LogDebug(30, "MessageReceivedContext.HandledResponse"); } else if (messageReceivedContext.Skipped) { - Logger.LogVerbose(31, "MessageReceivedContext.Skipped"); + Logger.LogDebug(31, "MessageReceivedContext.Skipped"); } return messageReceivedContext; @@ -948,7 +948,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { var redirectUri = properties.Items[OpenIdConnectDefaults.RedirectUriForCodePropertiesKey]; - Logger.LogDebug(32, "AuthorizationCode received: '{0}'", message.Code); + Logger.LogTrace(32, "AuthorizationCode received: '{0}'", message.Code); var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Options) { @@ -962,11 +962,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect await Options.Events.AuthorizationCodeReceived(authorizationCodeReceivedContext); if (authorizationCodeReceivedContext.HandledResponse) { - Logger.LogVerbose(33, "AuthorizationCodeReceivedContext.HandledResponse"); + Logger.LogDebug(33, "AuthorizationCodeReceivedContext.HandledResponse"); } else if (authorizationCodeReceivedContext.Skipped) { - Logger.LogVerbose(34, "AuthorizationCodeReceivedContext.Skipped"); + Logger.LogDebug(34, "AuthorizationCodeReceivedContext.Skipped"); } return authorizationCodeReceivedContext; @@ -974,7 +974,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect private async Task RunTokenResponseReceivedEventAsync(OpenIdConnectMessage message, OpenIdConnectMessage tokenEndpointResponse) { - Logger.LogDebug(35, "Token response received."); + Logger.LogTrace(35, "Token response received."); var tokenResponseReceivedContext = new TokenResponseReceivedContext(Context, Options) { ProtocolMessage = message, @@ -984,11 +984,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect await Options.Events.TokenResponseReceived(tokenResponseReceivedContext); if (tokenResponseReceivedContext.HandledResponse) { - Logger.LogVerbose(36, "AuthorizationCodeRedeemedContext.HandledResponse"); + Logger.LogDebug(36, "AuthorizationCodeRedeemedContext.HandledResponse"); } else if (tokenResponseReceivedContext.Skipped) { - Logger.LogVerbose(37, "AuthorizationCodeRedeemedContext.Skipped"); + Logger.LogDebug(37, "AuthorizationCodeRedeemedContext.Skipped"); } return tokenResponseReceivedContext; } @@ -1005,11 +1005,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect await Options.Events.AuthenticationValidated(authenticationValidatedContext); if (authenticationValidatedContext.HandledResponse) { - Logger.LogVerbose(38, "AuthenticationValidated.HandledResponse"); + Logger.LogDebug(38, "AuthenticationValidated.HandledResponse"); } else if (authenticationValidatedContext.Skipped) { - Logger.LogVerbose(39, "AuthenticationValidated.Skipped"); + Logger.LogDebug(39, "AuthenticationValidated.Skipped"); } return authenticationValidatedContext; @@ -1017,7 +1017,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect private async Task RunUserInformationReceivedEventAsync(AuthenticationTicket ticket, OpenIdConnectMessage message, JObject user) { - Logger.LogDebug(40, "User information received: {0}", user.ToString()); + Logger.LogTrace(40, "User information received: {0}", user.ToString()); var userInformationReceivedContext = new UserInformationReceivedContext(Context, Options) { @@ -1029,11 +1029,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect await Options.Events.UserInformationReceived(userInformationReceivedContext); if (userInformationReceivedContext.HandledResponse) { - Logger.LogVerbose(41, "The UserInformationReceived event returned Handled."); + Logger.LogDebug(41, "The UserInformationReceived event returned Handled."); } else if (userInformationReceivedContext.Skipped) { - Logger.LogVerbose(42, "The UserInformationReceived event returned Skipped."); + Logger.LogDebug(42, "The UserInformationReceived event returned Skipped."); } return userInformationReceivedContext; @@ -1050,11 +1050,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect await Options.Events.AuthenticationFailed(authenticationFailedContext); if (authenticationFailedContext.HandledResponse) { - Logger.LogVerbose(43, "AuthenticationFailedContext.HandledResponse"); + Logger.LogDebug(43, "AuthenticationFailedContext.HandledResponse"); } else if (authenticationFailedContext.Skipped) { - Logger.LogVerbose(44, "AuthenticationFailedContext.Skipped"); + Logger.LogDebug(44, "AuthenticationFailedContext.Skipped"); } return authenticationFailedContext; diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs index 8ea5ae42d6..312c8c281e 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs @@ -147,7 +147,7 @@ namespace Microsoft.AspNet.Authentication.Twitter private async Task ObtainRequestTokenAsync(string consumerKey, string consumerSecret, string callBackUri, AuthenticationProperties properties) { - Logger.LogVerbose("ObtainRequestToken"); + Logger.LogDebug("ObtainRequestToken"); var nonce = Guid.NewGuid().ToString("N"); @@ -208,7 +208,7 @@ namespace Microsoft.AspNet.Authentication.Twitter { // https://dev.twitter.com/docs/api/1/post/oauth/access_token - Logger.LogVerbose("ObtainAccessToken"); + Logger.LogDebug("ObtainAccessToken"); var nonce = Guid.NewGuid().ToString("N"); diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs index 7c4102cf39..6dd298fbc7 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs @@ -216,7 +216,7 @@ namespace Microsoft.AspNet.Authentication else { context.NotAuthenticated(); - Logger.LogVerbose(2, "AuthenticationScheme: {scheme} was not authenticated.", Options.AuthenticationScheme); + Logger.LogDebug(2, "AuthenticationScheme: {scheme} was not authenticated.", Options.AuthenticationScheme); } } } diff --git a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs index 0851b1b5ce..8c58d072dd 100644 --- a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs @@ -52,12 +52,12 @@ namespace Microsoft.AspNet.Authentication if (context.HandledResponse) { - Logger.LogVerbose("The SigningIn event returned Handled."); + Logger.LogDebug("The SigningIn event returned Handled."); return true; } else if (context.Skipped) { - Logger.LogVerbose("The SigningIn event returned Skipped."); + Logger.LogDebug("The SigningIn event returned Skipped."); return false; } From 0623f3b741f1e98c48a4fe5cf88b77c1d3133a77 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 9 Dec 2015 10:52:30 -0800 Subject: [PATCH 421/900] #555 Make SkipToNextMiddleware work on events. --- samples/JwtBearerSample/Startup.cs | 2 + .../Properties/launchSettings.json | 2 +- samples/SocialSample/Startup.cs | 10 +- .../CookieAuthenticationHandler.cs | 44 +++-- .../Events/JwtBearerEvents.cs | 8 +- .../JwtBearerHandler.cs | 34 +++- .../OAuthHandler.cs | 20 +- .../OpenIdConnectHandler.cs | 32 ++-- .../TwitterHandler.cs | 8 +- .../AuthenticateResult.cs | 24 ++- .../AuthenticationHandler.cs | 8 +- .../{ErrorContext.cs => FailureContext.cs} | 11 +- .../Events/IRemoteAuthenticationEvents.cs | 2 +- .../Events/RemoteAuthenticationEvents.cs | 8 +- .../RemoteAuthenticationHandler.cs | 14 +- .../Google/GoogleMiddlewareTests.cs | 24 +-- .../JwtBearer/JwtBearerMiddlewareTests.cs | 172 +++++++++++++++++- 17 files changed, 307 insertions(+), 116 deletions(-) rename src/Microsoft.AspNet.Authentication/Events/{ErrorContext.cs => FailureContext.cs} (60%) diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 5d2bd6400f..c79cbda951 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -5,6 +5,7 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; using Newtonsoft.Json.Linq; namespace JwtBearerSample @@ -91,6 +92,7 @@ namespace JwtBearerSample else { response.ContentType = "application/json"; + response.Headers[HeaderNames.CacheControl] = "no-cache"; var json = JToken.FromObject(Todos); await response.WriteAsync(json.ToString()); } diff --git a/samples/OpenIdConnectSample/Properties/launchSettings.json b/samples/OpenIdConnectSample/Properties/launchSettings.json index 174032b7bc..3d9d32eebe 100644 --- a/samples/OpenIdConnectSample/Properties/launchSettings.json +++ b/samples/OpenIdConnectSample/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:1791/", + "applicationUrl": "http://localhost:42023", "sslPort": 0 } }, diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 972f3ccc0f..01d26fcdf3 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -85,10 +85,10 @@ namespace CookieSample options.ClientSecret = "n2Q-GEw9RQjzcRbU3qhfTj8f"; options.Events = new OAuthEvents() { - OnRemoteError = ctx => + OnRemoteFailure = ctx => { - ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message)); + ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); ctx.HandleResponse(); return Task.FromResult(0); } @@ -103,9 +103,9 @@ namespace CookieSample options.ConsumerSecret = "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI"; options.Events = new TwitterEvents() { - OnRemoteError = ctx => + OnRemoteFailure = ctx => { - ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message)); + ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); ctx.HandleResponse(); return Task.FromResult(0); } @@ -269,7 +269,7 @@ namespace CookieSample { context.Response.ContentType = "text/html"; await context.Response.WriteAsync(""); - await context.Response.WriteAsync("An remote error has occured: " + context.Request.Query["ErrorMessage"] + "
"); + await context.Response.WriteAsync("An remote failure has occurred: " + context.Request.Query["FailureMessage"] + "
"); await context.Response.WriteAsync("Home"); await context.Response.WriteAsync(""); }); diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs index ad7dc7e862..e65640feaf 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -10,7 +10,6 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Http.Features.Authentication; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; @@ -26,31 +25,30 @@ namespace Microsoft.AspNet.Authentication.Cookies private DateTimeOffset? _renewIssuedUtc; private DateTimeOffset? _renewExpiresUtc; private string _sessionKey; - private Task _cookieTicketTask; + private Task _readCookieTask; - private Task EnsureCookieTicket() + private Task EnsureCookieTicket() { // We only need to read the ticket once - if (_cookieTicketTask == null) + if (_readCookieTask == null) { - _cookieTicketTask = ReadCookieTicket(); + _readCookieTask = ReadCookieTicket(); } - return _cookieTicketTask; + return _readCookieTask; } - private async Task ReadCookieTicket() + private async Task ReadCookieTicket() { var cookie = Options.CookieManager.GetRequestCookie(Context, Options.CookieName); if (string.IsNullOrEmpty(cookie)) { - return null; + return AuthenticateResult.Skip(); } var ticket = Options.TicketDataFormat.Unprotect(cookie, GetTlsTokenBinding()); if (ticket == null) { - Logger.LogWarning(@"Unprotect ticket failed"); - return null; + return AuthenticateResult.Fail("Unprotect ticket failed"); } if (Options.SessionStore != null) @@ -58,15 +56,13 @@ namespace Microsoft.AspNet.Authentication.Cookies var claim = ticket.Principal.Claims.FirstOrDefault(c => c.Type.Equals(SessionIdClaim)); if (claim == null) { - Logger.LogWarning(@"SessionId missing"); - return null; + return AuthenticateResult.Fail("SessionId missing"); } _sessionKey = claim.Value; ticket = await Options.SessionStore.RetrieveAsync(_sessionKey); if (ticket == null) { - Logger.LogWarning(@"Identity missing in session store"); - return null; + return AuthenticateResult.Fail("Identity missing in session store"); } } @@ -80,7 +76,7 @@ namespace Microsoft.AspNet.Authentication.Cookies { await Options.SessionStore.RemoveAsync(_sessionKey); } - return null; + return AuthenticateResult.Fail("Ticket expired"); } var allowRefresh = ticket.Properties.AllowRefresh ?? true; @@ -99,23 +95,23 @@ namespace Microsoft.AspNet.Authentication.Cookies } // Finally we have a valid ticket - return ticket; + return AuthenticateResult.Success(ticket); } protected override async Task HandleAuthenticateAsync() { - var ticket = await EnsureCookieTicket(); - if (ticket == null) + var result = await EnsureCookieTicket(); + if (!result.Succeeded) { - return AuthenticateResult.Failed("No ticket."); + return result; } - var context = new CookieValidatePrincipalContext(Context, ticket, Options); + var context = new CookieValidatePrincipalContext(Context, result.Ticket, Options); await Options.Events.ValidatePrincipal(context); if (context.Principal == null) { - return AuthenticateResult.Failed("No principal."); + return AuthenticateResult.Fail("No principal."); } if (context.ShouldRenew) @@ -196,7 +192,8 @@ namespace Microsoft.AspNet.Authentication.Cookies protected override async Task HandleSignInAsync(SignInContext signin) { - var ticket = await EnsureCookieTicket(); + // Process the request cookie to initialize members like _sessionKey. + var result = await EnsureCookieTicket(); var cookieOptions = BuildCookieOptions(); var signInContext = new CookieSigningInContext( @@ -231,7 +228,7 @@ namespace Microsoft.AspNet.Authentication.Cookies signInContext.CookieOptions.Expires = expiresUtc.ToUniversalTime().DateTime; } - ticket = new AuthenticationTicket(signInContext.Principal, signInContext.Properties, signInContext.AuthenticationScheme); + var ticket = new AuthenticationTicket(signInContext.Principal, signInContext.Properties, signInContext.AuthenticationScheme); if (Options.SessionStore != null) { if (_sessionKey != null) @@ -269,6 +266,7 @@ namespace Microsoft.AspNet.Authentication.Cookies protected override async Task HandleSignOutAsync(SignOutContext signOutContext) { + // Process the request cookie to initialize members like _sessionKey. var ticket = await EnsureCookieTicket(); var cookieOptions = BuildCookieOptions(); if (Options.SessionStore != null && _sessionKey != null) diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.cs index e9832862b2..7fcf922e57 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -36,13 +36,9 @@ namespace Microsoft.AspNet.Authentication.JwtBearer public Func OnValidatedToken { get; set; } = context => Task.FromResult(0); /// - /// Invoked to apply a challenge sent back to the caller. + /// Invoked before a challenge is sent back to the caller. /// - public Func OnChallenge { get; set; } = context => - { - context.HttpContext.Response.Headers.Append("WWW-Authenticate", context.Options.Challenge); - return Task.FromResult(0); - }; + public Func OnChallenge { get; set; } = context => Task.FromResult(0); public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs index beb77486f4..645cf2cdef 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs @@ -7,10 +7,12 @@ using System.IdentityModel.Tokens; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNet.Authentication.JwtBearer { @@ -38,7 +40,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer } if (receivingTokenContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } // If application retrieved token from somewhere else, use that. @@ -51,7 +53,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer // If no authorization header found, nothing to process further if (string.IsNullOrEmpty(authorization)) { - return AuthenticateResult.Failed("No authorization header."); + return AuthenticateResult.Skip(); } if (authorization.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase)) @@ -62,7 +64,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer // If no token found, no further work possible if (string.IsNullOrEmpty(token)) { - return AuthenticateResult.Failed("No bearer token."); + return AuthenticateResult.Skip(); } } @@ -79,7 +81,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer } if (receivedTokenContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } if (_configuration == null && Options.ConfigurationManager != null) @@ -147,7 +149,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer } if (validatedTokenContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } return AuthenticateResult.Success(ticket); @@ -168,13 +170,13 @@ namespace Microsoft.AspNet.Authentication.JwtBearer } if (authenticationFailedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } - return AuthenticateResult.Failed(authenticationFailedContext.Exception); + return AuthenticateResult.Fail(authenticationFailedContext.Exception); } - return AuthenticateResult.Failed("No SecurityTokenValidator available for token: " + token ?? "[null]"); + return AuthenticateResult.Fail("No SecurityTokenValidator available for token: " + token ?? "[null]"); } catch (Exception ex) { @@ -192,7 +194,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer } if (authenticationFailedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } throw; @@ -201,8 +203,20 @@ namespace Microsoft.AspNet.Authentication.JwtBearer protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { + var eventContext = new JwtBearerChallengeContext(Context, Options); + await Options.Events.Challenge(eventContext); + if (eventContext.HandledResponse) + { + return true; + } + if (eventContext.Skipped) + { + return false; + } + Response.StatusCode = 401; - await Options.Events.Challenge(new JwtBearerChallengeContext(Context, Options)); + Response.Headers.Append(HeaderNames.WWWAuthenticate, Options.Challenge); + return false; } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs index 1d9c95d3cd..1d36e1437d 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs @@ -38,20 +38,20 @@ namespace Microsoft.AspNet.Authentication.OAuth var error = query["error"]; if (!StringValues.IsNullOrEmpty(error)) { - var errorMessage = new StringBuilder(); - errorMessage.Append(error); + var failureMessage = new StringBuilder(); + failureMessage.Append(error); var errorDescription = query["error_description"]; if (!StringValues.IsNullOrEmpty(errorDescription)) { - errorMessage.Append(";Description=").Append(errorDescription); + failureMessage.Append(";Description=").Append(errorDescription); } var errorUri = query["error_uri"]; if (!StringValues.IsNullOrEmpty(errorUri)) { - errorMessage.Append(";Uri=").Append(errorUri); + failureMessage.Append(";Uri=").Append(errorUri); } - return AuthenticateResult.Failed(errorMessage.ToString()); + return AuthenticateResult.Fail(failureMessage.ToString()); } var code = query["code"]; @@ -60,30 +60,30 @@ namespace Microsoft.AspNet.Authentication.OAuth properties = Options.StateDataFormat.Unprotect(state); if (properties == null) { - return AuthenticateResult.Failed("The oauth state was missing or invalid."); + return AuthenticateResult.Fail("The oauth state was missing or invalid."); } // OAuth2 10.12 CSRF if (!ValidateCorrelationId(properties)) { - return AuthenticateResult.Failed("Correlation failed."); + return AuthenticateResult.Fail("Correlation failed."); } if (StringValues.IsNullOrEmpty(code)) { - return AuthenticateResult.Failed("Code was not found."); + return AuthenticateResult.Fail("Code was not found."); } var tokens = await ExchangeCodeAsync(code, BuildRedirectUri(Options.CallbackPath)); if (tokens.Error != null) { - return AuthenticateResult.Failed(tokens.Error); + return AuthenticateResult.Fail(tokens.Error); } if (string.IsNullOrEmpty(tokens.AccessToken)) { - return AuthenticateResult.Failed("Failed to retrieve access token."); + return AuthenticateResult.Fail("Failed to retrieve access token."); } var identity = new ClaimsIdentity(Options.ClaimsIssuer); diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 5780bccfe7..124d8f543a 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -307,7 +307,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect // See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#Security if (!string.IsNullOrEmpty(message.IdToken) || !string.IsNullOrEmpty(message.AccessToken)) { - return AuthenticateResult.Failed("An OpenID Connect response cannot contain an " + + return AuthenticateResult.Fail("An OpenID Connect response cannot contain an " + "identity token or an access token when using response_mode=query"); } } @@ -324,7 +324,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect if (message == null) { - return AuthenticateResult.Failed("No message."); + return AuthenticateResult.Fail("No message."); } try @@ -336,7 +336,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } else if (messageReceivedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = messageReceivedContext.ProtocolMessage; @@ -345,7 +345,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { // This wasn't a valid ODIC message, it may not have been intended for us. Logger.LogDebug(11, "message.State is null or empty."); - return AuthenticateResult.Failed(Resources.MessageStateIsNullOrEmpty); + return AuthenticateResult.Fail(Resources.MessageStateIsNullOrEmpty); } // if state exists and we failed to 'unprotect' this is not a message we should process. @@ -353,14 +353,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect if (properties == null) { Logger.LogError(12, "Unable to unprotect the message.State."); - return AuthenticateResult.Failed(Resources.MessageStateIsInvalid); + return AuthenticateResult.Fail(Resources.MessageStateIsInvalid); } // if any of the error fields are set, throw error null if (!string.IsNullOrEmpty(message.Error)) { Logger.LogError(13, "Message contains error: '{0}', error_description: '{1}', error_uri: '{2}'.", message.Error, message.ErrorDescription ?? "ErrorDecription null", message.ErrorUri ?? "ErrorUri null"); - return AuthenticateResult.Failed(new OpenIdConnectProtocolException(string.Format(CultureInfo.InvariantCulture, Resources.MessageContainsError, message.Error, message.ErrorDescription ?? "ErrorDecription null", message.ErrorUri ?? "ErrorUri null"))); + return AuthenticateResult.Fail(new OpenIdConnectProtocolException(string.Format(CultureInfo.InvariantCulture, Resources.MessageContainsError, message.Error, message.ErrorDescription ?? "ErrorDecription null", message.ErrorUri ?? "ErrorUri null"))); } string userstate = null; @@ -369,7 +369,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect if (!ValidateCorrelationId(properties)) { - return AuthenticateResult.Failed("Correlation failed."); + return AuthenticateResult.Fail("Correlation failed."); } if (_configuration == null && Options.ConfigurationManager != null) @@ -393,7 +393,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect else if (authorizationResponseReceivedContext.Skipped) { Logger.LogDebug(17, "AuthorizationResponseReceived.Skipped"); - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = authorizationResponseReceivedContext.ProtocolMessage; properties = authorizationResponseReceivedContext.Properties; @@ -409,7 +409,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect else { Logger.LogTrace(18, "Cannot process the message. Both id_token and code are missing."); - return AuthenticateResult.Failed(Resources.IdTokenCodeMissing); + return AuthenticateResult.Fail(Resources.IdTokenCodeMissing); } } catch (Exception exception) @@ -433,7 +433,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } else if (authenticationFailedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } throw; @@ -459,7 +459,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } else if (authorizationCodeReceivedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = authorizationCodeReceivedContext.ProtocolMessage; var code = authorizationCodeReceivedContext.Code; @@ -476,7 +476,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } else if (authorizationCodeRedeemedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = authorizationCodeRedeemedContext.ProtocolMessage; @@ -509,7 +509,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } else if (authenticationValidatedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } ticket = authenticationValidatedContext.AuthenticationTicket; @@ -558,7 +558,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } else if (authenticationValidatedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = authenticationValidatedContext.ProtocolMessage; ticket = authenticationValidatedContext.AuthenticationTicket; @@ -573,7 +573,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } else if (authorizationCodeReceivedContext.Skipped) { - return AuthenticateResult.Success(ticket: null); + return AuthenticateResult.Skip(); } message = authorizationCodeReceivedContext.ProtocolMessage; ticket = authorizationCodeReceivedContext.AuthenticationTicket; @@ -671,7 +671,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } else if (userInformationReceivedContext.Skipped) { - return null; + return ticket; } ticket = userInformationReceivedContext.AuthenticationTicket; user = userInformationReceivedContext.User; diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs index 312c8c281e..0552ed2d76 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs @@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Authentication.Twitter if (requestToken == null) { - return AuthenticateResult.Failed("Invalid state cookie."); + return AuthenticateResult.Fail("Invalid state cookie."); } properties = requestToken.Properties; @@ -54,18 +54,18 @@ namespace Microsoft.AspNet.Authentication.Twitter var returnedToken = query["oauth_token"]; if (StringValues.IsNullOrEmpty(returnedToken)) { - return AuthenticateResult.Failed("Missing oauth_token"); + return AuthenticateResult.Fail("Missing oauth_token"); } if (!string.Equals(returnedToken, requestToken.Token, StringComparison.Ordinal)) { - return AuthenticateResult.Failed("Unmatched token"); + return AuthenticateResult.Fail("Unmatched token"); } var oauthVerifier = query["oauth_verifier"]; if (StringValues.IsNullOrEmpty(oauthVerifier)) { - return AuthenticateResult.Failed("Missing or blank oauth_verifier"); + return AuthenticateResult.Fail("Missing or blank oauth_verifier"); } var cookieOptions = new CookieOptions diff --git a/src/Microsoft.AspNet.Authentication/AuthenticateResult.cs b/src/Microsoft.AspNet.Authentication/AuthenticateResult.cs index 4f733fe7fd..25d87a4633 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticateResult.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticateResult.cs @@ -2,8 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Security.Claims; -using Microsoft.AspNet.Http.Authentication; namespace Microsoft.AspNet.Authentication { @@ -31,9 +29,14 @@ namespace Microsoft.AspNet.Authentication public AuthenticationTicket Ticket { get; private set; } /// - /// Holds error information caused by authentication. + /// Holds failure information from the authentication. /// - public Exception Error { get; private set; } + public Exception Failure { get; private set; } + + /// + /// Indicates that this stage of authentication was skipped by user intervention. + /// + public bool Skipped { get; private set; } public static AuthenticateResult Success(AuthenticationTicket ticket) { @@ -44,14 +47,19 @@ namespace Microsoft.AspNet.Authentication return new AuthenticateResult() { Ticket = ticket }; } - public static AuthenticateResult Failed(Exception error) + public static AuthenticateResult Skip() { - return new AuthenticateResult() { Error = error }; + return new AuthenticateResult() { Skipped = true }; } - public static AuthenticateResult Failed(string errorMessage) + public static AuthenticateResult Fail(Exception failure) { - return new AuthenticateResult() { Error = new Exception(errorMessage) }; + return new AuthenticateResult() { Failure = failure }; + } + + public static AuthenticateResult Fail(string failureMessage) + { + return new AuthenticateResult() { Failure = new Exception(failureMessage) }; } } diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs index 6dd298fbc7..9beeb24823 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs @@ -100,6 +100,10 @@ namespace Microsoft.AspNet.Authentication if (ShouldHandleScheme(AuthenticationManager.AutomaticScheme, Options.AutomaticAuthenticate)) { var result = await HandleAuthenticateOnceAsync(); + if (result.Failure != null) + { + Logger.LogInformation(0, $"{Options.AuthenticationScheme} not authenticated: " + result.Failure.Message); + } var ticket = result?.Ticket; if (ticket?.Principal != null) { @@ -200,9 +204,9 @@ namespace Microsoft.AspNet.Authentication // Calling Authenticate more than once should always return the original value. var result = await HandleAuthenticateOnceAsync(); - if (result?.Error != null) + if (result?.Failure != null) { - context.Failed(result.Error); + context.Failed(result.Failure); } else { diff --git a/src/Microsoft.AspNet.Authentication/Events/ErrorContext.cs b/src/Microsoft.AspNet.Authentication/Events/FailureContext.cs similarity index 60% rename from src/Microsoft.AspNet.Authentication/Events/ErrorContext.cs rename to src/Microsoft.AspNet.Authentication/Events/FailureContext.cs index a8ef4b5944..e0475d7363 100644 --- a/src/Microsoft.AspNet.Authentication/Events/ErrorContext.cs +++ b/src/Microsoft.AspNet.Authentication/Events/FailureContext.cs @@ -2,25 +2,24 @@ // 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.Http; namespace Microsoft.AspNet.Authentication { /// - /// Provides error context information to middleware providers. + /// Provides failure context information to middleware providers. /// - public class ErrorContext : BaseControlContext + public class FailureContext : BaseControlContext { - public ErrorContext(HttpContext context, Exception error) + public FailureContext(HttpContext context, Exception failure) : base(context) { - Error = error; + Failure = failure; } /// /// User friendly error message for the error. /// - public Exception Error { get; set; } + public Exception Failure { get; set; } } } diff --git a/src/Microsoft.AspNet.Authentication/Events/IRemoteAuthenticationEvents.cs b/src/Microsoft.AspNet.Authentication/Events/IRemoteAuthenticationEvents.cs index e19fd10b28..666783fd9c 100644 --- a/src/Microsoft.AspNet.Authentication/Events/IRemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNet.Authentication/Events/IRemoteAuthenticationEvents.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Authentication /// /// Invoked when the remote authentication process has an error. /// - Task RemoteError(ErrorContext context); + Task RemoteFailure(FailureContext context); /// /// Invoked before sign in. diff --git a/src/Microsoft.AspNet.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNet.Authentication/Events/RemoteAuthenticationEvents.cs index fce53b9927..d1c90be2f0 100644 --- a/src/Microsoft.AspNet.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNet.Authentication/Events/RemoteAuthenticationEvents.cs @@ -8,17 +8,17 @@ namespace Microsoft.AspNet.Authentication { public class RemoteAuthenticationEvents : IRemoteAuthenticationEvents { - public Func OnRemoteError { get; set; } = context => Task.FromResult(0); + public Func OnRemoteFailure { get; set; } = context => Task.FromResult(0); public Func OnTicketReceived { get; set; } = context => Task.FromResult(0); /// - /// Invoked when there is a remote error + /// Invoked when there is a remote failure /// - public virtual Task RemoteError(ErrorContext context) => OnRemoteError(context); + public virtual Task RemoteFailure(FailureContext context) => OnRemoteFailure(context); /// - /// Invoked after the remote ticket has been recieved. + /// Invoked after the remote ticket has been received. /// public virtual Task TicketReceived(TicketReceivedContext context) => OnTicketReceived(context); } diff --git a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs index 8c58d072dd..dda9063697 100644 --- a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs @@ -22,11 +22,15 @@ namespace Microsoft.AspNet.Authentication protected virtual async Task HandleRemoteCallbackAsync() { var authResult = await HandleRemoteAuthenticateAsync(); + if (authResult != null && authResult.Skipped) + { + return false; + } if (authResult == null || !authResult.Succeeded) { - var errorContext = new ErrorContext(Context, authResult?.Error ?? new Exception("Invalid return state, unable to redirect.")); - Logger.LogInformation("Error from RemoteAuthentication: " + errorContext.Error.Message); - await Options.Events.RemoteError(errorContext); + var errorContext = new FailureContext(Context, authResult?.Failure ?? new Exception("Invalid return state, unable to redirect.")); + Logger.LogInformation("Error from RemoteAuthentication: " + errorContext.Failure.Message); + await Options.Events.RemoteFailure(errorContext); if (errorContext.HandledResponse) { return true; @@ -36,7 +40,7 @@ namespace Microsoft.AspNet.Authentication return false; } - throw new AggregateException("Unhandled remote error.", errorContext.Error); + throw new AggregateException("Unhandled remote failure.", errorContext.Failure); } // We have a ticket if we get here @@ -77,7 +81,7 @@ namespace Microsoft.AspNet.Authentication protected override Task HandleAuthenticateAsync() { - return Task.FromResult(AuthenticateResult.Failed("Remote authentication does not support authenticate")); + return Task.FromResult(AuthenticateResult.Fail("Remote authentication does not support authenticate")); } protected override Task HandleSignOutAsync(SignOutContext context) diff --git a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs index 2e3336e057..77fc762840 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -261,9 +261,9 @@ namespace Microsoft.AspNet.Authentication.Google { options.Events = new OAuthEvents() { - OnRemoteError = ctx => + OnRemoteFailure = ctx => { - ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message)); + ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); ctx.HandleResponse(); return Task.FromResult(0); } @@ -275,7 +275,7 @@ namespace Microsoft.AspNet.Authentication.Google { var transaction = await sendTask; Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal("/error?ErrorMessage=OMG"+UrlEncoder.Default.Encode(";Description=SoBad;Uri=foobar"), transaction.Response.Headers.GetValues("Location").First()); + Assert.Equal("/error?FailureMessage=OMG"+UrlEncoder.Default.Encode(";Description=SoBad;Uri=foobar"), transaction.Response.Headers.GetValues("Location").First()); } else { @@ -389,9 +389,9 @@ namespace Microsoft.AspNet.Authentication.Google { options.Events = new OAuthEvents() { - OnRemoteError = ctx => + OnRemoteFailure = ctx => { - ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message)); + ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); ctx.HandleResponse(); return Task.FromResult(0); } @@ -412,7 +412,7 @@ namespace Microsoft.AspNet.Authentication.Google { var transaction = await sendTask; Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal("/error?ErrorMessage=" + UrlEncoder.Default.Encode("OAuth token endpoint failure: Status: BadRequest;Headers: ;Body: {\"Error\":\"Error\"};"), + Assert.Equal("/error?FailureMessage=" + UrlEncoder.Default.Encode("OAuth token endpoint failure: Status: BadRequest;Headers: ;Body: {\"Error\":\"Error\"};"), transaction.Response.Headers.GetValues("Location").First()); } else @@ -444,9 +444,9 @@ namespace Microsoft.AspNet.Authentication.Google { options.Events = new OAuthEvents() { - OnRemoteError = ctx => + OnRemoteFailure = ctx => { - ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message)); + ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); ctx.HandleResponse(); return Task.FromResult(0); } @@ -466,7 +466,7 @@ namespace Microsoft.AspNet.Authentication.Google { var transaction = await sendTask; Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal("/error?ErrorMessage=" + UrlEncoder.Default.Encode("Failed to retrieve access token."), + Assert.Equal("/error?FailureMessage=" + UrlEncoder.Default.Encode("Failed to retrieve access token."), transaction.Response.Headers.GetValues("Location").First()); } else @@ -737,9 +737,9 @@ namespace Microsoft.AspNet.Authentication.Google options.ClientSecret = "Test Secret"; options.Events = new OAuthEvents() { - OnRemoteError = ctx => + OnRemoteFailure = ctx => { - ctx.Response.Redirect("/error?ErrorMessage=" + UrlEncoder.Default.Encode(ctx.Error.Message)); + ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); ctx.HandleResponse(); return Task.FromResult(0); } @@ -751,7 +751,7 @@ namespace Microsoft.AspNet.Authentication.Google "https://example.com/signin-google?code=TestCode"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal("/error?ErrorMessage=" + UrlEncoder.Default.Encode("The oauth state was missing or invalid."), + Assert.Equal("/error?FailureMessage=" + UrlEncoder.Default.Encode("The oauth state was missing or invalid."), transaction.Response.Headers.GetValues("Location").First()); } diff --git a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index aaef7ffa91..6100957cac 100644 --- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -11,6 +11,7 @@ using System.Xml.Linq; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.AspNet.TestHost; using Microsoft.AspNet.Testing.xunit; using Microsoft.Extensions.DependencyInjection; @@ -312,6 +313,163 @@ namespace Microsoft.AspNet.Authentication.JwtBearer Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); } + [Fact] + public async Task EventOnReceivingTokenSkipped_NoMoreEventsExecuted() + { + var server = CreateServer(options => + { + options.AutomaticAuthenticate = true; + + options.Events = new JwtBearerEvents() + { + OnReceivingToken = context => + { + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnReceivedToken = context => + { + throw new NotImplementedException(); + }, + OnValidatedToken = context => + { + throw new NotImplementedException(); + }, + OnAuthenticationFailed = context => + { + throw new NotImplementedException(context.Exception.ToString()); + }, + OnChallenge = context => + { + throw new NotImplementedException(); + }, + }; + }); + + var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); + Assert.Equal(string.Empty, response.ResponseText); + } + + [Fact] + public async Task EventOnReceivedTokenSkipped_NoMoreEventsExecuted() + { + var server = CreateServer(options => + { + options.AutomaticAuthenticate = true; + + options.Events = new JwtBearerEvents() + { + OnReceivedToken = context => + { + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnValidatedToken = context => + { + throw new NotImplementedException(); + }, + OnAuthenticationFailed = context => + { + throw new NotImplementedException(context.Exception.ToString()); + }, + OnChallenge = context => + { + throw new NotImplementedException(); + }, + }; + }); + + var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); + Assert.Equal(string.Empty, response.ResponseText); + } + + [Fact] + public async Task EventOnValidatedTokenSkipped_NoMoreEventsExecuted() + { + var server = CreateServer(options => + { + options.AutomaticAuthenticate = true; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + options.Events = new JwtBearerEvents() + { + OnValidatedToken = context => + { + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnAuthenticationFailed = context => + { + throw new NotImplementedException(context.Exception.ToString()); + }, + OnChallenge = context => + { + throw new NotImplementedException(); + }, + }; + }); + + var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); + Assert.Equal(string.Empty, response.ResponseText); + } + + [Fact] + public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() + { + var server = CreateServer(options => + { + options.AutomaticAuthenticate = true; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + options.Events = new JwtBearerEvents() + { + OnValidatedToken = context => + { + throw new Exception("Test Exception"); + }, + OnAuthenticationFailed = context => + { + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnChallenge = context => + { + throw new NotImplementedException(); + }, + }; + }); + + var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); + Assert.Equal(string.Empty, response.ResponseText); + } + + [Fact] + public async Task EventOnChallengeSkipped_ResponseNotModified() + { + var server = CreateServer(options => + { + options.AutomaticAuthenticate = true; + options.AutomaticChallenge = true; + options.Events = new JwtBearerEvents() + { + OnChallenge = context => + { + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + }; + }); + + var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); + Assert.Empty(response.Response.Headers.WwwAuthenticate); + Assert.Equal(string.Empty, response.ResponseText); + } + class InvalidTokenValidator : ISecurityTokenValidator { public InvalidTokenValidator() @@ -387,7 +545,17 @@ namespace Microsoft.AspNet.Authentication.JwtBearer app.Use(async (context, next) => { - if (context.Request.Path == new PathString("/oauth")) + if (context.Request.Path == new PathString("/checkforerrors")) + { + var authContext = new AuthenticateContext(Http.Authentication.AuthenticationManager.AutomaticScheme); + await context.Authentication.AuthenticateAsync(authContext); + if (authContext.Error != null) + { + throw new Exception("Failed to authenticate", authContext.Error); + } + return; + } + else if (context.Request.Path == new PathString("/oauth")) { if (context.User == null || context.User.Identity == null || @@ -408,14 +576,12 @@ namespace Microsoft.AspNet.Authentication.JwtBearer await context.Response.WriteAsync(identifier.Value); } - 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); } - else if (context.Request.Path == new PathString("/signIn")) { await Assert.ThrowsAsync(() => context.Authentication.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); From a1ed3e3748248eae66578eb2799f075512a7639f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 11 Dec 2015 12:23:59 -0800 Subject: [PATCH 422/900] Updating to release NuGet.config. --- NuGet.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.config b/NuGet.config index 5500f6d507..71b9724a09 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + From 965a86e404207a3e37e31cad9b82fb1d5e279bfa Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 10 Dec 2015 12:00:03 -0800 Subject: [PATCH 423/900] #593 Convert samples to use UserSecrets. --- samples/JwtBearerSample/Startup.cs | 15 +++++- samples/JwtBearerSample/project.json | 6 ++- samples/OpenIdConnectSample/Startup.cs | 17 +++++-- samples/OpenIdConnectSample/project.json | 4 +- samples/SocialSample/Startup.cs | 62 ++++++++++++++++-------- samples/SocialSample/config.json | 10 ++++ samples/SocialSample/project.json | 4 +- 7 files changed, 89 insertions(+), 29 deletions(-) create mode 100644 samples/SocialSample/config.json diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index c79cbda951..33e8076955 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -4,6 +4,7 @@ using System.IO; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Net.Http.Headers; using Newtonsoft.Json.Linq; @@ -12,6 +13,16 @@ namespace JwtBearerSample { public class Startup { + public Startup() + { + Configuration = new ConfigurationBuilder() + .AddEnvironmentVariables() + .AddUserSecrets() + .Build(); + } + + public IConfiguration Configuration { get; set; } + // Shared between users in memory public IList Todos { get; } = new List(); @@ -53,8 +64,8 @@ namespace JwtBearerSample options.AutomaticAuthenticate = true; options.AutomaticChallenge = true; // You also need to update /wwwroot/app/scripts/app.js - options.Authority = "https://login.windows.net/tratcheroutlook.onmicrosoft.com"; - options.Audience = "63a87a83-64b9-4ac1-b2c5-092126f8474f"; + options.Authority = Configuration["jwt:authority"]; + options.Audience = Configuration["jwt:audience"]; }); // [Authorize] would usually handle this diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 2e9dca157a..cc2350bb97 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -7,7 +7,8 @@ "Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-*", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.StaticFiles": "1.0.0-*" + "Microsoft.AspNet.StaticFiles": "1.0.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*" }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel" @@ -23,5 +24,6 @@ "publishExclude": [ "**.user", "**.vspscc" - ] + ], + "userSecretsId": "aspnet5-JwtBearerSample-20151210102827" } diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 73fe2b8b49..3e39d36541 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -4,6 +4,7 @@ using Microsoft.AspNet.Authentication.OpenIdConnect; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -12,6 +13,16 @@ namespace OpenIdConnectSample { public class Startup { + public Startup() + { + Configuration = new ConfigurationBuilder() + .AddEnvironmentVariables() + .AddUserSecrets() + .Build(); + } + + public IConfiguration Configuration { get; set; } + public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(sharedOptions => sharedOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); @@ -30,9 +41,9 @@ namespace OpenIdConnectSample app.UseOpenIdConnectAuthentication(options => { - options.ClientId = "63a87a83-64b9-4ac1-b2c5-092126f8474f"; - options.ClientSecret = "Yse2iP7tO1Azq0iDajNisMaTSnIDv+FXmAsFuXr+Cy8="; // for code flow - options.Authority = "https://login.windows.net/tratcheroutlook.onmicrosoft.com"; + options.ClientId = Configuration["oidc:clientid"]; + options.ClientSecret = Configuration["oidc:clientsecret"]; // for code flow + options.Authority = Configuration["oidc:authority"]; options.ResponseType = OpenIdConnectResponseTypes.Code; options.GetClaimsFromUserInfoEndpoint = true; }); diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 918dbcf3f1..21f0633824 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -5,6 +5,7 @@ "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "frameworks": { @@ -15,5 +16,6 @@ "web": "Microsoft.AspNet.Server.Kestrel", "kestrel": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:42023", "weblistener": "Microsoft.AspNet.Server.WebListener --server.urls http://localhost:42023" - } + }, + "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" } diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 01d26fcdf3..5ca189aa91 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -14,6 +14,7 @@ using Microsoft.AspNet.Authentication.Twitter; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; @@ -23,6 +24,17 @@ namespace CookieSample /* Note all servers must use the same address and port because these are pre-registered with the various providers. */ public class Startup { + public Startup() + { + Configuration = new ConfigurationBuilder() + .AddEnvironmentVariables() + .AddJsonFile("config.json") + .AddUserSecrets() + .Build(); + } + + public IConfiguration Configuration { get; set; } + public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(options => options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); @@ -57,32 +69,36 @@ namespace CookieSample options.LoginPath = new PathString("/login"); }); + // You must first create an app with facebook and add it's ID and Secret to your config.json or user-secrets. // https://developers.facebook.com/apps/ app.UseFacebookAuthentication(new FacebookOptions() { - AppId = "569522623154478", - AppSecret = "a124463c4719c94b4228d9a240e5dc1a", + AppId = Configuration["facebook:appid"], + AppSecret = Configuration["facebook:appsecret"], Scope = { "email" }, Fields = { "name", "email" }, }); + // See config.json app.UseOAuthAuthentication(new OAuthOptions { AuthenticationScheme = "Google-AccessToken", DisplayName = "Google-AccessToken", - ClientId = "560027070069-37ldt4kfuohhu3m495hk2j4pjp92d382.apps.googleusercontent.com", - ClientSecret = "n2Q-GEw9RQjzcRbU3qhfTj8f", + ClientId = Configuration["google:clientid"], + ClientSecret = Configuration["google:clientsecret"], CallbackPath = new PathString("/signin-google-token"), AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint, TokenEndpoint = GoogleDefaults.TokenEndpoint, - Scope = { "openid", "profile", "email" } + Scope = { "openid", "profile", "email" }, + SaveTokensAsClaims = true }); + // See config.json // https://console.developers.google.com/project app.UseGoogleAuthentication(options => { - options.ClientId = "560027070069-37ldt4kfuohhu3m495hk2j4pjp92d382.apps.googleusercontent.com"; - options.ClientSecret = "n2Q-GEw9RQjzcRbU3qhfTj8f"; + options.ClientId = Configuration["google:clientid"]; + options.ClientSecret = Configuration["google:clientsecret"]; options.Events = new OAuthEvents() { OnRemoteFailure = ctx => @@ -96,11 +112,12 @@ namespace CookieSample }); + // See config.json // https://apps.twitter.com/ app.UseTwitterAuthentication(options => { - options.ConsumerKey = "6XaCTaLbMqfj6ww3zvZ5g"; - options.ConsumerSecret = "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI"; + options.ConsumerKey = Configuration["twitter:consumerkey"]; + options.ConsumerSecret = Configuration["twitter:consumersecret"]; options.Events = new TwitterEvents() { OnRemoteFailure = ctx => @@ -112,6 +129,7 @@ namespace CookieSample }; }); + // You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. /* https://account.live.com/developers/applications The MicrosoftAccount service has restrictions that prevent the use of http://localhost:54540/ for test applications. As such, here is how to change this sample to uses http://mssecsample.localhost.this:54540/ instead. @@ -133,46 +151,50 @@ namespace CookieSample { AuthenticationScheme = "Microsoft-AccessToken", DisplayName = "MicrosoftAccount-AccessToken - Requires project changes", - ClientId = "00000000480FF62E", - ClientSecret = "bLw2JIvf8Y1TaToipPEqxTVlOeJwCUsr", + ClientId = Configuration["msa:clientid"], + ClientSecret = Configuration["msa:clientsecret"], CallbackPath = new PathString("/signin-microsoft-token"), AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint, TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint, - Scope = { "wl.basic" } + Scope = { "wl.basic" }, + SaveTokensAsClaims = true }); + // You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. app.UseMicrosoftAccountAuthentication(options => { options.DisplayName = "MicrosoftAccount - Requires project changes"; - options.ClientId = "00000000480FF62E"; - options.ClientSecret = "bLw2JIvf8Y1TaToipPEqxTVlOeJwCUsr"; + options.ClientId = Configuration["msa:clientid"]; + options.ClientSecret = Configuration["msa:clientsecret"]; options.Scope.Add("wl.emails"); }); + // See config.json // https://github.com/settings/applications/ app.UseOAuthAuthentication(new OAuthOptions { AuthenticationScheme = "GitHub-AccessToken", DisplayName = "Github-AccessToken", - ClientId = "8c0c5a572abe8fe89588", - ClientSecret = "e1d95eaf03461d27acd6f49d4fc7bf19d6ac8cda", + ClientId = Configuration["github-token:clientid"], + ClientSecret = Configuration["github-token:clientsecret"], CallbackPath = new PathString("/signin-github-token"), AuthorizationEndpoint = "https://github.com/login/oauth/authorize", - TokenEndpoint = "https://github.com/login/oauth/access_token" + TokenEndpoint = "https://github.com/login/oauth/access_token", + SaveTokensAsClaims = true }); + // See config.json app.UseOAuthAuthentication(new OAuthOptions { AuthenticationScheme = "GitHub", DisplayName = "Github", - ClientId = "49e302895d8b09ea5656", - ClientSecret = "98f1bf028608901e9df91d64ee61536fe562064b", + ClientId = Configuration["github:clientid"], + ClientSecret = Configuration["github:clientsecret"], CallbackPath = new PathString("/signin-github"), AuthorizationEndpoint = "https://github.com/login/oauth/authorize", TokenEndpoint = "https://github.com/login/oauth/access_token", UserInformationEndpoint = "https://api.github.com/user", ClaimsIssuer = "OAuth2-Github", - SaveTokensAsClaims = false, // Retrieving user information is unique to each provider. Events = new OAuthEvents { diff --git a/samples/SocialSample/config.json b/samples/SocialSample/config.json new file mode 100644 index 0000000000..13d3ff94a0 --- /dev/null +++ b/samples/SocialSample/config.json @@ -0,0 +1,10 @@ +{ + "google:clientid": "560027070069-37ldt4kfuohhu3m495hk2j4pjp92d382.apps.googleusercontent.com", + "google:clientsecret": "n2Q-GEw9RQjzcRbU3qhfTj8f", + "twitter:consumerkey": "6XaCTaLbMqfj6ww3zvZ5g", + "twitter:consumersecret": "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI", + "github:clientid": "49e302895d8b09ea5656", + "github:clientsecret": "98f1bf028608901e9df91d64ee61536fe562064b", + "github-token:clientid": "8c0c5a572abe8fe89588", + "github-token:clientsecret": "e1d95eaf03461d27acd6f49d4fc7bf19d6ac8cda" +} diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 823ac24c01..14c7606f15 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -9,6 +9,7 @@ "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "commands": { @@ -19,5 +20,6 @@ "frameworks": { "dnx451": { }, "dnxcore50": { } - } + }, + "userSecretsId": "aspnet5-SocialSample-20151210111056" } From a0418070231e7444721047a4153eaaa05876b449 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 18 Dec 2015 10:49:37 -0800 Subject: [PATCH 424/900] Reacting to new Hosting API --- .../Properties/launchSettings.json | 5 - samples/CookieSample/Startup.cs | 11 + samples/CookieSample/hosting.json | 3 + samples/CookieSample/project.json | 7 +- .../Properties/launchSettings.json | 5 - samples/CookieSessionSample/Startup.cs | 11 + samples/CookieSessionSample/hosting.json | 3 + samples/CookieSessionSample/project.json | 7 +- samples/JwtBearerSample/Startup.cs | 10 +- samples/JwtBearerSample/hosting.json | 3 + samples/JwtBearerSample/project.json | 2 +- .../Properties/launchSettings.json | 8 +- samples/OpenIdConnectSample/Startup.cs | 11 + samples/OpenIdConnectSample/hosting.json | 3 + samples/OpenIdConnectSample/project.json | 8 +- .../Properties/launchSettings.json | 9 +- samples/SocialSample/Startup.cs | 13 +- samples/SocialSample/hosting.json | 3 + samples/SocialSample/project.json | 8 +- .../Cookies/CookieMiddlewareTests.cs | 323 ++++++++++-------- .../Facebook/FacebookMiddlewareTests.cs | 28 +- .../Google/GoogleMiddlewareTests.cs | 133 ++++---- .../JwtBearer/JwtBearerMiddlewareTests.cs | 107 +++--- .../MicrosoftAccountMiddlewareTests.cs | 87 ++--- .../OpenIdConnectHandlerTests.cs | 13 +- .../OpenIdConnectMiddlewareTests.cs | 109 +++--- .../Twitter/TwitterMiddlewareTests.cs | 71 ++-- .../CookiePolicyTests.cs | 35 +- .../TicketInteropTests.cs | 33 +- 29 files changed, 590 insertions(+), 479 deletions(-) create mode 100644 samples/CookieSample/hosting.json create mode 100644 samples/CookieSessionSample/hosting.json create mode 100644 samples/JwtBearerSample/hosting.json create mode 100644 samples/OpenIdConnectSample/hosting.json create mode 100644 samples/SocialSample/hosting.json diff --git a/samples/CookieSample/Properties/launchSettings.json b/samples/CookieSample/Properties/launchSettings.json index 9077103681..c85de8d26e 100644 --- a/samples/CookieSample/Properties/launchSettings.json +++ b/samples/CookieSample/Properties/launchSettings.json @@ -22,11 +22,6 @@ "environmentVariables": { "Hosting:Environment": "Development" } - }, - "kestrel": { - "commandName": "kestrel", - "launchBrowser": true, - "launchUrl": "http://localhost:5004" } } } \ No newline at end of file diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 2d77ae1bb4..dca9105128 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Security.Claims; using Microsoft.AspNet.Authentication.Cookies; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -40,5 +41,15 @@ namespace CookieSample await context.Response.WriteAsync("Hello old timer"); }); } + + public static void Main(string[] args) + { + var application = new WebApplicationBuilder() + .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseStartup() + .Build(); + + application.Run(); + } } } \ No newline at end of file diff --git a/samples/CookieSample/hosting.json b/samples/CookieSample/hosting.json new file mode 100644 index 0000000000..f8ef14574d --- /dev/null +++ b/samples/CookieSample/hosting.json @@ -0,0 +1,3 @@ +{ + "server": "Microsoft.AspNet.Server.Kestrel" +} diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 030c149834..20c5e0249d 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -4,12 +4,13 @@ "Microsoft.AspNet.DataProtection": "1.0.0-*", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, + "compilationOptions": { + "emitEntryPoint": true + }, "commands": { - "web": "Microsoft.AspNet.Server.Kestrel", - "weblistener": "Microsoft.AspNet.Server.WebListener" + "web": "CookieSample" }, "frameworks": { "dnx451": { }, diff --git a/samples/CookieSessionSample/Properties/launchSettings.json b/samples/CookieSessionSample/Properties/launchSettings.json index f4fbdd3fde..8d4a0316ab 100644 --- a/samples/CookieSessionSample/Properties/launchSettings.json +++ b/samples/CookieSessionSample/Properties/launchSettings.json @@ -22,11 +22,6 @@ "environmentVariables": { "Hosting:Environment": "Development" } - }, - "kestrel": { - "commandName": "kestrel", - "launchBrowser": true, - "launchUrl": "http://localhost:5004" } } } \ No newline at end of file diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 5affb5afaf..bf7200ca6a 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Security.Claims; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Authentication.Cookies; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -50,5 +51,15 @@ namespace CookieSessionSample await context.Response.WriteAsync("Hello old timer"); }); } + + public static void Main(string[] args) + { + var application = new WebApplicationBuilder() + .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseStartup() + .Build(); + + application.Run(); + } } } \ No newline at end of file diff --git a/samples/CookieSessionSample/hosting.json b/samples/CookieSessionSample/hosting.json new file mode 100644 index 0000000000..f8ef14574d --- /dev/null +++ b/samples/CookieSessionSample/hosting.json @@ -0,0 +1,3 @@ +{ + "server": "Microsoft.AspNet.Server.Kestrel" +} diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index a1c5ad3c6c..cddabac495 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -4,13 +4,14 @@ "Microsoft.AspNet.DataProtection": "1.0.0-*", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*", "Microsoft.Extensions.Caching.Memory": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, + "compilationOptions": { + "emitEntryPoint": true + }, "commands": { - "web": "Microsoft.AspNet.Server.Kestrel", - "weblistener": "Microsoft.AspNet.Server.WebListener" + "web": "CookieSessionSample" }, "frameworks": { "dnx451": { }, diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 33e8076955..88032b8e69 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -112,6 +112,14 @@ namespace JwtBearerSample } // Entry point for the application. - public static void Main(string[] args) => WebApplication.Run(args); + public static void Main(string[] args) + { + var application = new WebApplicationBuilder() + .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseStartup() + .Build(); + + application.Run(); + } } } diff --git a/samples/JwtBearerSample/hosting.json b/samples/JwtBearerSample/hosting.json new file mode 100644 index 0000000000..f8ef14574d --- /dev/null +++ b/samples/JwtBearerSample/hosting.json @@ -0,0 +1,3 @@ +{ + "server": "Microsoft.AspNet.Server.Kestrel" +} diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index cc2350bb97..bfb35107ef 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -11,7 +11,7 @@ "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*" }, "commands": { - "web": "Microsoft.AspNet.Server.Kestrel" + "web": "JwtBearerSample" }, "frameworks": { "dnx451": { }, diff --git a/samples/OpenIdConnectSample/Properties/launchSettings.json b/samples/OpenIdConnectSample/Properties/launchSettings.json index 3d9d32eebe..c75dba9f49 100644 --- a/samples/OpenIdConnectSample/Properties/launchSettings.json +++ b/samples/OpenIdConnectSample/Properties/launchSettings.json @@ -15,17 +15,13 @@ "ASPNET_ENV": "Development" } }, - "kestrel": { - "commandName": "kestrel", - "launchBrowser": true, - "launchUrl": "http://localhost:42023" - }, "web": { "commandName": "web", "launchBrowser": true, "launchUrl": "http://localhost:42023", "environmentVariables": { - "Hosting:Environment": "Development" + "Hosting:Environment": "Development", + "ASPNET_server.urls": "http://localhost:42023" } } } diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 3e39d36541..67a979ea91 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -2,6 +2,7 @@ using System.Linq; using Microsoft.AspNet.Authentication.Cookies; using Microsoft.AspNet.Authentication.OpenIdConnect; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.Extensions.Configuration; @@ -63,5 +64,15 @@ namespace OpenIdConnectSample await context.Response.WriteAsync("Hello Authenticated User"); }); } + + public static void Main(string[] args) + { + var application = new WebApplicationBuilder() + .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseStartup() + .Build(); + + application.Run(); + } } } diff --git a/samples/OpenIdConnectSample/hosting.json b/samples/OpenIdConnectSample/hosting.json new file mode 100644 index 0000000000..f8ef14574d --- /dev/null +++ b/samples/OpenIdConnectSample/hosting.json @@ -0,0 +1,3 @@ +{ + "server": "Microsoft.AspNet.Server.Kestrel" +} diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 21f0633824..9a204e1425 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -4,7 +4,6 @@ "Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, @@ -12,10 +11,11 @@ "dnx451": { }, "dnxcore50": { } }, + "compilationOptions": { + "emitEntryPoint": true + }, "commands": { - "web": "Microsoft.AspNet.Server.Kestrel", - "kestrel": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:42023", - "weblistener": "Microsoft.AspNet.Server.WebListener --server.urls http://localhost:42023" + "web": "OpenIdConnectSample" }, "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" } diff --git a/samples/SocialSample/Properties/launchSettings.json b/samples/SocialSample/Properties/launchSettings.json index dcfe9f5144..b10006b86c 100644 --- a/samples/SocialSample/Properties/launchSettings.json +++ b/samples/SocialSample/Properties/launchSettings.json @@ -10,22 +10,17 @@ "profiles": { "IIS Express": { "commandName": "IISExpress", - "launchBrowser": true, "environmentVariables": { "ASPNET_ENV": "Development" } }, - "kestrel": { - "commandName": "kestrel", - "launchBrowser": true, - "launchUrl": "http://localhost:54540/" - }, "web": { "commandName": "web", "launchBrowser": true, "launchUrl": "http://localhost:54540/", "environmentVariables": { - "Hosting:Environment": "Development" + "Hosting:Environment": "Development", + "ASPNET_server.urls": "http://localhost:54540/" } } } diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 5ca189aa91..59c57862ae 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -12,6 +12,7 @@ using Microsoft.AspNet.Authentication.MicrosoftAccount; using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Authentication.Twitter; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.Extensions.Configuration; @@ -160,7 +161,7 @@ namespace CookieSample SaveTokensAsClaims = true }); - // You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. + //// You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. app.UseMicrosoftAccountAuthentication(options => { options.DisplayName = "MicrosoftAccount - Requires project changes"; @@ -323,5 +324,15 @@ namespace CookieSample await context.Response.WriteAsync(""); }); } + + public static void Main(string[] args) + { + var application = new WebApplicationBuilder() + .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseStartup() + .Build(); + + application.Run(); + } } } diff --git a/samples/SocialSample/hosting.json b/samples/SocialSample/hosting.json new file mode 100644 index 0000000000..f8ef14574d --- /dev/null +++ b/samples/SocialSample/hosting.json @@ -0,0 +1,3 @@ +{ + "server": "Microsoft.AspNet.Server.Kestrel" +} diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 14c7606f15..53ade790cd 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -8,14 +8,14 @@ "Microsoft.AspNet.DataProtection": "1.0.0-*", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, + "compilationOptions": { + "emitEntryPoint": true + }, "commands": { - "web": "Microsoft.AspNet.Server.Kestrel", - "kestrel": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:54540", - "weblistener": "Microsoft.AspNet.Server.WebListener --server.urls=http://localhost:54540" + "web": "SocialSample" }, "frameworks": { "dnx451": { }, diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 8af2b88780..db27680d42 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; @@ -748,12 +749,14 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWillNotAffectChallenge() { - var server = TestServer.Create(app => + var builder = new WebApplicationBuilder() + .Configure(app => { app.UseCookieAuthentication(options => options.LoginPath = new PathString("/page")); app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); - }, - services => services.AddAuthentication()); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/login"); @@ -767,14 +770,17 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task ChallengeDoesNotSet401OnUnauthorized() { - var server = TestServer.Create(app => - { - app.UseCookieAuthentication(); - app.Run(async context => + var builder = new WebApplicationBuilder() + .Configure(app => { - await Assert.ThrowsAsync(() => context.Authentication.ChallengeAsync()); - }); - }, services => services.AddAuthentication()); + app.UseCookieAuthentication(); + app.Run(async context => + { + await Assert.ThrowsAsync(() => context.Authentication.ChallengeAsync()); + }); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -783,12 +789,15 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task UseCookieWithInstanceDoesntUseSharedOptions() { - var server = TestServer.Create(app => - { - app.UseCookieAuthentication(options => options.CookieName = "One"); - app.UseCookieAuthentication(new CookieAuthenticationOptions()); - app.Run(context => context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity()))); - }, services => services.AddAuthentication()); + var builder = new WebApplicationBuilder() + .Configure(app => + { + app.UseCookieAuthentication(options => options.CookieName = "One"); + app.UseCookieAuthentication(new CookieAuthenticationOptions()); + app.Run(context => context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity()))); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com"); @@ -799,13 +808,15 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath() { - var server = TestServer.Create(app => - { - app.UseCookieAuthentication(options => options.LoginPath = new PathString("/login")); - app.Map("/notlogin", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies", - new ClaimsPrincipal()))); - }, - services => services.AddAuthentication()); + var builder = new WebApplicationBuilder() + .Configure(app => + { + app.UseCookieAuthentication(options => options.LoginPath = new PathString("/login")); + app.Map("/notlogin", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies", + new ClaimsPrincipal()))); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/notlogin?ReturnUrl=%2Fpage"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -815,13 +826,15 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWillNotAffectSignInRedirectToReturnUrl() { - var server = TestServer.Create(app => - { - app.UseCookieAuthentication(options => options.LoginPath = new PathString("/login")); - app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies", - new ClaimsPrincipal()))); - }, - services => services.AddAuthentication()); + var builder = new WebApplicationBuilder() + .Configure(app => + { + app.UseCookieAuthentication(options => options.LoginPath = new PathString("/login")); + app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies", + new ClaimsPrincipal()))); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/login?ReturnUrl=%2Fpage"); @@ -835,12 +848,14 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() { - var server = TestServer.Create(app => - { - app.UseCookieAuthentication(options => options.LogoutPath = new PathString("/logout")); - app.Map("/notlogout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies"))); - }, - services => services.AddAuthentication()); + var builder = new WebApplicationBuilder() + .Configure(app => + { + app.UseCookieAuthentication(options => options.LogoutPath = new PathString("/logout")); + app.Map("/notlogout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies"))); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/notlogout?ReturnUrl=%2Fpage"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -850,12 +865,14 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWillNotAffectSignOutRedirectToReturnUrl() { - var server = TestServer.Create(app => - { - app.UseCookieAuthentication(options => options.LogoutPath = new PathString("/logout")); - app.Map("/logout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies"))); - }, - services => services.AddAuthentication()); + var builder = new WebApplicationBuilder() + .Configure(app => + { + app.UseCookieAuthentication(options => options.LogoutPath = new PathString("/logout")); + app.Map("/logout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies"))); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/logout?ReturnUrl=%2Fpage"); @@ -869,12 +886,14 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWillNotAffectAccessDenied() { - var server = TestServer.Create(app => + var builder = new WebApplicationBuilder() + .Configure(app => { app.UseCookieAuthentication(options => options.AccessDeniedPath = new PathString("/denied")); app.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies"))); - }, - services => services.AddAuthentication()); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/forbid"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -886,13 +905,15 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task NestedMapWillNotAffectLogin() { - var server = TestServer.Create(app => - app.Map("/base", map => - { - map.UseCookieAuthentication(options => options.LoginPath = new PathString("/page")); - map.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); - }), - services => services.AddAuthentication()); + var builder = new WebApplicationBuilder() + .Configure(app => + app.Map("/base", map => + { + map.UseCookieAuthentication(options => options.LoginPath = new PathString("/page")); + map.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); + })) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/base/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -905,13 +926,15 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task NestedMapWillNotAffectAccessDenied() { - var server = TestServer.Create(app => - app.Map("/base", map => - { - map.UseCookieAuthentication(options => options.AccessDeniedPath = new PathString("/denied")); - map.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies"))); - }), - services => services.AddAuthentication()); + var builder = new WebApplicationBuilder() + .Configure(app => + app.Map("/base", map => + { + map.UseCookieAuthentication(options => options.AccessDeniedPath = new PathString("/denied")); + map.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies"))); + })) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/base/forbid"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -925,39 +948,43 @@ namespace Microsoft.AspNet.Authentication.Cookies { var dp = new NoOpDataProtector(); - var server1 = TestServer.Create(app => - { - app.UseCookieAuthentication(options => + var builder1 = new WebApplicationBuilder() + .Configure(app => { - options.TicketDataFormat = new TicketDataFormat(dp); - options.CookieName = "Cookie"; - }); - app.Use((context, next) => - context.Authentication.SignInAsync("Cookies", - new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), - new AuthenticationProperties())); - }, - services => services.AddAuthentication()); + app.UseCookieAuthentication(options => + { + options.TicketDataFormat = new TicketDataFormat(dp); + options.CookieName = "Cookie"; + }); + app.Use((context, next) => + context.Authentication.SignInAsync("Cookies", + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), + new AuthenticationProperties())); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server1 = new TestServer(builder1); var transaction = await SendAsync(server1, "http://example.com/stuff"); Assert.NotNull(transaction.SetCookie); - var server2 = TestServer.Create(app => - { - app.UseCookieAuthentication(options => + var builder2 = new WebApplicationBuilder() + .Configure(app => { - options.AuthenticationScheme = "Cookies"; - options.CookieName = "Cookie"; - options.TicketDataFormat = new TicketDataFormat(dp); - }); - app.Use(async (context, next) => - { - var authContext = new AuthenticateContext("Cookies"); - await context.Authentication.AuthenticateAsync(authContext); - Describe(context.Response, authContext); - }); - }, - services => services.AddAuthentication()); + app.UseCookieAuthentication(options => + { + options.AuthenticationScheme = "Cookies"; + options.CookieName = "Cookie"; + options.TicketDataFormat = new TicketDataFormat(dp); + }); + app.Use(async (context, next) => + { + var authContext = new AuthenticateContext("Cookies"); + await context.Authentication.AuthenticateAsync(authContext); + Describe(context.Response, authContext); + }); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server2 = new TestServer(builder2); var transaction2 = await SendAsync(server2, "http://example.com/stuff", transaction.CookieNameValue); Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); } @@ -1003,71 +1030,73 @@ namespace Microsoft.AspNet.Authentication.Cookies private static TestServer CreateServer(Action configureOptions, Func testpath = null, Uri baseAddress = null, Action claimsTransform = null) { - var server = TestServer.Create(app => - { - app.UseCookieAuthentication(configureOptions); - // app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "Cookie2" }); + var builder = new WebApplicationBuilder() + .Configure(app => + { + app.UseCookieAuthentication(configureOptions); + // app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "Cookie2" }); - if (claimsTransform != null) - { - app.UseClaimsTransformation(claimsTransform); - } - app.Use(async (context, next) => - { - var req = context.Request; - var res = context.Response; - PathString remainder; - if (req.Path == new PathString("/normal")) + if (claimsTransform != null) { - res.StatusCode = 200; + app.UseClaimsTransformation(claimsTransform); } - else if (req.Path == new PathString("/protected")) + app.Use(async (context, next) => { - res.StatusCode = 401; - } - else if (req.Path == new PathString("/forbid")) // Simulate forbidden - { - await context.Authentication.ForbidAsync(CookieAuthenticationDefaults.AuthenticationScheme); - } - else if (req.Path == new PathString("/challenge")) - { - await context.Authentication.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme); - } - else if (req.Path == new PathString("/signout")) - { - await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - } - else if (req.Path == new PathString("/unauthorized")) - { - await context.Authentication.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme, new AuthenticationProperties(), ChallengeBehavior.Unauthorized); - } - else if (req.Path == new PathString("/protected/CustomRedirect")) - { - await context.Authentication.ChallengeAsync(new AuthenticationProperties() { RedirectUri = "/CustomRedirect" }); - } - else if (req.Path == new PathString("/me")) - { - var authContext = new AuthenticateContext(CookieAuthenticationDefaults.AuthenticationScheme); - authContext.Authenticated(context.User, properties: null, description: null); - Describe(res, authContext); - } - else if (req.Path.StartsWithSegments(new PathString("/me"), out remainder)) - { - var authContext = new AuthenticateContext(remainder.Value.Substring(1)); - await context.Authentication.AuthenticateAsync(authContext); - Describe(res, authContext); - } - else if (req.Path == new PathString("/testpath") && testpath != null) - { - await testpath(context); - } - else - { - await next(); - } - }); - }, - services => services.AddAuthentication()); + var req = context.Request; + var res = context.Response; + PathString remainder; + if (req.Path == new PathString("/normal")) + { + res.StatusCode = 200; + } + else if (req.Path == new PathString("/protected")) + { + res.StatusCode = 401; + } + else if (req.Path == new PathString("/forbid")) // Simulate forbidden + { + await context.Authentication.ForbidAsync(CookieAuthenticationDefaults.AuthenticationScheme); + } + else if (req.Path == new PathString("/challenge")) + { + await context.Authentication.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme); + } + else if (req.Path == new PathString("/signout")) + { + await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + } + else if (req.Path == new PathString("/unauthorized")) + { + await context.Authentication.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme, new AuthenticationProperties(), ChallengeBehavior.Unauthorized); + } + else if (req.Path == new PathString("/protected/CustomRedirect")) + { + await context.Authentication.ChallengeAsync(new AuthenticationProperties() { RedirectUri = "/CustomRedirect" }); + } + else if (req.Path == new PathString("/me")) + { + var authContext = new AuthenticateContext(CookieAuthenticationDefaults.AuthenticationScheme); + authContext.Authenticated(context.User, properties: null, description: null); + Describe(res, authContext); + } + else if (req.Path.StartsWithSegments(new PathString("/me"), out remainder)) + { + var authContext = new AuthenticateContext(remainder.Value.Substring(1)); + await context.Authentication.AuthenticateAsync(authContext); + Describe(res, authContext); + } + else if (req.Path == new PathString("/testpath") && testpath != null) + { + await testpath(context); + } + else + { + await next(); + } + }); + }) + .ConfigureServices(services => services.AddAuthentication()); + var server = new TestServer(builder); server.BaseAddress = baseAddress; return server; } diff --git a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs index c1796c3dec..5263dadb57 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; @@ -13,6 +12,7 @@ using Microsoft.AspNet.Authentication.Cookies; using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.TestHost; @@ -226,21 +226,23 @@ namespace Microsoft.AspNet.Authentication.Facebook private static TestServer CreateServer(Action configure, Action configureServices, Func handler) { - return TestServer.Create(app => - { - if (configure != null) + var builder = new WebApplicationBuilder() + .Configure(app => { - configure(app); - } - app.Use(async (context, next) => - { - if (handler == null || !handler(context)) + if (configure != null) { - await next(); + configure(app); } - }); - }, - configureServices); + app.Use(async (context, next) => + { + if (handler == null || !handler(context)) + { + await next(); + } + }); + }) + .ConfigureServices(configureServices); + return new TestServer(builder); } } } diff --git a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs index 77fc762840..11fbe67e51 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; @@ -765,74 +766,76 @@ namespace Microsoft.AspNet.Authentication.Google private static TestServer CreateServer(Action configureOptions, Func testpath = null) { - return TestServer.Create(app => - { - app.UseCookieAuthentication(options => + var builder = new WebApplicationBuilder() + .Configure(app => { - options.AuthenticationScheme = TestExtensions.CookieAuthenticationScheme; - options.AutomaticAuthenticate = true; - }); - app.UseGoogleAuthentication(configureOptions); - app.UseClaimsTransformation(p => + app.UseCookieAuthentication(options => + { + options.AuthenticationScheme = TestExtensions.CookieAuthenticationScheme; + options.AutomaticAuthenticate = true; + }); + app.UseGoogleAuthentication(configureOptions); + app.UseClaimsTransformation(p => + { + var id = new ClaimsIdentity("xform"); + id.AddClaim(new Claim("xform", "yup")); + p.AddIdentity(id); + return Task.FromResult(p); + }); + app.Use(async (context, next) => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/challenge")) + { + await context.Authentication.ChallengeAsync("Google"); + } + else if (req.Path == new PathString("/me")) + { + res.Describe(context.User); + } + else if (req.Path == new PathString("/unauthorized")) + { + // Simulate Authorization failure + var result = await context.Authentication.AuthenticateAsync("Google"); + await context.Authentication.ChallengeAsync("Google"); + } + else if (req.Path == new PathString("/unauthorizedAuto")) + { + var result = await context.Authentication.AuthenticateAsync("Google"); + await context.Authentication.ChallengeAsync(); + } + else if (req.Path == new PathString("/401")) + { + res.StatusCode = 401; + } + else if (req.Path == new PathString("/signIn")) + { + await Assert.ThrowsAsync(() => context.Authentication.SignInAsync("Google", new ClaimsPrincipal())); + } + else if (req.Path == new PathString("/signOut")) + { + await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync("Google")); + } + else if (req.Path == new PathString("/forbid")) + { + await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Google")); + } + else if (testpath != null) + { + await testpath(context); + } + else + { + await next(); + } + }); + }) + .ConfigureServices(services => { - var id = new ClaimsIdentity("xform"); - id.AddClaim(new Claim("xform", "yup")); - p.AddIdentity(id); - return Task.FromResult(p); + services.AddAuthentication(options => options.SignInScheme = TestExtensions.CookieAuthenticationScheme); }); - app.Use(async (context, next) => - { - var req = context.Request; - var res = context.Response; - if (req.Path == new PathString("/challenge")) - { - await context.Authentication.ChallengeAsync("Google"); - } - else if (req.Path == new PathString("/me")) - { - res.Describe(context.User); - } - else if (req.Path == new PathString("/unauthorized")) - { - // Simulate Authorization failure - var result = await context.Authentication.AuthenticateAsync("Google"); - await context.Authentication.ChallengeAsync("Google"); - } - else if (req.Path == new PathString("/unauthorizedAuto")) - { - var result = await context.Authentication.AuthenticateAsync("Google"); - await context.Authentication.ChallengeAsync(); - } - else if (req.Path == new PathString("/401")) - { - res.StatusCode = 401; - } - else if (req.Path == new PathString("/signIn")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignInAsync("Google", new ClaimsPrincipal())); - } - else if (req.Path == new PathString("/signOut")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync("Google")); - } - else if (req.Path == new PathString("/forbid")) - { - await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Google")); - } - else if (testpath != null) - { - await testpath(context); - } - else - { - await next(); - } - }); - }, - services => - { - services.AddAuthentication(options => options.SignInScheme = TestExtensions.CookieAuthenticationScheme); - }); + return new TestServer(builder); } } } diff --git a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 6100957cac..6bea890b17 100644 --- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -9,6 +9,7 @@ using System.Security.Claims; using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; @@ -536,67 +537,69 @@ namespace Microsoft.AspNet.Authentication.JwtBearer private static TestServer CreateServer(Action configureOptions, Func handler = null) { - return TestServer.Create(app => - { - if (configureOptions != null) + var builder = new WebApplicationBuilder() + .Configure(app => { - app.UseJwtBearerAuthentication(configureOptions); - } - - app.Use(async (context, next) => - { - if (context.Request.Path == new PathString("/checkforerrors")) + if (configureOptions != null) { - var authContext = new AuthenticateContext(Http.Authentication.AuthenticationManager.AutomaticScheme); - await context.Authentication.AuthenticateAsync(authContext); - if (authContext.Error != null) - { - throw new Exception("Failed to authenticate", authContext.Error); - } - return; + app.UseJwtBearerAuthentication(configureOptions); } - else if (context.Request.Path == new PathString("/oauth")) - { - if (context.User == null || - context.User.Identity == null || - !context.User.Identity.IsAuthenticated) - { - context.Response.StatusCode = 401; + app.Use(async (context, next) => + { + if (context.Request.Path == new PathString("/checkforerrors")) + { + var authContext = new AuthenticateContext(Http.Authentication.AuthenticationManager.AutomaticScheme); + await context.Authentication.AuthenticateAsync(authContext); + if (authContext.Error != null) + { + throw new Exception("Failed to authenticate", authContext.Error); + } return; } - - var identifier = context.User.FindFirst(ClaimTypes.NameIdentifier); - if (identifier == null) + else if (context.Request.Path == new PathString("/oauth")) { - context.Response.StatusCode = 500; + if (context.User == null || + context.User.Identity == null || + !context.User.Identity.IsAuthenticated) + { + context.Response.StatusCode = 401; - return; + return; + } + + var identifier = context.User.FindFirst(ClaimTypes.NameIdentifier); + if (identifier == null) + { + context.Response.StatusCode = 500; + + return; + } + + await context.Response.WriteAsync(identifier.Value); } - - await context.Response.WriteAsync(identifier.Value); - } - 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); - } - else if (context.Request.Path == new PathString("/signIn")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); - } - else if (context.Request.Path == new PathString("/signOut")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync(JwtBearerDefaults.AuthenticationScheme)); - } - else - { - await next(); - } - }); - }, - services => services.AddAuthentication()); + 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); + } + else if (context.Request.Path == new PathString("/signIn")) + { + await Assert.ThrowsAsync(() => context.Authentication.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); + } + else if (context.Request.Path == new PathString("/signOut")) + { + await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync(JwtBearerDefaults.AuthenticationScheme)); + } + else + { + await next(); + } + }); + }) + .ConfigureServices(services => services.AddAuthentication()); + return new TestServer(builder); } // TODO: see if we can share the TestExtensions SendAsync method (only diff is auth header) diff --git a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index 650c86465e..1b5bd483b7 100644 --- a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -12,6 +12,7 @@ using Microsoft.AspNet.Authentication.MicrosoftAccount; using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.TestHost; @@ -177,53 +178,55 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount private static TestServer CreateServer(Action configureOptions) { - return TestServer.Create(app => - { - app.UseCookieAuthentication(options => + var builder = new WebApplicationBuilder() + .Configure(app => { - options.AuthenticationScheme = TestExtensions.CookieAuthenticationScheme; - options.AutomaticAuthenticate = true; - }); - app.UseMicrosoftAccountAuthentication(configureOptions); + app.UseCookieAuthentication(options => + { + options.AuthenticationScheme = TestExtensions.CookieAuthenticationScheme; + options.AutomaticAuthenticate = true; + }); + app.UseMicrosoftAccountAuthentication(configureOptions); - app.Use(async (context, next) => + app.Use(async (context, next) => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/challenge")) + { + await context.Authentication.ChallengeAsync("Microsoft"); + } + else if (req.Path == new PathString("/me")) + { + res.Describe(context.User); + } + else if (req.Path == new PathString("/signIn")) + { + await Assert.ThrowsAsync(() => context.Authentication.SignInAsync("Microsoft", new ClaimsPrincipal())); + } + else if (req.Path == new PathString("/signOut")) + { + await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync("Microsoft")); + } + else if (req.Path == new PathString("/forbid")) + { + await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Microsoft")); + } + else + { + await next(); + } + }); + }) + .ConfigureServices(services => { - var req = context.Request; - var res = context.Response; - if (req.Path == new PathString("/challenge")) + services.AddAuthentication(); + services.Configure(options => { - await context.Authentication.ChallengeAsync("Microsoft"); - } - else if (req.Path == new PathString("/me")) - { - res.Describe(context.User); - } - else if (req.Path == new PathString("/signIn")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignInAsync("Microsoft", new ClaimsPrincipal())); - } - else if (req.Path == new PathString("/signOut")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync("Microsoft")); - } - else if (req.Path == new PathString("/forbid")) - { - await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Microsoft")); - } - else - { - await next(); - } + options.SignInScheme = TestExtensions.CookieAuthenticationScheme; + }); }); - }, - services => - { - services.AddAuthentication(); - services.Configure(options => - { - options.SignInScheme = TestExtensions.CookieAuthenticationScheme; - }); - }); + return new TestServer(builder); } private static HttpResponseMessage ReturnJsonResponse(object content) diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs index 3c48657d1c..99b7040ea5 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs @@ -12,6 +12,7 @@ using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Authentication.OpenIdConnect; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.TestHost; using Microsoft.Extensions.DependencyInjection; @@ -94,8 +95,8 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect private static TestServer CreateServer(Action configureOptions, UrlEncoder encoder, OpenIdConnectHandler handler = null) { - return TestServer.Create( - app => + var builder = new WebApplicationBuilder() + .Configure(app => { var options = new OpenIdConnectOptions(); configureOptions(options); @@ -104,13 +105,13 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect { await next(); }); - }, - services => + }) + .ConfigureServices(services => { services.AddWebEncoders(); services.AddDataProtection(); - } - ); + }); + return new TestServer(builder); } } } diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index b9f0f26f89..9446be945a 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -14,6 +14,7 @@ using System.Xml.Linq; using Microsoft.AspNet.Authentication.Cookies; using Microsoft.AspNet.Authentication.OpenIdConnect; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.TestHost; @@ -380,63 +381,65 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect private static TestServer CreateServer(Action configureOptions, Func handler = null, AuthenticationProperties properties = null) { - return TestServer.Create(app => - { - app.UseCookieAuthentication(options => + var builder = new WebApplicationBuilder() + .Configure(app => { - options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - app.UseOpenIdConnectAuthentication(configureOptions); - app.Use(async (context, next) => - { - var req = context.Request; - var res = context.Response; + app.UseCookieAuthentication(options => + { + options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + app.UseOpenIdConnectAuthentication(configureOptions); + app.Use(async (context, next) => + { + var req = context.Request; + var res = context.Response; - if (req.Path == new PathString(Challenge)) - { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme); - } - else if (req.Path == new PathString(ChallengeWithProperties)) - { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, properties); - } - else if (req.Path == new PathString(ChallengeWithOutContext)) - { - res.StatusCode = 401; - } - else if (req.Path == new PathString(Signin)) - { - // REVIEW: this used to just be res.SignIn() - await context.Authentication.SignInAsync(OpenIdConnectDefaults.AuthenticationScheme, new ClaimsPrincipal()); - } - else if (req.Path == new PathString(Signout)) - { - await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); - } - else if (req.Path == new PathString("/signout_with_specific_redirect_uri")) - { - await context.Authentication.SignOutAsync( - OpenIdConnectDefaults.AuthenticationScheme, - new AuthenticationProperties() { RedirectUri = "http://www.example.com/specific_redirect_uri" }); - } - else if (handler != null) - { - await handler(context); - } - else - { - await next(); - } - }); - }, - services => - { - services.AddAuthentication(); - services.Configure(options => + if (req.Path == new PathString(Challenge)) + { + await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme); + } + else if (req.Path == new PathString(ChallengeWithProperties)) + { + await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, properties); + } + else if (req.Path == new PathString(ChallengeWithOutContext)) + { + res.StatusCode = 401; + } + else if (req.Path == new PathString(Signin)) + { + // REVIEW: this used to just be res.SignIn() + await context.Authentication.SignInAsync(OpenIdConnectDefaults.AuthenticationScheme, new ClaimsPrincipal()); + } + else if (req.Path == new PathString(Signout)) + { + await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); + } + else if (req.Path == new PathString("/signout_with_specific_redirect_uri")) + { + await context.Authentication.SignOutAsync( + OpenIdConnectDefaults.AuthenticationScheme, + new AuthenticationProperties() { RedirectUri = "http://www.example.com/specific_redirect_uri" }); + } + else if (handler != null) + { + await handler(context); + } + else + { + await next(); + } + }); + }) + .ConfigureServices(services => { - options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + services.AddAuthentication(); + services.Configure(options => + { + options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); }); - }); + return new TestServer(builder); } private static async Task SendAsync(TestServer server, string uri, string cookieHeader = null) diff --git a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs index 668f874811..db77d7f5ff 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs @@ -1,17 +1,16 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; -using System.Linq; using System.Net; using System.Net.Http; using System.Security.Claims; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.TestHost; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.WebEncoders; using Xunit; namespace Microsoft.AspNet.Authentication.Twitter @@ -153,43 +152,45 @@ namespace Microsoft.AspNet.Authentication.Twitter private static TestServer CreateServer(Action configure, Func handler = null) { - return TestServer.Create(app => - { - app.UseCookieAuthentication(options => + var builder = new WebApplicationBuilder() + .Configure(app => { - options.AuthenticationScheme = "External"; - }); - app.UseTwitterAuthentication(configure); - app.Use(async (context, next) => + app.UseCookieAuthentication(options => + { + options.AuthenticationScheme = "External"; + }); + app.UseTwitterAuthentication(configure); + app.Use(async (context, next) => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/signIn")) + { + await Assert.ThrowsAsync(() => context.Authentication.SignInAsync("Twitter", new ClaimsPrincipal())); + } + else if (req.Path == new PathString("/signOut")) + { + await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync("Twitter")); + } + else if (req.Path == new PathString("/forbid")) + { + await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Twitter")); + } + else if (handler == null || !handler(context)) + { + await next(); + } + }); + }) + .ConfigureServices(services => { - var req = context.Request; - var res = context.Response; - if (req.Path == new PathString("/signIn")) + services.AddAuthentication(); + services.Configure(options => { - await Assert.ThrowsAsync(() => context.Authentication.SignInAsync("Twitter", new ClaimsPrincipal())); - } - else if (req.Path == new PathString("/signOut")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync("Twitter")); - } - else if (req.Path == new PathString("/forbid")) - { - await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Twitter")); - } - else if (handler == null || !handler(context)) - { - await next(); - } + options.SignInScheme = "External"; + }); }); - }, - services => - { - services.AddAuthentication(); - services.Configure(options => - { - options.SignInScheme = "External"; - }); - }); + return new TestServer(builder); } } } diff --git a/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs index 78f20c9cf1..4b798c5613 100644 --- a/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs @@ -4,6 +4,7 @@ using System; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Http.Features.Internal; @@ -129,18 +130,20 @@ namespace Microsoft.AspNet.CookiePolicy.Test [Fact] public async Task CookiePolicyCanHijackAppend() { - var server = TestServer.Create(app => - { - app.UseCookiePolicy(options => options.OnAppendCookie = ctx => ctx.CookieName = ctx.CookieValue = "Hao"); - app.Run(context => + var builder = new WebApplicationBuilder() + .Configure(app => { - context.Response.Cookies.Append("A", "A"); - context.Response.Cookies.Append("B", "B", new CookieOptions { Secure = false }); - context.Response.Cookies.Append("C", "C", new CookieOptions()); - context.Response.Cookies.Append("D", "D", new CookieOptions { Secure = true }); - return Task.FromResult(0); + app.UseCookiePolicy(options => options.OnAppendCookie = ctx => ctx.CookieName = ctx.CookieValue = "Hao"); + app.Run(context => + { + context.Response.Cookies.Append("A", "A"); + context.Response.Cookies.Append("B", "B", new CookieOptions { Secure = false }); + context.Response.Cookies.Append("C", "C", new CookieOptions()); + context.Response.Cookies.Append("D", "D", new CookieOptions { Secure = true }); + return Task.FromResult(0); + }); }); - }); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/login"); @@ -154,7 +157,8 @@ namespace Microsoft.AspNet.CookiePolicy.Test [Fact] public async Task CookiePolicyCanHijackDelete() { - var server = TestServer.Create(app => + var builder = new WebApplicationBuilder() + .Configure(app => { app.UseCookiePolicy(options => options.OnDeleteCookie = ctx => ctx.CookieName = "A"); app.Run(context => @@ -166,6 +170,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test return Task.FromResult(0); }); }); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/login"); @@ -177,7 +182,8 @@ namespace Microsoft.AspNet.CookiePolicy.Test [Fact] public async Task CookiePolicyCallsCookieFeature() { - var server = TestServer.Create(app => + var builder = new WebApplicationBuilder() + .Configure(app => { app.Use(next => context => { @@ -194,6 +200,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test return context.Response.WriteAsync("Done"); }); }); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/login"); Assert.Equal("Done", transaction.ResponseText); @@ -251,7 +258,8 @@ namespace Microsoft.AspNet.CookiePolicy.Test RequestDelegate configureSetup, params RequestTest[] tests) { - var server = TestServer.Create(app => + var builder = new WebApplicationBuilder() + .Configure(app => { app.Map(path, map => { @@ -259,6 +267,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test map.Run(configureSetup); }); }); + var server = new TestServer(builder); foreach (var test in tests) { await test.Execute(server); diff --git a/test/Microsoft.Owin.Security.Cookies.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Cookies.Interop.Test/TicketInteropTests.cs index 725c5b1f2f..71acba5978 100644 --- a/test/Microsoft.Owin.Security.Cookies.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Cookies.Interop.Test/TicketInteropTests.cs @@ -13,6 +13,7 @@ using System.Xml; using System.Xml.Linq; using Microsoft.AspNet.Authentication; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Owin; using Microsoft.Owin.Security.Cookies; @@ -120,15 +121,18 @@ namespace Microsoft.AspNet.CookiePolicy.Test var transaction = await SendAsync(interopServer, "http://example.com"); - var newServer = TestHost.TestServer.Create(app => - { - app.UseCookieAuthentication(options => options.DataProtectionProvider = dataProtection); - app.Run(async context => + var builder = new WebApplicationBuilder() + .Configure(app => { - var result = await context.Authentication.AuthenticateAsync("Cookies"); - await context.Response.WriteAsync(result.Identity.Name); - }); - }, services => services.AddAuthentication()); + app.UseCookieAuthentication(options => options.DataProtectionProvider = dataProtection); + app.Run(async context => + { + var result = await context.Authentication.AuthenticateAsync("Cookies"); + await context.Response.WriteAsync(result.Identity.Name); + }); + }) + .ConfigureServices(services => services.AddAuthentication()); + var newServer = new TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); request.Headers.Add("Cookie", transaction.SetCookie.Split(new[] { ';' }, 2).First()); @@ -146,11 +150,14 @@ namespace Microsoft.AspNet.CookiePolicy.Test user.AddIdentity(identity); var dataProtection = new DataProtection.DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); - var newServer = TestHost.TestServer.Create(app => - { - app.UseCookieAuthentication(options => options.DataProtectionProvider = dataProtection); - app.Run(context => context.Authentication.SignInAsync("Cookies", user)); - }, services => services.AddAuthentication()); + var builder = new WebApplicationBuilder() + .Configure(app => + { + app.UseCookieAuthentication(options => options.DataProtectionProvider = dataProtection); + app.Run(context => context.Authentication.SignInAsync("Cookies", user)); + }) + .ConfigureServices(services => services.AddAuthentication()); + var newServer = new TestHost.TestServer(builder); var cookie = await SendAndGetCookie(newServer, "http://example.com/login"); From e4df43611da85fd4ffdf340d1b3790656c44a672 Mon Sep 17 00:00:00 2001 From: Chris R Date: Sun, 20 Dec 2015 19:44:21 -0800 Subject: [PATCH 425/900] React to IdentityModel namespace changes. --- .../JwtBearerHandler.cs | 2 +- .../JwtBearerOptions.cs | 2 +- .../OpenIdConnectHandler.cs | 2 +- .../OpenIdConnectOptions.cs | 3 +-- .../JwtBearer/JwtBearerMiddlewareTests.cs | 2 +- .../OpenIdConnect/OpenIdConnectHandlerTests.cs | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs index 645cf2cdef..6983041327 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.IdentityModel.Tokens; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; @@ -12,6 +11,7 @@ using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; namespace Microsoft.AspNet.Authentication.JwtBearer diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs index 1ab2a8b131..ad2160c06a 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs @@ -4,11 +4,11 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.IdentityModel.Tokens; using System.IdentityModel.Tokens.Jwt; using System.Net.Http; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Microsoft.IdentityModel.Tokens; namespace Microsoft.AspNet.Authentication.JwtBearer { diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 124d8f543a..9f8e4f9572 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.IdentityModel.Tokens; using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Net.Http; @@ -19,6 +18,7 @@ using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; using Newtonsoft.Json.Linq; diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index dc2cce9964..06b7442de0 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -4,13 +4,12 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.IdentityModel.Tokens; using System.IdentityModel.Tokens.Jwt; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; -using Microsoft.Extensions.WebEncoders; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Microsoft.IdentityModel.Tokens; namespace Microsoft.AspNet.Authentication.OpenIdConnect { diff --git a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 6bea890b17..7dee0f0ffb 100644 --- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.IdentityModel.Tokens; using System.Net; using System.Net.Http; using System.Security.Claims; @@ -16,6 +15,7 @@ using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.AspNet.TestHost; using Microsoft.AspNet.Testing.xunit; using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; using Xunit; namespace Microsoft.AspNet.Authentication.JwtBearer diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs index 99b7040ea5..801cc71f95 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.IdentityModel.Tokens; using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Net.Http; @@ -17,6 +16,7 @@ using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.TestHost; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Microsoft.IdentityModel.Tokens; using Xunit; namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect From 84279c07cfdf4871516092c32344ce34d952a6a5 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 21 Dec 2015 15:02:14 -0800 Subject: [PATCH 426/900] OptionsModel => Options rename --- .../CookieAuthenticationOptions.cs | 2 +- .../FacebookMiddleware.cs | 2 +- src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs | 2 +- .../MicrosoftAccountMiddleware.cs | 2 +- src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs | 2 +- .../OpenIdConnectMiddleware.cs | 2 +- .../TwitterMiddleware.cs | 2 +- src/Microsoft.AspNet.Authentication/project.json | 2 +- .../DefaultAuthorizationService.cs | 2 +- src/Microsoft.AspNet.Authorization/project.json | 2 +- .../OpenIdConnectMiddlewareForTestingAuthenticate.cs | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs index 88d41c6635..830b559c96 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -6,7 +6,7 @@ using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authentication.Cookies { diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs index 3789163810..441145681d 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs @@ -8,7 +8,7 @@ using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authentication.Facebook { diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs index 152cc6290a..55d2b0ed13 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs @@ -8,7 +8,7 @@ using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authentication.Google { diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs index 590e0d7785..c398b9279e 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs @@ -7,7 +7,7 @@ using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authentication.MicrosoftAccount { diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs index 10b7bdf425..ea145fa6de 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs @@ -9,7 +9,7 @@ using System.Text.Encodings.Web; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authentication.OAuth { diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs index 52023d99d7..a6f9971705 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -9,7 +9,7 @@ using System.Text.Encodings.Web; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs index 3c214b0d71..e1a1c17211 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs @@ -9,7 +9,7 @@ using System.Text.Encodings.Web; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authentication.Twitter { diff --git a/src/Microsoft.AspNet.Authentication/project.json b/src/Microsoft.AspNet.Authentication/project.json index c4b246641a..ef36e17f03 100644 --- a/src/Microsoft.AspNet.Authentication/project.json +++ b/src/Microsoft.AspNet.Authentication/project.json @@ -18,7 +18,7 @@ "type": "build", "version": "1.0.0-*" }, - "Microsoft.Extensions.OptionsModel": "1.0.0-*", + "Microsoft.Extensions.Options": "1.0.0-*", "Microsoft.Extensions.WebEncoders": "1.0.0-*" }, "frameworks": { diff --git a/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs index 40e16107c0..2c1fcd20d1 100644 --- a/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authorization { diff --git a/src/Microsoft.AspNet.Authorization/project.json b/src/Microsoft.AspNet.Authorization/project.json index 0cd2647ce6..14245e4d2f 100644 --- a/src/Microsoft.AspNet.Authorization/project.json +++ b/src/Microsoft.AspNet.Authorization/project.json @@ -12,7 +12,7 @@ "dependencies": { "Microsoft.AspNet.Http.Features": "1.0.0-*", "Microsoft.Extensions.Logging.Abstractions": "1.0.0-*", - "Microsoft.Extensions.OptionsModel": "1.0.0-*" + "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { "net451": {}, diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs index 17b27128af..2a91eecdbc 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs @@ -7,7 +7,7 @@ using Microsoft.AspNet.Authentication.OpenIdConnect; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect { From 5837ce160ac5faf792bf2a64af7b5e38a22e6510 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 21 Dec 2015 17:06:48 -0800 Subject: [PATCH 427/900] Stardardizing middleware to use ConfigureOption lambda --- samples/SocialSample/Startup.cs | 97 ++++++++++--------- .../CookieAppBuilderExtensions.cs | 31 ++---- .../FacebookAppBuilderExtensions.cs | 33 ++----- .../GoogleAppBuilderExtensions.cs | 33 ++----- .../JwtBearerAppBuilderExtensions.cs | 39 ++------ .../MicrosoftAccountAppBuilderExtensions.cs | 33 ++----- .../OAuthAppBuilderExtensions.cs | 26 +---- .../OAuthOptions.cs | 3 - .../OpenIdConnectAppBuilderExtensions.cs | 32 ++---- .../TwitterAppBuilderExtensions.cs | 29 +----- ...laimsTransformationAppBuilderExtensions.cs | 43 ++++---- .../CookiePolicyAppBuilderExtensions.cs | 26 +++-- .../Cookies/CookieMiddlewareTests.cs | 2 +- 13 files changed, 131 insertions(+), 296 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 59c57862ae..f1bc5b335f 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -72,26 +72,29 @@ namespace CookieSample // You must first create an app with facebook and add it's ID and Secret to your config.json or user-secrets. // https://developers.facebook.com/apps/ - app.UseFacebookAuthentication(new FacebookOptions() + app.UseFacebookAuthentication(options => { - AppId = Configuration["facebook:appid"], - AppSecret = Configuration["facebook:appsecret"], - Scope = { "email" }, - Fields = { "name", "email" }, + options.AppId = Configuration["facebook:appid"]; + options.AppSecret = Configuration["facebook:appsecret"]; + options.Scope.Add("email"); + options.Fields.Add("name"); + options.Fields.Add("email"); }); // See config.json - app.UseOAuthAuthentication(new OAuthOptions + app.UseOAuthAuthentication(options => { - AuthenticationScheme = "Google-AccessToken", - DisplayName = "Google-AccessToken", - ClientId = Configuration["google:clientid"], - ClientSecret = Configuration["google:clientsecret"], - CallbackPath = new PathString("/signin-google-token"), - AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint, - TokenEndpoint = GoogleDefaults.TokenEndpoint, - Scope = { "openid", "profile", "email" }, - SaveTokensAsClaims = true + options.AuthenticationScheme = "Google-AccessToken"; + options.DisplayName = "Google-AccessToken"; + options.ClientId = Configuration["google:clientid"]; + options.ClientSecret = Configuration["google:clientsecret"]; + options.CallbackPath = new PathString("/signin-google-token"); + options.AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint; + options.TokenEndpoint = GoogleDefaults.TokenEndpoint; + options.Scope.Add("openid"); + options.Scope.Add("profile"); + options.Scope.Add("email"); + options.SaveTokensAsClaims = true; }); // See config.json @@ -148,17 +151,17 @@ namespace CookieSample The sample app can then be run via: dnx . web */ - app.UseOAuthAuthentication(new OAuthOptions + app.UseOAuthAuthentication(options => { - AuthenticationScheme = "Microsoft-AccessToken", - DisplayName = "MicrosoftAccount-AccessToken - Requires project changes", - ClientId = Configuration["msa:clientid"], - ClientSecret = Configuration["msa:clientsecret"], - CallbackPath = new PathString("/signin-microsoft-token"), - AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint, - TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint, - Scope = { "wl.basic" }, - SaveTokensAsClaims = true + options.AuthenticationScheme = "Microsoft-AccessToken"; + options.DisplayName = "MicrosoftAccount-AccessToken - Requires project changes"; + options.ClientId = Configuration["msa:clientid"]; + options.ClientSecret = Configuration["msa:clientsecret"]; + options.CallbackPath = new PathString("/signin-microsoft-token"); + options.AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint; + options.TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; + options.Scope.Add("wl.basic"); + options.SaveTokensAsClaims = true; }); //// You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. @@ -172,32 +175,32 @@ namespace CookieSample // See config.json // https://github.com/settings/applications/ - app.UseOAuthAuthentication(new OAuthOptions + app.UseOAuthAuthentication(options => { - AuthenticationScheme = "GitHub-AccessToken", - DisplayName = "Github-AccessToken", - ClientId = Configuration["github-token:clientid"], - ClientSecret = Configuration["github-token:clientsecret"], - CallbackPath = new PathString("/signin-github-token"), - AuthorizationEndpoint = "https://github.com/login/oauth/authorize", - TokenEndpoint = "https://github.com/login/oauth/access_token", - SaveTokensAsClaims = true + options.AuthenticationScheme = "GitHub-AccessToken"; + options.DisplayName = "Github-AccessToken"; + options.ClientId = Configuration["github-token:clientid"]; + options.ClientSecret = Configuration["github-token:clientsecret"]; + options.CallbackPath = new PathString("/signin-github-token"); + options.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; + options.TokenEndpoint = "https://github.com/login/oauth/access_token"; + options.SaveTokensAsClaims = true; }); // See config.json - app.UseOAuthAuthentication(new OAuthOptions + app.UseOAuthAuthentication(options => { - AuthenticationScheme = "GitHub", - DisplayName = "Github", - ClientId = Configuration["github:clientid"], - ClientSecret = Configuration["github:clientsecret"], - CallbackPath = new PathString("/signin-github"), - AuthorizationEndpoint = "https://github.com/login/oauth/authorize", - TokenEndpoint = "https://github.com/login/oauth/access_token", - UserInformationEndpoint = "https://api.github.com/user", - ClaimsIssuer = "OAuth2-Github", + options.AuthenticationScheme = "GitHub"; + options.DisplayName = "Github"; + options.ClientId = Configuration["github:clientid"]; + options.ClientSecret = Configuration["github:clientsecret"]; + options.CallbackPath = new PathString("/signin-github"); + options.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; + options.TokenEndpoint = "https://github.com/login/oauth/access_token"; + options.UserInformationEndpoint = "https://api.github.com/user"; + options.ClaimsIssuer = "OAuth2-Github"; // Retrieving user information is unique to each provider. - Events = new OAuthEvents + options.Events = new OAuthEvents { OnCreatingTicket = async context => { @@ -210,7 +213,7 @@ namespace CookieSample response.EnsureSuccessStatusCode(); var user = JObject.Parse(await response.Content.ReadAsStringAsync()); - + var identifier = user.Value("id"); if (!string.IsNullOrEmpty(identifier)) { @@ -243,7 +246,7 @@ namespace CookieSample ClaimValueTypes.String, context.Options.ClaimsIssuer)); } } - } + }; }); // Choose an authentication type diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs index 0a8cd12ce4..46539f875c 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(app)); } - return app.UseCookieAuthentication(new CookieAuthenticationOptions()); + return app.UseCookieAuthentication(options => { }); } /// @@ -38,32 +38,13 @@ namespace Microsoft.AspNet.Builder { throw new ArgumentNullException(nameof(app)); } + if (configureOptions == null) + { + throw new ArgumentNullException(nameof(configureOptions)); + } var options = new CookieAuthenticationOptions(); - if (configureOptions != null) - { - configureOptions(options); - } - return app.UseCookieAuthentication(options); - } - - /// - /// Adds the middleware to the specified , which enables cookie authentication capabilities. - /// - /// The to add the middleware to. - /// A that specifies options for the middleware. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuilder app, CookieAuthenticationOptions options) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } + configureOptions(options); return app.UseMiddleware(options); } diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs index 0889ec6ece..cc9b73f48b 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs @@ -11,27 +11,6 @@ namespace Microsoft.AspNet.Builder /// public static class FacebookAppBuilderExtensions { - /// - /// Adds the middleware to the specified , which enables Facebook authentication capabilities. - /// - /// The to add the middleware to. - /// A that specifies options for the middleware. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app, FacebookOptions options) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(options); - } - /// /// Adds the middleware to the specified , which enables Facebook authentication capabilities. /// @@ -44,13 +23,15 @@ namespace Microsoft.AspNet.Builder { throw new ArgumentNullException(nameof(app)); } + if (configureOptions == null) + { + throw new ArgumentNullException(nameof(configureOptions)); + } var options = new FacebookOptions(); - if (configureOptions != null) - { - configureOptions(options); - } - return app.UseFacebookAuthentication(options); + configureOptions(options); + + return app.UseMiddleware(options); } } } diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs index 67993bbc2e..88e56928f8 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -11,27 +11,6 @@ namespace Microsoft.AspNet.Builder /// public static class GoogleAppBuilderExtensions { - /// - /// Adds the middleware to the specified , which enables Google authentication capabilities. - /// - /// The to add the middleware to. - /// A that specifies options for the middleware. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app, GoogleOptions options) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(options); - } - /// /// Adds the middleware to the specified , which enables Google authentication capabilities. /// @@ -44,13 +23,15 @@ namespace Microsoft.AspNet.Builder { throw new ArgumentNullException(nameof(app)); } + if (configureOptions == null) + { + throw new ArgumentNullException(nameof(configureOptions)); + } var options = new GoogleOptions(); - if (configureOptions != null) - { - configureOptions(options); - } - return app.UseGoogleAuthentication(options); + configureOptions(options); + + return app.UseMiddleware(options); } } } diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index 80494f09d8..0a1d01e446 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -11,33 +11,6 @@ namespace Microsoft.AspNet.Builder /// public static class JwtBearerAppBuilderExtensions { - /// - /// Adds the middleware to the specified , which enables Bearer token processing capabilities. - /// This middleware understands appropriately - /// formatted and secured tokens which appear in the request header. If the Options.AuthenticationMode is Active, the - /// claims within the bearer token are added to the current request's IPrincipal User. If the Options.AuthenticationMode - /// is Passive, then the current request is not modified, but IAuthenticationManager AuthenticateAsync may be used at - /// any time to obtain the claims from the request's bearer token. - /// See also http://tools.ietf.org/html/rfc6749 - /// - /// The to add the middleware to. - /// A that specifies options for the middleware. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app, JwtBearerOptions options) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(options); - } - /// /// Adds the middleware to the specified , which enables Bearer token processing capabilities. /// This middleware understands appropriately @@ -56,13 +29,15 @@ namespace Microsoft.AspNet.Builder { throw new ArgumentNullException(nameof(app)); } + if (configureOptions == null) + { + throw new ArgumentNullException(nameof(configureOptions)); + } var options = new JwtBearerOptions(); - if (configureOptions != null) - { - configureOptions(options); - } - return app.UseJwtBearerAuthentication(options); + configureOptions(options); + + return app.UseMiddleware(options); } } } diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs index 37a8d4180d..34b2ae0709 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs @@ -11,27 +11,6 @@ namespace Microsoft.AspNet.Builder /// public static class MicrosoftAccountAppBuilderExtensions { - /// - /// Adds the middleware to the specified , which enables Microsoft Account authentication capabilities. - /// - /// The to add the middleware to. - /// A that specifies options for the middleware. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app, MicrosoftAccountOptions options) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(options); - } - /// /// Adds the middleware to the specified , which enables Microsoft Account authentication capabilities. /// @@ -44,13 +23,15 @@ namespace Microsoft.AspNet.Builder { throw new ArgumentNullException(nameof(app)); } + if (configureOptions == null) + { + throw new ArgumentNullException(nameof(configureOptions)); + } var options = new MicrosoftAccountOptions(); - if (configureOptions != null) - { - configureOptions(options); - } - return app.UseMicrosoftAccountAuthentication(options); + configureOptions(options); + + return app.UseMiddleware(options); } } } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs index 18aa623624..93db92caba 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs @@ -23,37 +23,13 @@ namespace Microsoft.AspNet.Builder { throw new ArgumentNullException(nameof(app)); } - if (configureOptions == null) { throw new ArgumentNullException(nameof(configureOptions)); } var options = new OAuthOptions(); - if (configureOptions != null) - { - configureOptions(options); - } - return app.UseOAuthAuthentication(options); - } - - /// - /// Adds the middleware to the specified , which enables OAuth 2.0 authentication capabilities. - /// - /// The to add the middleware to. - /// A that specifies options for the middleware. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app, OAuthOptions options) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } + configureOptions(options); return app.UseMiddleware>(options); } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs index ba689e66b1..a79c546725 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs @@ -1,10 +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.Collections.Generic; -using System.Net.Http; -using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; namespace Microsoft.AspNet.Authentication.OAuth diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs index f9b064137f..5f22512261 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Builder /// Adds the middleware to the specified , which enables OpenID Connect authentication capabilities. /// /// The to add the middleware to. - /// An action delegate to configure the provided . + /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app, Action configureOptions) { @@ -23,33 +23,13 @@ namespace Microsoft.AspNet.Builder { throw new ArgumentNullException(nameof(app)); } - + if (configureOptions == null) + { + throw new ArgumentNullException(nameof(configureOptions)); + } var options = new OpenIdConnectOptions(); - if (configureOptions != null) - { - configureOptions(options); - } - return app.UseOpenIdConnectAuthentication(options); - } - - /// - /// Adds the middleware to the specified , which enables OpenID Connect authentication capabilities. - /// - /// The to add the middleware to. - /// An that specifies options for the middleware. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app, OpenIdConnectOptions options) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } + configureOptions(options); return app.UseMiddleware(options); } diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs index efff5937ae..024d04e697 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs @@ -23,32 +23,13 @@ namespace Microsoft.AspNet.Builder { throw new ArgumentNullException(nameof(app)); } + if (configureOptions == null) + { + throw new ArgumentNullException(nameof(configureOptions)); + } var options = new TwitterOptions(); - if (configureOptions != null) - { - configureOptions(options); - } - return app.UseTwitterAuthentication(options); - } - - /// - /// Adds the middleware to the specified , which enables Twitter authentication capabilities. - /// - /// The to add the middleware to. - /// A that specifies options for the middleware. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, TwitterOptions options) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } + configureOptions(options); return app.UseMiddleware(options); } diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs index 4086c95915..702e65627b 100644 --- a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs @@ -13,17 +13,6 @@ namespace Microsoft.AspNet.Builder /// public static class ClaimsTransformationAppBuilderExtensions { - /// - /// Adds the middleware to the specified , which enables claims transformation capabilities. - /// - /// The to add the middleware to. - /// A that specifies options for the middleware. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, ClaimsTransformationOptions options) - { - return app.UseMiddleware(options); - } - /// /// Adds the middleware to the specified , which enables claims transformation capabilities. /// @@ -32,12 +21,19 @@ namespace Microsoft.AspNet.Builder /// A reference to this instance after the operation has completed. public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, Func> transform) { - var options = new ClaimsTransformationOptions(); - options.Transformer = new ClaimsTransformer + if (app == null) { - OnTransform = transform - }; - return app.UseClaimsTransformation(options); + throw new ArgumentNullException(nameof(app)); + } + if (transform == null) + { + throw new ArgumentNullException(nameof(transform)); + } + + return app.UseClaimsTransformation(options => + { + options.Transformer = new ClaimsTransformer { OnTransform = transform }; + }); } /// @@ -48,12 +44,19 @@ namespace Microsoft.AspNet.Builder /// A reference to this instance after the operation has completed. public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, Action configureOptions) { - var options = new ClaimsTransformationOptions(); - if (configureOptions != null) + if (app == null) { - configureOptions(options); + throw new ArgumentNullException(nameof(app)); } - return app.UseClaimsTransformation(options); + if (configureOptions == null) + { + throw new ArgumentNullException(nameof(configureOptions)); + } + + var options = new ClaimsTransformationOptions(); + configureOptions(options); + + return app.UseMiddleware(options); } } } diff --git a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs index f8a4af52f0..c44a39360e 100644 --- a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs @@ -11,17 +11,6 @@ namespace Microsoft.AspNet.Builder /// public static class CookiePolicyAppBuilderExtensions { - /// - /// Adds the middleware to the specified , which enables cookie policy capabilities. - /// - /// The to add the middleware to. - /// A that specifies options for the middleware. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app, CookiePolicyOptions options) - { - return app.UseMiddleware(options); - } - /// /// Adds the middleware to the specified , which enables cookie policy capabilities. /// @@ -30,12 +19,19 @@ namespace Microsoft.AspNet.Builder /// A reference to this instance after the operation has completed. public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app, Action configureOptions) { - var options = new CookiePolicyOptions(); - if (configureOptions != null) + if (app == null) { - configureOptions(options); + throw new ArgumentNullException(nameof(app)); } - return app.UseCookiePolicy(options); + if (configureOptions == null) + { + throw new ArgumentNullException(nameof(configureOptions)); + } + + var options = new CookiePolicyOptions(); + configureOptions(options); + + return app.UseMiddleware(options); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs index db27680d42..852b63f3e0 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -793,7 +793,7 @@ namespace Microsoft.AspNet.Authentication.Cookies .Configure(app => { app.UseCookieAuthentication(options => options.CookieName = "One"); - app.UseCookieAuthentication(new CookieAuthenticationOptions()); + app.UseCookieAuthentication(); app.Run(context => context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity()))); }) .ConfigureServices(services => services.AddAuthentication()); From 2d21b72561c1c7092ee7eb389dee0dff1cf45b79 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 23 Dec 2015 15:26:41 -0800 Subject: [PATCH 428/900] Adding back middleware initialization with options instance. --- .../CookieAppBuilderExtensions.cs | 20 ++++++++++++++ .../FacebookAppBuilderExtensions.cs | 20 ++++++++++++++ .../GoogleAppBuilderExtensions.cs | 20 ++++++++++++++ .../JwtBearerAppBuilderExtensions.cs | 26 +++++++++++++++++++ .../MicrosoftAccountAppBuilderExtensions.cs | 20 ++++++++++++++ .../OAuthAppBuilderExtensions.cs | 20 ++++++++++++++ .../OpenIdConnectAppBuilderExtensions.cs | 20 ++++++++++++++ .../TwitterAppBuilderExtensions.cs | 22 +++++++++++++++- ...laimsTransformationAppBuilderExtensions.cs | 20 ++++++++++++++ .../CookiePolicyAppBuilderExtensions.cs | 20 ++++++++++++++ 10 files changed, 207 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs index 46539f875c..f990df58aa 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs @@ -48,5 +48,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables cookie authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuilder app, CookieAuthenticationOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs index cc9b73f48b..f649790a1a 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables Facebook authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app, FacebookOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs index 88e56928f8..34f65b112e 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables Google authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app, GoogleOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index 0a1d01e446..da36d17f08 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -39,5 +39,31 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables Bearer token processing capabilities. + /// This middleware understands appropriately + /// formatted and secured tokens which appear in the request header. If the Options.AuthenticationMode is Active, the + /// claims within the bearer token are added to the current request's IPrincipal User. If the Options.AuthenticationMode + /// is Passive, then the current request is not modified, but IAuthenticationManager AuthenticateAsync may be used at + /// any time to obtain the claims from the request's bearer token. + /// See also http://tools.ietf.org/html/rfc6749 + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app, JwtBearerOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs index 34b2ae0709..4066fa4ed7 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables Microsoft Account authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app, MicrosoftAccountOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs index 93db92caba..5599407ca3 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware>(options); } + + /// + /// Adds the middleware to the specified , which enables OAuth 2.0 authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app, OAuthOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware>(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs index 5f22512261..329820417c 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables OpenID Connect authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app, OpenIdConnectOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs index 024d04e697..1701122b0a 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Builder /// The to add the middleware to. /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, Action configureOptions = null) + public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, Action configureOptions) { if (app == null) { @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables Twitter authentication capabilities. + /// + /// The to add the middleware to. + /// An action delegate to configure the provided . + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, TwitterOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs index 702e65627b..21f80419f7 100644 --- a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs @@ -58,5 +58,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables claims transformation capabilities. + /// + /// The to add the middleware to. + /// The to configure the middleware with. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, ClaimsTransformationOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs index c44a39360e..95d52e55f0 100644 --- a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables cookie policy capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app, CookiePolicyOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } \ No newline at end of file From 6850e3b3b65d0ed80e65c62f51d0654ba44bc1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Lain=C3=A9?= Date: Mon, 28 Dec 2015 14:47:15 +0100 Subject: [PATCH 429/900] Fix missing Trim in Roles and Schemes split --- .../AuthorizationPolicy.cs | 7 +++- .../AuthorizationPolicyFacts.cs | 34 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs index 096caeecd9..1882efb51b 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs @@ -88,6 +88,9 @@ namespace Microsoft.AspNet.Authorization var rolesSplit = authorizeAttribute.Roles?.Split(','); if (rolesSplit != null && rolesSplit.Any()) { + for (int i = 0; i < rolesSplit.Length; ++i) + rolesSplit[i] = rolesSplit[i]?.Trim(); + policyBuilder.RequireRole(rolesSplit); useDefaultPolicy = false; } @@ -96,7 +99,9 @@ namespace Microsoft.AspNet.Authorization { foreach (var authType in authTypesSplit) { - policyBuilder.AuthenticationSchemes.Add(authType); + if (string.IsNullOrEmpty(authType)) + continue; + policyBuilder.AuthenticationSchemes.Add(authType.Trim()); } } if (useDefaultPolicy) diff --git a/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs index 03eccd2a62..487888d1f4 100644 --- a/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs @@ -67,5 +67,39 @@ namespace Microsoft.AspNet.Authroization.Test Assert.False(combined.Requirements.Any(r => r is DenyAnonymousAuthorizationRequirement)); Assert.Equal(2, combined.Requirements.OfType().Count()); } + + [Fact] + public void CombineMustTrimRoles() + { + // Arrange + var attributes = new AuthorizeAttribute[] { + new AuthorizeAttribute("2") { Roles = "r1 , r2" } + }; + var options = new AuthorizationOptions(); + + var combined = AuthorizationPolicy.Combine(options, attributes); + + Assert.True(combined.Requirements.Any(r => r is RolesAuthorizationRequirement)); + var rolesAuthorizationRequirement = combined.Requirements.OfType().First(); + Assert.Equal(2, rolesAuthorizationRequirement.AllowedRoles.Count()); + Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r1"))); + Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r2"))); + } + + [Fact] + public void CombineMustTrimAuthenticationScheme() + { + // Arrange + var attributes = new AuthorizeAttribute[] { + new AuthorizeAttribute("2") { ActiveAuthenticationSchemes = "a1 , a2" } + }; + var options = new AuthorizationOptions(); + + var combined = AuthorizationPolicy.Combine(options, attributes); + + Assert.Equal(2, combined.AuthenticationSchemes.Count()); + Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a1"))); + Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a2"))); + } } } \ No newline at end of file From ee6a57e9a2f4b7fa3c19ecaff637bf277ee690a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Lain=C3=A9?= Date: Mon, 28 Dec 2015 14:55:13 +0100 Subject: [PATCH 430/900] Fix unit tests --- .../AuthorizationPolicyFacts.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs index 487888d1f4..8807fa840f 100644 --- a/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs @@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Authroization.Test { // Arrange var attributes = new AuthorizeAttribute[] { - new AuthorizeAttribute("2") { Roles = "r1 , r2" } + new AuthorizeAttribute() { Roles = "r1 , r2" } }; var options = new AuthorizationOptions(); @@ -91,7 +91,7 @@ namespace Microsoft.AspNet.Authroization.Test { // Arrange var attributes = new AuthorizeAttribute[] { - new AuthorizeAttribute("2") { ActiveAuthenticationSchemes = "a1 , a2" } + new AuthorizeAttribute() { ActiveAuthenticationSchemes = "a1 , a2" } }; var options = new AuthorizationOptions(); From 9a5da5861b1f16f96e5bf1ff96de7a787c25b974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Lain=C3=A9?= Date: Mon, 28 Dec 2015 23:57:42 +0100 Subject: [PATCH 431/900] Fix coding style and handle case where empty roles & schemes are empty --- .../AuthorizationPolicy.cs | 18 ++++---- .../AuthorizationPolicyFacts.cs | 42 +++++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs index 1882efb51b..3e6d0a773d 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs @@ -85,23 +85,27 @@ namespace Microsoft.AspNet.Authorization policyBuilder.Combine(policy); useDefaultPolicy = false; } - var rolesSplit = authorizeAttribute.Roles?.Split(','); + var rolesSplit = authorizeAttribute.Roles?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (rolesSplit != null && rolesSplit.Any()) { for (int i = 0; i < rolesSplit.Length; ++i) - rolesSplit[i] = rolesSplit[i]?.Trim(); + { + rolesSplit[i] = rolesSplit[i].Trim(); + } - policyBuilder.RequireRole(rolesSplit); + policyBuilder.RequireRole(rolesSplit.Where(r => !string.IsNullOrWhiteSpace(r))); useDefaultPolicy = false; } - var authTypesSplit = authorizeAttribute.ActiveAuthenticationSchemes?.Split(','); + var authTypesSplit = authorizeAttribute.ActiveAuthenticationSchemes?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (authTypesSplit != null && authTypesSplit.Any()) { foreach (var authType in authTypesSplit) { - if (string.IsNullOrEmpty(authType)) - continue; - policyBuilder.AuthenticationSchemes.Add(authType.Trim()); + var trimmedAuthType = authType.Trim(); + if(!string.IsNullOrWhiteSpace(trimmedAuthType)) + { + policyBuilder.AuthenticationSchemes.Add(trimmedAuthType); + } } } if (useDefaultPolicy) diff --git a/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs index 8807fa840f..97430a1215 100644 --- a/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs @@ -77,8 +77,10 @@ namespace Microsoft.AspNet.Authroization.Test }; var options = new AuthorizationOptions(); + // Act var combined = AuthorizationPolicy.Combine(options, attributes); + // Assert Assert.True(combined.Requirements.Any(r => r is RolesAuthorizationRequirement)); var rolesAuthorizationRequirement = combined.Requirements.OfType().First(); Assert.Equal(2, rolesAuthorizationRequirement.AllowedRoles.Count()); @@ -95,11 +97,51 @@ namespace Microsoft.AspNet.Authroization.Test }; var options = new AuthorizationOptions(); + // Act var combined = AuthorizationPolicy.Combine(options, attributes); + // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a1"))); Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a2"))); } + + [Fact] + public void CombineMustIgnoreEmptyAuthenticationScheme() + { + // Arrange + var attributes = new AuthorizeAttribute[] { + new AuthorizeAttribute() { ActiveAuthenticationSchemes = "a1 , , ,,, a2" } + }; + var options = new AuthorizationOptions(); + + // Act + var combined = AuthorizationPolicy.Combine(options, attributes); + + // Assert + Assert.Equal(2, combined.AuthenticationSchemes.Count()); + Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a1"))); + Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a2"))); + } + + [Fact] + public void CombineMustIgnoreEmptyRoles() + { + // Arrange + var attributes = new AuthorizeAttribute[] { + new AuthorizeAttribute() { Roles = "r1 , ,, , r2" } + }; + var options = new AuthorizationOptions(); + + // Act + var combined = AuthorizationPolicy.Combine(options, attributes); + + // Assert + Assert.True(combined.Requirements.Any(r => r is RolesAuthorizationRequirement)); + var rolesAuthorizationRequirement = combined.Requirements.OfType().First(); + Assert.Equal(2, rolesAuthorizationRequirement.AllowedRoles.Count()); + Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r1"))); + Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r2"))); + } } } \ No newline at end of file From 9bf861307cd7d0edbebebd578a4ba7eab7096ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Lain=C3=A9?= Date: Wed, 30 Dec 2015 12:04:00 +0100 Subject: [PATCH 432/900] Rework the empty or space only filtering in Roles and Schemes --- .../AuthorizationPolicy.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs index 3e6d0a773d..befcb3c277 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs @@ -85,26 +85,22 @@ namespace Microsoft.AspNet.Authorization policyBuilder.Combine(policy); useDefaultPolicy = false; } - var rolesSplit = authorizeAttribute.Roles?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + var rolesSplit = authorizeAttribute.Roles?.Split(','); if (rolesSplit != null && rolesSplit.Any()) { - for (int i = 0; i < rolesSplit.Length; ++i) - { - rolesSplit[i] = rolesSplit[i].Trim(); - } + var trimmedRolesSplit = rolesSplit.Where(r => !string.IsNullOrWhiteSpace(r)).Select(r => r.Trim()); - policyBuilder.RequireRole(rolesSplit.Where(r => !string.IsNullOrWhiteSpace(r))); + policyBuilder.RequireRole(trimmedRolesSplit); useDefaultPolicy = false; } - var authTypesSplit = authorizeAttribute.ActiveAuthenticationSchemes?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + var authTypesSplit = authorizeAttribute.ActiveAuthenticationSchemes?.Split(','); if (authTypesSplit != null && authTypesSplit.Any()) { foreach (var authType in authTypesSplit) { - var trimmedAuthType = authType.Trim(); - if(!string.IsNullOrWhiteSpace(trimmedAuthType)) + if (!string.IsNullOrWhiteSpace(authType)) { - policyBuilder.AuthenticationSchemes.Add(trimmedAuthType); + policyBuilder.AuthenticationSchemes.Add(authType.Trim()); } } } From 74961cac493644922840b9e34c67a7a778871582 Mon Sep 17 00:00:00 2001 From: Nicholas Nelson Date: Wed, 30 Dec 2015 16:50:42 -0500 Subject: [PATCH 433/900] fix typo in log message HttContext.User merged...=>HttpContext.User merged --- src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs index 9beeb24823..c45fdfa7e6 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs @@ -108,7 +108,7 @@ namespace Microsoft.AspNet.Authentication if (ticket?.Principal != null) { Context.User = SecurityHelper.MergeUserPrincipal(Context.User, ticket.Principal); - Logger.LogInformation(0, "HttContext.User merged via AutomaticAuthentication from authenticationScheme: {scheme}.", Options.AuthenticationScheme); + Logger.LogInformation(0, "HttpContext.User merged via AutomaticAuthentication from authenticationScheme: {scheme}.", Options.AuthenticationScheme); } } } From 5c33ecd895e036cf9e2df64689ee5cccadbe97e5 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 4 Jan 2016 11:39:09 -0800 Subject: [PATCH 434/900] Disabling JwtBearer TokenValidationTest which is using an expired token --- .../JwtBearer/JwtBearerMiddlewareTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 7dee0f0ffb..33f573ca18 100644 --- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer { public class JwtBearerMiddlewareTests { - [ConditionalFact] + [ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/179 public async Task BearerTokenValidation() From d38fb1e49dfc037d379b8841add915f0964b63f1 Mon Sep 17 00:00:00 2001 From: Osmozy Date: Tue, 17 Nov 2015 00:28:50 +0300 Subject: [PATCH 435/900] Summary of the changes - No need to set the authenticationType in the Authorize_ShouldAllowIfClaimIsPresent unit test, since we already have another unit test for these functionality. - Specified the authentication scheme of the authorization policy in the Authorize_ShouldAllowIfClaimIsPresentWithSpecifiedAuthType unit test --- .../DefaultAuthorizationServiceTests.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs index 968f1151bb..63f1168991 100644 --- a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Authorization.Test options.AddPolicy("Basic", policy => policy.RequireClaim("Permission", "CanViewPage")); }); }); - var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim("Permission", "CanViewPage") }, "Basic")); + var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim("Permission", "CanViewPage") })); // Act var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); @@ -62,7 +62,10 @@ namespace Microsoft.AspNet.Authorization.Test { services.AddAuthorization(options => { - options.AddPolicy("Basic", policy => policy.RequireClaim("Permission", "CanViewPage")); + options.AddPolicy("Basic", policy => { + policy.AddAuthenticationSchemes("Basic"); + policy.RequireClaim("Permission", "CanViewPage"); + }); }); }); var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim("Permission", "CanViewPage") }, "Basic")); From f195ed3bab934aa0862a86390285c625f4e12386 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 4 Jan 2016 13:30:40 -0800 Subject: [PATCH 436/900] Allow value type resources for AuthZ --- .../AuthorizationHandler.cs | 7 ++-- .../DefaultAuthorizationServiceTests.cs | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationHandler.cs b/src/Microsoft.AspNet.Authorization/AuthorizationHandler.cs index 84e0160fee..bdfe8b1c13 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationHandler.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationHandler.cs @@ -35,7 +35,6 @@ namespace Microsoft.AspNet.Authorization } public abstract class AuthorizationHandler : IAuthorizationHandler - where TResource : class where TRequirement : IAuthorizationRequirement { public virtual async Task HandleAsync(AuthorizationContext context) @@ -57,13 +56,11 @@ namespace Microsoft.AspNet.Authorization public virtual void Handle(AuthorizationContext context) { - var resource = context.Resource as TResource; - // REVIEW: should we allow null resources? - if (resource != null) + if (context.Resource is TResource) { foreach (var req in context.Requirements.OfType()) { - Handle(context, req, resource); + Handle(context, req, (TResource)context.Resource); } } } diff --git a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs index 63f1168991..f2b28f6aba 100644 --- a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -817,6 +817,39 @@ namespace Microsoft.AspNet.Authorization.Test } } + public class EvenHandler : AuthorizationHandler + { + protected override void Handle(AuthorizationContext context, OperationAuthorizationRequirement requirement, int id) + { + if (id % 2 == 0) + { + context.Succeed(requirement); + } + } + } + + [Fact] + public async Task CanUseValueTypeResource() + { + // Arrange + var authorizationService = BuildAuthorizationService(services => + { + services.AddTransient(); + }); + var user = new ClaimsPrincipal( + new ClaimsIdentity( + new Claim[] { + }, + "AuthType") + ); + + // Act + // Assert + Assert.False(await authorizationService.AuthorizeAsync(user, 1, Operations.Edit)); + Assert.True(await authorizationService.AuthorizeAsync(user, 2, Operations.Edit)); + } + + [Fact] public async Task DoesNotCallHandlerWithWrongResourceType() { From 3257a82367e946a351cc1eaa02a9bb5dae2a432b Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 5 Jan 2016 14:32:31 -0800 Subject: [PATCH 437/900] Expose AuthenticationProperties in events --- .../CookieAuthenticationHandler.cs | 21 ++++---- .../Events/CookieRedirectContext.cs | 6 ++- .../Events/CookieSignedInContext.cs | 6 +-- .../Events/CookieSigningInContext.cs | 2 +- .../Events/CookieSigningOutContext.cs | 16 ++++--- .../FacebookHandler.cs | 8 +--- .../GoogleHandler.cs | 8 +--- .../Events/JwtBearerChallengeContext.cs | 6 ++- .../JwtBearerHandler.cs | 2 +- .../MicrosoftAccountHandler.cs | 7 +-- .../Events/OAuthCreatingTicketContext.cs | 12 ++++- .../OAuthHandler.cs | 6 +-- .../Events/AuthenticationValidatedContext.cs | 6 ++- .../AuthorizationCodeReceivedContext.cs | 9 ++-- .../AuthorizationResponseReceivedContext.cs | 5 +- .../Events/RedirectContext.cs | 6 ++- .../Events/TokenResponseReceivedContext.cs | 6 ++- .../OpenIdConnectHandler.cs | 25 +++++----- .../Cookies/CookieMiddlewareTests.cs | 48 +++++++++++++++++++ 19 files changed, 138 insertions(+), 67 deletions(-) diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs index e65640feaf..7cef596140 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -186,7 +186,7 @@ namespace Microsoft.AspNet.Authentication.Cookies cookieValue, cookieOptions); - await ApplyHeaders(shouldRedirectToReturnUrl: false); + await ApplyHeaders(shouldRedirectToReturnUrl: false, properties: ticket.Properties); } } @@ -261,7 +261,7 @@ namespace Microsoft.AspNet.Authentication.Cookies // Only redirect on the login path var shouldRedirect = Options.LoginPath.HasValue && OriginalPath == Options.LoginPath; - await ApplyHeaders(shouldRedirect); + await ApplyHeaders(shouldRedirect, signedInContext.Properties); } protected override async Task HandleSignOutAsync(SignOutContext signOutContext) @@ -277,6 +277,7 @@ namespace Microsoft.AspNet.Authentication.Cookies var context = new CookieSigningOutContext( Context, Options, + new AuthenticationProperties(signOutContext.Properties), cookieOptions); await Options.Events.SigningOut(context); @@ -288,10 +289,10 @@ namespace Microsoft.AspNet.Authentication.Cookies // Only redirect on the logout path var shouldRedirect = Options.LogoutPath.HasValue && OriginalPath == Options.LogoutPath; - await ApplyHeaders(shouldRedirect); + await ApplyHeaders(shouldRedirect, context.Properties); } - private async Task ApplyHeaders(bool shouldRedirectToReturnUrl) + private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationProperties properties) { Response.Headers[HeaderNames.CacheControl] = HeaderValueNoCache; Response.Headers[HeaderNames.Pragma] = HeaderValueNoCache; @@ -303,7 +304,7 @@ namespace Microsoft.AspNet.Authentication.Cookies if (!StringValues.IsNullOrEmpty(redirectUri) && IsHostRelative(redirectUri)) { - var redirectContext = new CookieRedirectContext(Context, Options, redirectUri); + var redirectContext = new CookieRedirectContext(Context, Options, redirectUri, properties); await Options.Events.RedirectToReturnUrl(redirectContext); } } @@ -325,13 +326,14 @@ namespace Microsoft.AspNet.Authentication.Cookies protected override async Task HandleForbiddenAsync(ChallengeContext context) { - var returnUrl = new AuthenticationProperties(context.Properties).RedirectUri; + var properties = new AuthenticationProperties(context.Properties); + var returnUrl = properties.RedirectUri; if (string.IsNullOrEmpty(returnUrl)) { returnUrl = OriginalPathBase + Request.Path + Request.QueryString; } var accessDeniedUri = Options.AccessDeniedPath + QueryString.Create(Options.ReturnUrlParameter, returnUrl); - var redirectContext = new CookieRedirectContext(Context, Options, BuildRedirectUri(accessDeniedUri)); + var redirectContext = new CookieRedirectContext(Context, Options, BuildRedirectUri(accessDeniedUri), properties); await Options.Events.RedirectToAccessDenied(redirectContext); return true; } @@ -343,14 +345,15 @@ namespace Microsoft.AspNet.Authentication.Cookies throw new ArgumentNullException(nameof(context)); } - var redirectUri = new AuthenticationProperties(context.Properties).RedirectUri; + var properties = new AuthenticationProperties(context.Properties); + var redirectUri = properties.RedirectUri; if (string.IsNullOrEmpty(redirectUri)) { redirectUri = OriginalPathBase + Request.Path + Request.QueryString; } var loginUri = Options.LoginPath + QueryString.Create(Options.ReturnUrlParameter, redirectUri); - var redirectContext = new CookieRedirectContext(Context, Options, BuildRedirectUri(loginUri)); + var redirectContext = new CookieRedirectContext(Context, Options, BuildRedirectUri(loginUri), properties); await Options.Events.RedirectToLogin(redirectContext); return true; diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieRedirectContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieRedirectContext.cs index 07a69dc358..437e8927e1 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieRedirectContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieRedirectContext.cs @@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Authentication; namespace Microsoft.AspNet.Authentication.Cookies { @@ -18,10 +19,11 @@ namespace Microsoft.AspNet.Authentication.Cookies /// The cookie middleware options /// The initial redirect URI [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#", Justification = "Represents header value")] - public CookieRedirectContext(HttpContext context, CookieAuthenticationOptions options, string redirectUri) + public CookieRedirectContext(HttpContext context, CookieAuthenticationOptions options, string redirectUri, AuthenticationProperties properties) : base(context, options) { RedirectUri = redirectUri; + Properties = properties; } /// @@ -29,5 +31,7 @@ namespace Microsoft.AspNet.Authentication.Cookies /// [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "Represents header value")] public string RedirectUri { get; set; } + + public AuthenticationProperties Properties { get; } } } diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs index 838f73e621..17f5090cda 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs @@ -36,16 +36,16 @@ namespace Microsoft.AspNet.Authentication.Cookies /// /// The name of the AuthenticationScheme creating a cookie /// - public string AuthenticationScheme { get; private set; } + public string AuthenticationScheme { get; } /// /// Contains the claims that were converted into the outgoing cookie. /// - public ClaimsPrincipal Principal { get; private set; } + public ClaimsPrincipal Principal { get; } /// /// Contains the extra data that was contained in the outgoing cookie. /// - public AuthenticationProperties Properties { get; private set; } + public AuthenticationProperties Properties { get; } } } diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs index cf630fc31d..fa441b4b0e 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs @@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Authentication.Cookies /// /// The name of the AuthenticationScheme creating a cookie /// - public string AuthenticationScheme { get; private set; } + public string AuthenticationScheme { get; } /// /// Contains the claims about to be converted into the outgoing cookie. diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs index 55a9c762d8..a510dbcb59 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Authentication; namespace Microsoft.AspNet.Authentication.Cookies { @@ -16,20 +17,23 @@ namespace Microsoft.AspNet.Authentication.Cookies /// /// /// - public CookieSigningOutContext(HttpContext context, CookieAuthenticationOptions options, CookieOptions cookieOptions) + public CookieSigningOutContext( + HttpContext context, + CookieAuthenticationOptions options, + AuthenticationProperties properties, + CookieOptions cookieOptions) : base(context, options) { CookieOptions = cookieOptions; + Properties = properties; } /// /// The options for creating the outgoing cookie. /// May be replace or altered during the SigningOut call. /// - public CookieOptions CookieOptions - { - get; - set; - } + public CookieOptions CookieOptions { get; set; } + + public AuthenticationProperties Properties { get; set; } } } diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs index d390384710..8d9548c428 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs @@ -37,12 +37,8 @@ namespace Microsoft.AspNet.Authentication.Facebook response.EnsureSuccessStatusCode(); var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - - var context = new OAuthCreatingTicketContext(Context, Options, Backchannel, tokens, payload) - { - Properties = properties, - Principal = new ClaimsPrincipal(identity) - }; + + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Options, Backchannel, tokens, payload); var identifier = FacebookHelper.GetId(payload); if (!string.IsNullOrEmpty(identifier)) diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs index 1d692b4549..f1a1eb145e 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs @@ -31,12 +31,8 @@ namespace Microsoft.AspNet.Authentication.Google response.EnsureSuccessStatusCode(); var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - - var context = new OAuthCreatingTicketContext(Context, Options, Backchannel, tokens, payload) - { - Properties = properties, - Principal = new ClaimsPrincipal(identity) - }; + + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Options, Backchannel, tokens, payload); var identifier = GoogleHelper.GetId(payload); if (!string.IsNullOrEmpty(identifier)) diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs index 7a6ce6991a..ae6b9d4c69 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs @@ -2,14 +2,18 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Authentication; namespace Microsoft.AspNet.Authentication.JwtBearer { public class JwtBearerChallengeContext : BaseJwtBearerContext { - public JwtBearerChallengeContext(HttpContext context, JwtBearerOptions options) + public JwtBearerChallengeContext(HttpContext context, JwtBearerOptions options, AuthenticationProperties properties) : base(context, options) { + Properties = properties; } + + public AuthenticationProperties Properties { get; } } } diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs index 6983041327..74faa2e63f 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs @@ -203,7 +203,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { - var eventContext = new JwtBearerChallengeContext(Context, Options); + var eventContext = new JwtBearerChallengeContext(Context, Options, new AuthenticationProperties(context.Properties)); await Options.Events.Challenge(eventContext); if (eventContext.HandledResponse) { diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 940b115444..6c775906d3 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -27,13 +27,8 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount response.EnsureSuccessStatusCode(); var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - - var context = new OAuthCreatingTicketContext(Context, Options, Backchannel, tokens, payload) - { - Properties = properties, - Principal = new ClaimsPrincipal(identity) - }; + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Options, Backchannel, tokens, payload); var identifier = MicrosoftAccountHelper.GetId(payload); if (!string.IsNullOrEmpty(identifier)) { diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs index 05961d5ee5..bae81bf8e9 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -19,28 +19,36 @@ namespace Microsoft.AspNet.Authentication.OAuth /// /// Initializes a new . /// + /// The representing the user. + /// Property bag for common authentication properties. /// 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 OAuthCreatingTicketContext( + ClaimsPrincipal principal, + AuthenticationProperties properties, HttpContext context, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens) - : this(context, options, backchannel, tokens, user: new JObject()) + : this(principal, properties, context, options, backchannel, tokens, user: new JObject()) { } /// /// Initializes a new . /// + /// The representing the user. + /// Property bag for common authentication properties. /// 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 OAuthCreatingTicketContext( + ClaimsPrincipal principal, + AuthenticationProperties properties, HttpContext context, OAuthOptions options, HttpClient backchannel, @@ -77,6 +85,8 @@ namespace Microsoft.AspNet.Authentication.OAuth Backchannel = backchannel; User = user; Options = options; + Principal = principal; + Properties = properties; } public OAuthOptions Options { get; } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs index 1d36e1437d..c7a3c5efa4 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs @@ -155,11 +155,7 @@ namespace Microsoft.AspNet.Authentication.OAuth protected virtual async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) { - var context = new OAuthCreatingTicketContext(Context, Options, Backchannel, tokens) - { - Principal = new ClaimsPrincipal(identity), - Properties = properties - }; + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Options, Backchannel, tokens); await Options.Events.CreatingTicket(context); diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs index b12aedce22..f9998b83e7 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs @@ -2,17 +2,21 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNet.Authentication.OpenIdConnect { public class AuthenticationValidatedContext : BaseOpenIdConnectContext { - public AuthenticationValidatedContext(HttpContext context, OpenIdConnectOptions options) + public AuthenticationValidatedContext(HttpContext context, OpenIdConnectOptions options, AuthenticationProperties properties) : base(context, options) { + Properties = properties; } + public AuthenticationProperties Properties { get; } + public OpenIdConnectMessage TokenEndpointResponse { get; set; } } } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs index 9489e5c25f..59f4d49115 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs @@ -4,7 +4,7 @@ using System.Diagnostics.CodeAnalysis; using System.IdentityModel.Tokens.Jwt; using Microsoft.AspNet.Http; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Microsoft.AspNet.Http.Authentication; namespace Microsoft.AspNet.Authentication.OpenIdConnect { @@ -16,11 +16,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect /// /// Creates a /// - public AuthorizationCodeReceivedContext(HttpContext context, OpenIdConnectOptions options) + public AuthorizationCodeReceivedContext(HttpContext context, OpenIdConnectOptions options, AuthenticationProperties properties) : base(context, options) - { + { + Properties = properties; } + public AuthenticationProperties Properties { get; set; } + /// /// Gets or sets the 'code'. /// diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs index e433d28744..8e8b86a13a 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs @@ -9,11 +9,12 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { public class AuthorizationResponseReceivedContext : BaseOpenIdConnectContext { - public AuthorizationResponseReceivedContext(HttpContext context, OpenIdConnectOptions options) + public AuthorizationResponseReceivedContext(HttpContext context, OpenIdConnectOptions options, AuthenticationProperties properties) : base(context, options) { + Properties = properties; } - public AuthenticationProperties Properties { get; set; } + public AuthenticationProperties Properties { get; } } } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/RedirectContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/RedirectContext.cs index dcd06843c5..fa1ef30d08 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/RedirectContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/RedirectContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNet.Authentication.OpenIdConnect @@ -12,9 +13,12 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect /// public class RedirectContext : BaseOpenIdConnectContext { - public RedirectContext(HttpContext context, OpenIdConnectOptions options) + public RedirectContext(HttpContext context, OpenIdConnectOptions options, AuthenticationProperties properties) : base(context, options) { + Properties = properties; } + + public AuthenticationProperties Properties { get; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs index 19c58dca9f..e9522f70d8 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs @@ -1,4 +1,5 @@ using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNet.Authentication.OpenIdConnect @@ -11,11 +12,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect /// /// Creates a /// - public TokenResponseReceivedContext(HttpContext context, OpenIdConnectOptions options) + public TokenResponseReceivedContext(HttpContext context, OpenIdConnectOptions options, AuthenticationProperties properties) : base(context, options) { + Properties = properties; } + public AuthenticationProperties Properties { get; } + /// /// Gets or sets the that contains the tokens received after redeeming the code at the token endpoint. /// diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 9f8e4f9572..14472b4b9a 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -99,7 +99,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect message.IdTokenHint = principal?.FindFirst(OpenIdConnectParameterNames.IdToken)?.Value; } - var redirectContext = new RedirectContext(Context, Options) + var redirectContext = new RedirectContext(Context, Options, properties) { ProtocolMessage = message }; @@ -215,7 +215,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect GenerateCorrelationId(properties); - var redirectContext = new RedirectContext(Context, Options) + var redirectContext = new RedirectContext(Context, Options, properties) { ProtocolMessage = message }; @@ -379,10 +379,9 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect } Logger.LogTrace(15, "Authorization response received."); - var authorizationResponseReceivedContext = new AuthorizationResponseReceivedContext(Context, Options) + var authorizationResponseReceivedContext = new AuthorizationResponseReceivedContext(Context, Options, properties) { - ProtocolMessage = message, - Properties = properties + ProtocolMessage = message }; await Options.Events.AuthorizationResponseReceived(authorizationResponseReceivedContext); if (authorizationResponseReceivedContext.HandledResponse) @@ -469,7 +468,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var tokenEndpointResponse = await RedeemAuthorizationCodeAsync(code, authorizationCodeReceivedContext.RedirectUri); - var authorizationCodeRedeemedContext = await RunTokenResponseReceivedEventAsync(message, tokenEndpointResponse); + var authorizationCodeRedeemedContext = await RunTokenResponseReceivedEventAsync(message, tokenEndpointResponse, properties); if (authorizationCodeRedeemedContext.HandledResponse) { return AuthenticateResult.Success(authorizationCodeRedeemedContext.AuthenticationTicket); @@ -502,7 +501,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect Nonce = nonce }); - var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(message, ticket, tokenEndpointResponse); + var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(message, ticket, properties, tokenEndpointResponse); if (authenticationValidatedContext.HandledResponse) { return AuthenticateResult.Success(authenticationValidatedContext.AuthenticationTicket); @@ -551,7 +550,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect Nonce = nonce }); - var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(message, ticket, tokenEndpointResponse: null); + var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(message, ticket, properties, tokenEndpointResponse: null); if (authenticationValidatedContext.HandledResponse) { return AuthenticateResult.Success(authenticationValidatedContext.AuthenticationTicket); @@ -950,7 +949,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect Logger.LogTrace(32, "AuthorizationCode received: '{0}'", message.Code); - var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Options) + var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Options, properties) { Code = message.Code, ProtocolMessage = message, @@ -972,10 +971,10 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect return authorizationCodeReceivedContext; } - private async Task RunTokenResponseReceivedEventAsync(OpenIdConnectMessage message, OpenIdConnectMessage tokenEndpointResponse) + private async Task RunTokenResponseReceivedEventAsync(OpenIdConnectMessage message, OpenIdConnectMessage tokenEndpointResponse, AuthenticationProperties properties) { Logger.LogTrace(35, "Token response received."); - var tokenResponseReceivedContext = new TokenResponseReceivedContext(Context, Options) + var tokenResponseReceivedContext = new TokenResponseReceivedContext(Context, Options, properties) { ProtocolMessage = message, TokenEndpointResponse = tokenEndpointResponse @@ -993,9 +992,9 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect return tokenResponseReceivedContext; } - private async Task RunAuthenticationValidatedEventAsync(OpenIdConnectMessage message, AuthenticationTicket ticket, OpenIdConnectMessage tokenEndpointResponse) + private async Task RunAuthenticationValidatedEventAsync(OpenIdConnectMessage message, AuthenticationTicket ticket, AuthenticationProperties properties, OpenIdConnectMessage tokenEndpointResponse) { - var authenticationValidatedContext = new AuthenticationValidatedContext(Context, Options) + var authenticationValidatedContext = new AuthenticationValidatedContext(Context, Options, properties) { AuthenticationTicket = ticket, ProtocolMessage = message, diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 852b63f3e0..329b0d176e 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -533,6 +533,54 @@ namespace Microsoft.AspNet.Authentication.Cookies Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); } + [Fact] + public async Task CookieValidatorOnlyCalledOnce() + { + var clock = new TestClock(); + var server = CreateServer(options => + { + options.SystemClock = clock; + options.ExpireTimeSpan = TimeSpan.FromMinutes(10); + options.SlidingExpiration = false; + options.Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = ctx => + { + ctx.ShouldRenew = true; + return Task.FromResult(0); + } + }; + }, + context => + context.Authentication.SignInAsync("Cookies", + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction2.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + + clock.Add(TimeSpan.FromMinutes(5)); + + var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); + Assert.NotNull(transaction3.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); + + clock.Add(TimeSpan.FromMinutes(6)); + + var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.Null(transaction4.SetCookie); + Assert.Null(FindClaimValue(transaction4, ClaimTypes.Name)); + + clock.Add(TimeSpan.FromMinutes(5)); + + var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); + Assert.Null(transaction5.SetCookie); + Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); + } + + [Fact] public async Task CookieExpirationCanBeOverridenInEvent() { From 7a23028527d6aaf3d468a8d943a118a0c751f523 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 5 Jan 2016 15:46:58 -0800 Subject: [PATCH 438/900] Switch to AuthenticationTicket in OAuth event --- .../FacebookHandler.cs | 5 +-- .../GoogleHandler.cs | 5 +-- .../JwtBearerHandler.cs | 12 +++---- .../MicrosoftAccountHandler.cs | 6 ++-- .../Events/OAuthCreatingTicketContext.cs | 32 +++++++------------ .../OAuthHandler.cs | 12 ++----- .../OpenIdConnectHandler.cs | 32 +++++++++---------- .../Events/BaseControlContext.cs | 6 ++-- .../Events/TicketReceivedContext.cs | 2 +- .../Google/GoogleMiddlewareTests.cs | 4 +-- .../JwtBearer/JwtBearerMiddlewareTests.cs | 12 +++---- .../MicrosoftAccountMiddlewareTests.cs | 2 +- 12 files changed, 58 insertions(+), 72 deletions(-) diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs index 8d9548c428..44bc1468ee 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs @@ -38,7 +38,8 @@ namespace Microsoft.AspNet.Authentication.Facebook var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Options, Backchannel, tokens, payload); + var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Options.AuthenticationScheme); + var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens, payload); var identifier = FacebookHelper.GetId(payload); if (!string.IsNullOrEmpty(identifier)) @@ -78,7 +79,7 @@ namespace Microsoft.AspNet.Authentication.Facebook await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, context.Options.AuthenticationScheme); + return context.Ticket; } private string GenerateAppSecretProof(string accessToken) diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs index f1a1eb145e..e4b50132ad 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs @@ -32,7 +32,8 @@ namespace Microsoft.AspNet.Authentication.Google var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Options, Backchannel, tokens, payload); + var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Options.AuthenticationScheme); + var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens, payload); var identifier = GoogleHelper.GetId(payload); if (!string.IsNullOrEmpty(identifier)) @@ -72,7 +73,7 @@ namespace Microsoft.AspNet.Authentication.Google await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, context.Options.AuthenticationScheme); + return context.Ticket; } // TODO: Abstract this properties override pattern into the base class? diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs index 74faa2e63f..08640019c9 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer await Options.Events.ReceivingToken(receivingTokenContext); if (receivingTokenContext.HandledResponse) { - return AuthenticateResult.Success(receivingTokenContext.AuthenticationTicket); + return AuthenticateResult.Success(receivingTokenContext.Ticket); } if (receivingTokenContext.Skipped) { @@ -77,7 +77,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer await Options.Events.ReceivedToken(receivedTokenContext); if (receivedTokenContext.HandledResponse) { - return AuthenticateResult.Success(receivedTokenContext.AuthenticationTicket); + return AuthenticateResult.Success(receivedTokenContext.Ticket); } if (receivedTokenContext.Skipped) { @@ -139,13 +139,13 @@ namespace Microsoft.AspNet.Authentication.JwtBearer var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Options.AuthenticationScheme); var validatedTokenContext = new ValidatedTokenContext(Context, Options) { - AuthenticationTicket = ticket + Ticket = ticket }; await Options.Events.ValidatedToken(validatedTokenContext); if (validatedTokenContext.HandledResponse) { - return AuthenticateResult.Success(validatedTokenContext.AuthenticationTicket); + return AuthenticateResult.Success(validatedTokenContext.Ticket); } if (validatedTokenContext.Skipped) { @@ -166,7 +166,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer await Options.Events.AuthenticationFailed(authenticationFailedContext); if (authenticationFailedContext.HandledResponse) { - return AuthenticateResult.Success(authenticationFailedContext.AuthenticationTicket); + return AuthenticateResult.Success(authenticationFailedContext.Ticket); } if (authenticationFailedContext.Skipped) { @@ -190,7 +190,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer await Options.Events.AuthenticationFailed(authenticationFailedContext); if (authenticationFailedContext.HandledResponse) { - return AuthenticateResult.Success(authenticationFailedContext.AuthenticationTicket); + return AuthenticateResult.Success(authenticationFailedContext.Ticket); } if (authenticationFailedContext.Skipped) { diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 6c775906d3..35dcc92239 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -28,7 +28,8 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Options, Backchannel, tokens, payload); + var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Options.AuthenticationScheme); + var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens, payload); var identifier = MicrosoftAccountHelper.GetId(payload); if (!string.IsNullOrEmpty(identifier)) { @@ -50,8 +51,7 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount } await Options.Events.CreatingTicket(context); - - return new AuthenticationTicket(context.Principal, context.Properties, context.Options.AuthenticationScheme); + return context.Ticket; } } } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs index bae81bf8e9..835bb2e3ae 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -19,36 +19,32 @@ namespace Microsoft.AspNet.Authentication.OAuth /// /// Initializes a new . /// - /// The representing the user. - /// Property bag for common authentication properties. + /// The . /// 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 OAuthCreatingTicketContext( - ClaimsPrincipal principal, - AuthenticationProperties properties, + AuthenticationTicket ticket, HttpContext context, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens) - : this(principal, properties, context, options, backchannel, tokens, user: new JObject()) + : this(ticket, context, options, backchannel, tokens, user: new JObject()) { } /// /// Initializes a new . /// - /// The representing the user. - /// Property bag for common authentication properties. + /// The . /// 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 OAuthCreatingTicketContext( - ClaimsPrincipal principal, - AuthenticationProperties properties, + AuthenticationTicket ticket, HttpContext context, OAuthOptions options, HttpClient backchannel, @@ -85,8 +81,7 @@ namespace Microsoft.AspNet.Authentication.OAuth Backchannel = backchannel; User = user; Options = options; - Principal = principal; - Properties = properties; + Ticket = ticket; } public OAuthOptions Options { get; } @@ -140,19 +135,14 @@ namespace Microsoft.AspNet.Authentication.OAuth public HttpClient Backchannel { get; } /// - /// Gets the representing the user. + /// The that will be created. /// - public ClaimsPrincipal Principal { get; set; } + public AuthenticationTicket Ticket { get; set; } /// - /// Gets the main identity exposed by . - /// This property returns null when is null. + /// Gets the main identity exposed by . + /// This property returns null when is null. /// - public ClaimsIdentity Identity => Principal?.Identity as ClaimsIdentity; - - /// - /// Gets or sets a property bag for common authentication properties. - /// - public AuthenticationProperties Properties { get; set; } + public ClaimsIdentity Identity => Ticket?.Principal.Identity as ClaimsIdentity; } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs index c7a3c5efa4..6f197d86bc 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs @@ -155,16 +155,10 @@ namespace Microsoft.AspNet.Authentication.OAuth protected virtual async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) { - var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Options, Backchannel, tokens); - + var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Options.AuthenticationScheme); + var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens); await Options.Events.CreatingTicket(context); - - if (context.Principal?.Identity == null) - { - return null; - } - - return new AuthenticationTicket(context.Principal, context.Properties, Options.AuthenticationScheme); + return context.Ticket; } protected override async Task HandleUnauthorizedAsync(ChallengeContext context) diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 14472b4b9a..2d157e48c3 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -332,7 +332,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var messageReceivedContext = await RunMessageReceivedEventAsync(message); if (messageReceivedContext.HandledResponse) { - return AuthenticateResult.Success(messageReceivedContext.AuthenticationTicket); + return AuthenticateResult.Success(messageReceivedContext.Ticket); } else if (messageReceivedContext.Skipped) { @@ -387,7 +387,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect if (authorizationResponseReceivedContext.HandledResponse) { Logger.LogDebug(16, "AuthorizationResponseReceived.HandledResponse"); - return AuthenticateResult.Success(authorizationResponseReceivedContext.AuthenticationTicket); + return AuthenticateResult.Success(authorizationResponseReceivedContext.Ticket); } else if (authorizationResponseReceivedContext.Skipped) { @@ -428,7 +428,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var authenticationFailedContext = await RunAuthenticationFailedEventAsync(message, exception); if (authenticationFailedContext.HandledResponse) { - return AuthenticateResult.Success(authenticationFailedContext.AuthenticationTicket); + return AuthenticateResult.Success(authenticationFailedContext.Ticket); } else if (authenticationFailedContext.Skipped) { @@ -454,7 +454,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(message, properties, ticket, jwt); if (authorizationCodeReceivedContext.HandledResponse) { - return AuthenticateResult.Success(authorizationCodeReceivedContext.AuthenticationTicket); + return AuthenticateResult.Success(authorizationCodeReceivedContext.Ticket); } else if (authorizationCodeReceivedContext.Skipped) { @@ -471,7 +471,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var authorizationCodeRedeemedContext = await RunTokenResponseReceivedEventAsync(message, tokenEndpointResponse, properties); if (authorizationCodeRedeemedContext.HandledResponse) { - return AuthenticateResult.Success(authorizationCodeRedeemedContext.AuthenticationTicket); + return AuthenticateResult.Success(authorizationCodeRedeemedContext.Ticket); } else if (authorizationCodeRedeemedContext.Skipped) { @@ -504,13 +504,13 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(message, ticket, properties, tokenEndpointResponse); if (authenticationValidatedContext.HandledResponse) { - return AuthenticateResult.Success(authenticationValidatedContext.AuthenticationTicket); + return AuthenticateResult.Success(authenticationValidatedContext.Ticket); } else if (authenticationValidatedContext.Skipped) { return AuthenticateResult.Skip(); } - ticket = authenticationValidatedContext.AuthenticationTicket; + ticket = authenticationValidatedContext.Ticket; if (Options.SaveTokensAsClaims) { @@ -553,14 +553,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(message, ticket, properties, tokenEndpointResponse: null); if (authenticationValidatedContext.HandledResponse) { - return AuthenticateResult.Success(authenticationValidatedContext.AuthenticationTicket); + return AuthenticateResult.Success(authenticationValidatedContext.Ticket); } else if (authenticationValidatedContext.Skipped) { return AuthenticateResult.Skip(); } message = authenticationValidatedContext.ProtocolMessage; - ticket = authenticationValidatedContext.AuthenticationTicket; + ticket = authenticationValidatedContext.Ticket; // Hybrid Flow if (message.Code != null) @@ -568,14 +568,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(message, properties, ticket, jwt); if (authorizationCodeReceivedContext.HandledResponse) { - return AuthenticateResult.Success(authorizationCodeReceivedContext.AuthenticationTicket); + return AuthenticateResult.Success(authorizationCodeReceivedContext.Ticket); } else if (authorizationCodeReceivedContext.Skipped) { return AuthenticateResult.Skip(); } message = authorizationCodeReceivedContext.ProtocolMessage; - ticket = authorizationCodeReceivedContext.AuthenticationTicket; + ticket = authorizationCodeReceivedContext.Ticket; if (Options.SaveTokensAsClaims) { @@ -666,13 +666,13 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(ticket, message, user); if (userInformationReceivedContext.HandledResponse) { - return userInformationReceivedContext.AuthenticationTicket; + return userInformationReceivedContext.Ticket; } else if (userInformationReceivedContext.Skipped) { return ticket; } - ticket = userInformationReceivedContext.AuthenticationTicket; + ticket = userInformationReceivedContext.Ticket; user = userInformationReceivedContext.User; Options.ProtocolValidator.ValidateUserInfoResponse(new OpenIdConnectProtocolValidationContext() @@ -954,7 +954,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect Code = message.Code, ProtocolMessage = message, RedirectUri = redirectUri, - AuthenticationTicket = ticket, + Ticket = ticket, JwtSecurityToken = jwt }; @@ -996,7 +996,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { var authenticationValidatedContext = new AuthenticationValidatedContext(Context, Options, properties) { - AuthenticationTicket = ticket, + Ticket = ticket, ProtocolMessage = message, TokenEndpointResponse = tokenEndpointResponse, }; @@ -1020,7 +1020,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var userInformationReceivedContext = new UserInformationReceivedContext(Context, Options) { - AuthenticationTicket = ticket, + Ticket = ticket, ProtocolMessage = message, User = user, }; diff --git a/src/Microsoft.AspNet.Authentication/Events/BaseControlContext.cs b/src/Microsoft.AspNet.Authentication/Events/BaseControlContext.cs index 5e28dfc6c1..4e986c808e 100644 --- a/src/Microsoft.AspNet.Authentication/Events/BaseControlContext.cs +++ b/src/Microsoft.AspNet.Authentication/Events/BaseControlContext.cs @@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Authentication /// /// Discontinue all processing for this request and return to the client. /// The caller is responsible for generating the full response. - /// Set the to trigger SignIn. + /// Set the to trigger SignIn. /// public void HandleResponse() { @@ -43,8 +43,8 @@ namespace Microsoft.AspNet.Authentication } /// - /// Gets or set the to return if this event signals it handled the event. + /// Gets or set the to return if this event signals it handled the event. /// - public AuthenticationTicket AuthenticationTicket { get; set; } + public AuthenticationTicket Ticket { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs b/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs index b2c5adbc58..28f6649fee 100644 --- a/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Authentication : base(context) { Options = options; - AuthenticationTicket = ticket; + Ticket = ticket; if (ticket != null) { Principal = ticket.Principal; diff --git a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs index 11fbe67e51..dcfe91e5a1 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -531,7 +531,7 @@ namespace Microsoft.AspNet.Authentication.Google OnCreatingTicket = context => { var refreshToken = context.RefreshToken; - context.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Google") }, "Google")); + context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Google") }, "Google")); return Task.FromResult(0); } }; @@ -610,7 +610,7 @@ namespace Microsoft.AspNet.Authentication.Google { OnTicketReceived = context => { - context.AuthenticationTicket.Properties.RedirectUri = null; + context.Ticket.Properties.RedirectUri = null; return Task.FromResult(0); } }; diff --git a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 33f573ca18..a3e7fbd54e 100644 --- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -82,7 +82,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - context.AuthenticationTicket = new AuthenticationTicket( + context.Ticket = new AuthenticationTicket( new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), new AuthenticationProperties(), context.Options.AuthenticationScheme); @@ -160,7 +160,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - context.AuthenticationTicket = new AuthenticationTicket( + context.Ticket = new AuthenticationTicket( new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), new AuthenticationProperties(), context.Options.AuthenticationScheme); @@ -189,7 +189,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer { // Retrieve the NameIdentifier claim from the identity // returned by the custom security token validator. - var identity = (ClaimsIdentity)context.AuthenticationTicket.Principal.Identity; + var identity = (ClaimsIdentity)context.Ticket.Principal.Identity; var identifier = identity.FindFirst(ClaimTypes.NameIdentifier); Assert.Equal("Bob le Tout Puissant", identifier.Value); @@ -236,7 +236,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - context.AuthenticationTicket = new AuthenticationTicket( + context.Ticket = new AuthenticationTicket( new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), new AuthenticationProperties(), context.Options.AuthenticationScheme); @@ -268,7 +268,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - context.AuthenticationTicket = new AuthenticationTicket( + context.Ticket = new AuthenticationTicket( new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), new AuthenticationProperties(), context.Options.AuthenticationScheme); @@ -299,7 +299,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - context.AuthenticationTicket = new AuthenticationTicket( + context.Ticket = new AuthenticationTicket( new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), new AuthenticationProperties(), context.Options.AuthenticationScheme); diff --git a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index 1b5bd483b7..849cdfe0a2 100644 --- a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -150,7 +150,7 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount OnCreatingTicket = context => { var refreshToken = context.RefreshToken; - context.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Microsoft") }, "Microsoft")); + context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Microsoft") }, "Microsoft")); return Task.FromResult(null); } }; From 5bcc1bfc260978b0bea9b981056dd0beb31df400 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 8 Jan 2016 13:22:55 -0800 Subject: [PATCH 439/900] Also refresh expires/Issues when renewing cookie --- .../CookieAuthenticationHandler.cs | 64 +++++++++++-------- .../Cookies/CookieMiddlewareTests.cs | 55 ++++++++++++++++ 2 files changed, 94 insertions(+), 25 deletions(-) diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs index 7cef596140..82a47ecaeb 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -21,9 +21,9 @@ namespace Microsoft.AspNet.Authentication.Cookies private const string HeaderValueMinusOne = "-1"; private const string SessionIdClaim = "Microsoft.AspNet.Authentication.Cookies-SessionId"; - private bool _shouldRenew; - private DateTimeOffset? _renewIssuedUtc; - private DateTimeOffset? _renewExpiresUtc; + private bool _shouldRefresh; + private DateTimeOffset? _refreshIssuedUtc; + private DateTimeOffset? _refreshExpiresUtc; private string _sessionKey; private Task _readCookieTask; @@ -37,6 +37,33 @@ namespace Microsoft.AspNet.Authentication.Cookies return _readCookieTask; } + private void CheckForRefresh(AuthenticationTicket ticket) + { + var currentUtc = Options.SystemClock.UtcNow; + var issuedUtc = ticket.Properties.IssuedUtc; + var expiresUtc = ticket.Properties.ExpiresUtc; + var allowRefresh = ticket.Properties.AllowRefresh ?? true; + if (issuedUtc != null && expiresUtc != null && Options.SlidingExpiration && allowRefresh) + { + var timeElapsed = currentUtc.Subtract(issuedUtc.Value); + var timeRemaining = expiresUtc.Value.Subtract(currentUtc); + + if (timeRemaining < timeElapsed) + { + RequestRefresh(ticket); + } + } + } + + private void RequestRefresh(AuthenticationTicket ticket) + { + _shouldRefresh = true; + var currentUtc = Options.SystemClock.UtcNow; + _refreshIssuedUtc = currentUtc; + var timeSpan = ticket.Properties.ExpiresUtc.Value.Subtract(ticket.Properties.IssuedUtc.Value); + _refreshExpiresUtc = currentUtc.Add(timeSpan); + } + private async Task ReadCookieTicket() { var cookie = Options.CookieManager.GetRequestCookie(Context, Options.CookieName); @@ -79,20 +106,7 @@ namespace Microsoft.AspNet.Authentication.Cookies return AuthenticateResult.Fail("Ticket expired"); } - var allowRefresh = ticket.Properties.AllowRefresh ?? true; - if (issuedUtc != null && expiresUtc != null && Options.SlidingExpiration && allowRefresh) - { - var timeElapsed = currentUtc.Subtract(issuedUtc.Value); - var timeRemaining = expiresUtc.Value.Subtract(currentUtc); - - if (timeRemaining < timeElapsed) - { - _shouldRenew = true; - _renewIssuedUtc = currentUtc; - var timeSpan = expiresUtc.Value.Subtract(issuedUtc.Value); - _renewExpiresUtc = currentUtc.Add(timeSpan); - } - } + CheckForRefresh(ticket); // Finally we have a valid ticket return AuthenticateResult.Success(ticket); @@ -116,7 +130,7 @@ namespace Microsoft.AspNet.Authentication.Cookies if (context.ShouldRenew) { - _shouldRenew = true; + RequestRefresh(result.Ticket); } return AuthenticateResult.Success(new AuthenticationTicket(context.Principal, context.Properties, Options.AuthenticationScheme)); @@ -144,7 +158,7 @@ namespace Microsoft.AspNet.Authentication.Cookies protected override async Task FinishResponseAsync() { // Only renew if requested, and neither sign in or sign out was called - if (!_shouldRenew || SignInAccepted || SignOutAccepted) + if (!_shouldRefresh || SignInAccepted || SignOutAccepted) { return; } @@ -153,13 +167,13 @@ namespace Microsoft.AspNet.Authentication.Cookies var ticket = (await HandleAuthenticateOnceAsync())?.Ticket; if (ticket != null) { - if (_renewIssuedUtc.HasValue) + if (_refreshIssuedUtc.HasValue) { - ticket.Properties.IssuedUtc = _renewIssuedUtc; + ticket.Properties.IssuedUtc = _refreshIssuedUtc; } - if (_renewExpiresUtc.HasValue) + if (_refreshExpiresUtc.HasValue) { - ticket.Properties.ExpiresUtc = _renewExpiresUtc; + ticket.Properties.ExpiresUtc = _refreshExpiresUtc; } if (Options.SessionStore != null && _sessionKey != null) @@ -175,9 +189,9 @@ namespace Microsoft.AspNet.Authentication.Cookies var cookieValue = Options.TicketDataFormat.Protect(ticket, GetTlsTokenBinding()); var cookieOptions = BuildCookieOptions(); - if (ticket.Properties.IsPersistent && _renewExpiresUtc.HasValue) + if (ticket.Properties.IsPersistent && _refreshExpiresUtc.HasValue) { - cookieOptions.Expires = _renewExpiresUtc.Value.ToUniversalTime().DateTime; + cookieOptions.Expires = _refreshExpiresUtc.Value.ToUniversalTime().DateTime; } Options.CookieManager.AppendResponseCookie( diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 329b0d176e..ffcf6d8792 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -580,6 +580,61 @@ namespace Microsoft.AspNet.Authentication.Cookies Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) + { + var clock = new TestClock(); + DateTimeOffset? lastValidateIssuedDate = null; + DateTimeOffset? lastExpiresDate = null; + var server = CreateServer(options => + { + options.SystemClock = clock; + options.ExpireTimeSpan = TimeSpan.FromMinutes(10); + options.SlidingExpiration = sliding; + options.Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = ctx => + { + lastValidateIssuedDate = ctx.Properties.IssuedUtc; + lastExpiresDate = ctx.Properties.ExpiresUtc; + ctx.ShouldRenew = true; + return Task.FromResult(0); + } + }; + }, + context => + context.Authentication.SignInAsync("Cookies", + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction2.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + + Assert.NotNull(lastValidateIssuedDate); + Assert.NotNull(lastExpiresDate); + + var firstIssueDate = lastValidateIssuedDate; + var firstExpiresDate = lastExpiresDate; + + clock.Add(TimeSpan.FromMinutes(1)); + + var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); + Assert.NotNull(transaction3.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); + + clock.Add(TimeSpan.FromMinutes(2)); + + var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction3.CookieNameValue); + Assert.NotNull(transaction4.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); + + Assert.NotEqual(lastValidateIssuedDate, firstIssueDate); + Assert.NotEqual(firstExpiresDate, lastExpiresDate); + } [Fact] public async Task CookieExpirationCanBeOverridenInEvent() From f4aafe04e09d4a51568f2d171712f5cafe1b2a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Mon, 4 Jan 2016 20:58:49 +0100 Subject: [PATCH 440/900] Replace Microsoft.Owin.Security.Cookies.Interop by Microsoft.Owin.Security.Interop --- Security.sln | 60 ++++----- .../DataHandler/TicketDataFormat.cs | 3 +- .../DataHandler/TicketSerializer.cs | 2 +- .../CookieAuthenticationExtensions.cs | 26 ---- .../DefaultCompatibilityConstants.cs | 22 ---- .../Properties/AssemblyInfo.cs | 8 -- .../project.json | 18 --- .../AspNetTicketDataFormat.cs | 4 +- .../AspNetTicketSerializer.cs | 4 +- .../DataProtectorShim.cs | 4 +- .../Microsoft.Owin.Security.Interop.xproj} | 11 +- .../Properties/AssemblyInfo.cs | 23 ++++ .../project.json | 15 +++ .../CookieInteropTests.cs} | 121 +++++------------- ...icrosoft.Owin.Security.Interop.Test.xproj} | 4 +- .../Properties/AssemblyInfo.cs | 23 ++++ .../TicketInteropTests.cs | 91 +++++++++++++ .../project.json | 5 +- 18 files changed, 232 insertions(+), 212 deletions(-) delete mode 100644 src/Microsoft.Owin.Security.Cookies.Interop/CookieAuthenticationExtensions.cs delete mode 100644 src/Microsoft.Owin.Security.Cookies.Interop/DefaultCompatibilityConstants.cs delete mode 100644 src/Microsoft.Owin.Security.Cookies.Interop/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.Owin.Security.Cookies.Interop/project.json rename src/{Microsoft.Owin.Security.Cookies.Interop => Microsoft.Owin.Security.Interop}/AspNetTicketDataFormat.cs (78%) rename src/{Microsoft.Owin.Security.Cookies.Interop => Microsoft.Owin.Security.Interop}/AspNetTicketSerializer.cs (98%) rename src/{Microsoft.Owin.Security.Cookies.Interop => Microsoft.Owin.Security.Interop}/DataProtectorShim.cs (84%) rename src/{Microsoft.Owin.Security.Cookies.Interop/Microsoft.Owin.Security.Cookies.Interop.xproj => Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj} (70%) create mode 100644 src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.Owin.Security.Interop/project.json rename test/{Microsoft.Owin.Security.Cookies.Interop.Test/TicketInteropTests.cs => Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs} (63%) rename test/{Microsoft.Owin.Security.Cookies.Interop.Test/Microsoft.Owin.Security.Cookies.Interop.Test.xproj => Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj} (87%) create mode 100644 test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs create mode 100644 test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs rename test/{Microsoft.Owin.Security.Cookies.Interop.Test => Microsoft.Owin.Security.Interop.Test}/project.json (78%) diff --git a/Security.sln b/Security.sln index 77ed552842..28ecb032ed 100644 --- a/Security.sln +++ b/Security.sln @@ -50,12 +50,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.CookiePoli 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}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Owin.Security.Cookies.Interop", "src\Microsoft.Owin.Security.Cookies.Interop\Microsoft.Owin.Security.Cookies.Interop.xproj", "{21A56E78-31DE-4868-9778-7E4DBE2A4E35}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Owin.Security.Cookies.Interop.Test", "test\Microsoft.Owin.Security.Cookies.Interop.Test\Microsoft.Owin.Security.Cookies.Interop.Test.xproj", "{73E8E654-A2AC-4848-95F3-EB55512F6C39}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JwtBearerSample", "samples\JwtBearerSample\JwtBearerSample.xproj", "{D399B84F-591B-4E98-92BA-B0F63E7B6957}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Owin.Security.Interop", "src\Microsoft.Owin.Security.Interop\Microsoft.Owin.Security.Interop.xproj", "{A7922DD8-09F1-43E4-938B-CC523EA08898}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Owin.Security.Interop.Test", "test\Microsoft.Owin.Security.Interop.Test\Microsoft.Owin.Security.Interop.Test.xproj", "{A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -276,30 +276,6 @@ Global {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|Mixed Platforms.Build.0 = Release|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|x86.ActiveCfg = Release|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|x86.Build.0 = Release|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Debug|Any CPU.Build.0 = Debug|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Debug|x86.ActiveCfg = Debug|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Debug|x86.Build.0 = Debug|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Release|Any CPU.ActiveCfg = Release|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Release|Any CPU.Build.0 = Release|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Release|x86.ActiveCfg = Release|Any CPU - {21A56E78-31DE-4868-9778-7E4DBE2A4E35}.Release|x86.Build.0 = Release|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Debug|x86.ActiveCfg = Debug|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Debug|x86.Build.0 = Debug|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Release|Any CPU.Build.0 = Release|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Release|x86.ActiveCfg = Release|Any CPU - {73E8E654-A2AC-4848-95F3-EB55512F6C39}.Release|x86.Build.0 = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|Any CPU.Build.0 = Debug|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -312,6 +288,30 @@ Global {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|Mixed Platforms.Build.0 = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.ActiveCfg = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -335,8 +335,8 @@ Global {86183DC3-02A8-4A68-8B60-71ECEC066E79} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {1790E052-646F-4529-B90E-6FEA95520D69} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {2755BFE5-7421-4A31-A644-F817DF5CAA98} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} - {21A56E78-31DE-4868-9778-7E4DBE2A4E35} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} - {73E8E654-A2AC-4848-95F3-EB55512F6C39} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {D399B84F-591B-4E98-92BA-B0F63E7B6957} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} + {A7922DD8-09F1-43E4-938B-CC523EA08898} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/TicketDataFormat.cs b/src/Microsoft.AspNet.Authentication/DataHandler/TicketDataFormat.cs index a252b138ca..63f97cc9e4 100644 --- a/src/Microsoft.AspNet.Authentication/DataHandler/TicketDataFormat.cs +++ b/src/Microsoft.AspNet.Authentication/DataHandler/TicketDataFormat.cs @@ -7,7 +7,8 @@ namespace Microsoft.AspNet.Authentication { public class TicketDataFormat : SecureDataFormat { - public TicketDataFormat(IDataProtector protector) : base(new TicketSerializer(), protector) + public TicketDataFormat(IDataProtector protector) + : base(TicketSerializer.Default, protector) { } } diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/TicketSerializer.cs b/src/Microsoft.AspNet.Authentication/DataHandler/TicketSerializer.cs index 8fae5f9235..36b2695923 100644 --- a/src/Microsoft.AspNet.Authentication/DataHandler/TicketSerializer.cs +++ b/src/Microsoft.AspNet.Authentication/DataHandler/TicketSerializer.cs @@ -8,7 +8,7 @@ using System.Security.Claims; namespace Microsoft.AspNet.Authentication { - // This MUST be kept in sync with Microsoft.Owin.Security.Cookies.AspNetTicketSerializer + // This MUST be kept in sync with Microsoft.Owin.Security.Interop.AspNetTicketSerializer public class TicketSerializer : IDataSerializer { private const string DefaultStringPlaceholder = "\0"; diff --git a/src/Microsoft.Owin.Security.Cookies.Interop/CookieAuthenticationExtensions.cs b/src/Microsoft.Owin.Security.Cookies.Interop/CookieAuthenticationExtensions.cs deleted file mode 100644 index 3bbe74aad6..0000000000 --- a/src/Microsoft.Owin.Security.Cookies.Interop/CookieAuthenticationExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNet.DataProtection; -using Microsoft.Owin.Security.Cookies; -using Microsoft.Owin.Security.Cookies.Interop; - -namespace Owin -{ - public static class CookieAuthenticationExtensions - { - public static IAppBuilder UseCookieAuthentication( - this IAppBuilder app, - CookieAuthenticationOptions options, - DataProtectionProvider dataProtectionProvider, - PipelineStage stage = PipelineStage.Authenticate) - { - var dataProtector = dataProtectionProvider.CreateProtector( - "Microsoft.AspNet.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type - options.AuthenticationType, "v2"); - options.TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)); - - return app.UseCookieAuthentication(options, stage); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Cookies.Interop/DefaultCompatibilityConstants.cs b/src/Microsoft.Owin.Security.Cookies.Interop/DefaultCompatibilityConstants.cs deleted file mode 100644 index b403033e32..0000000000 --- a/src/Microsoft.Owin.Security.Cookies.Interop/DefaultCompatibilityConstants.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Microsoft.AspNet.Identity -{ - /// - /// Helpful constants for working with the authentication cookie compatibility shim. - /// - public static class DefaultCompatibilityConstants - { - /// - /// The default authentication type for application authentication cookies. - /// - public const string ApplicationCookieAuthenticationType = "Microsoft.AspNet.Identity.Application.AuthType"; - - /// - /// The default cookie name for application authentication cookies. - /// Used by . - /// - public const string CookieName = ".AspNet.Microsoft.AspNet.Identity.Application"; - } -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Cookies.Interop/Properties/AssemblyInfo.cs b/src/Microsoft.Owin.Security.Cookies.Interop/Properties/AssemblyInfo.cs deleted file mode 100644 index b2437d9ad6..0000000000 --- a/src/Microsoft.Owin.Security.Cookies.Interop/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,8 +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.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Cookies.Interop/project.json b/src/Microsoft.Owin.Security.Cookies.Interop/project.json deleted file mode 100644 index 30053b01ee..0000000000 --- a/src/Microsoft.Owin.Security.Cookies.Interop/project.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" - }, - "description": "A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security.Cookies and Microsoft.AspNet.Authentication.Cookies.", - "dependencies": { - }, - "frameworks": { - "net451": { - "dependencies": { - "Microsoft.AspNet.DataProtection.Extensions": "1.0.0-*", - "Microsoft.Owin.Security.Cookies": "3.0.1" - } - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Cookies.Interop/AspNetTicketDataFormat.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs similarity index 78% rename from src/Microsoft.Owin.Security.Cookies.Interop/AspNetTicketDataFormat.cs rename to src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs index 48ded33091..f1a07c5bf7 100644 --- a/src/Microsoft.Owin.Security.Cookies.Interop/AspNetTicketDataFormat.cs +++ b/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs @@ -5,12 +5,12 @@ using Microsoft.Owin.Security.DataHandler; using Microsoft.Owin.Security.DataHandler.Encoder; using Microsoft.Owin.Security.DataProtection; -namespace Microsoft.Owin.Security.Cookies.Interop +namespace Microsoft.Owin.Security.Interop { public class AspNetTicketDataFormat : SecureDataFormat { public AspNetTicketDataFormat(IDataProtector protector) - : base(new AspNetTicketSerializer(), protector, TextEncodings.Base64Url) + : base(AspNetTicketSerializer.Default, protector, TextEncodings.Base64Url) { } } diff --git a/src/Microsoft.Owin.Security.Cookies.Interop/AspNetTicketSerializer.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs similarity index 98% rename from src/Microsoft.Owin.Security.Cookies.Interop/AspNetTicketSerializer.cs rename to src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs index 8727f7c46b..2bfc44fde9 100644 --- a/src/Microsoft.Owin.Security.Cookies.Interop/AspNetTicketSerializer.cs +++ b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Security.Claims; using Microsoft.Owin.Security.DataHandler.Serializer; -namespace Microsoft.Owin.Security.Cookies.Interop +namespace Microsoft.Owin.Security.Interop { // This MUST be kept in sync with Microsoft.AspNet.Authentication.DataHandler.TicketSerializer public class AspNetTicketSerializer : IDataSerializer @@ -15,7 +15,7 @@ namespace Microsoft.Owin.Security.Cookies.Interop private const string DefaultStringPlaceholder = "\0"; private const int FormatVersion = 5; - public static TicketSerializer Default { get; } = new TicketSerializer(); + public static AspNetTicketSerializer Default { get; } = new AspNetTicketSerializer(); public virtual byte[] Serialize(AuthenticationTicket ticket) { diff --git a/src/Microsoft.Owin.Security.Cookies.Interop/DataProtectorShim.cs b/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs similarity index 84% rename from src/Microsoft.Owin.Security.Cookies.Interop/DataProtectorShim.cs rename to src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs index 0dab249aea..9dc7eedda9 100644 --- a/src/Microsoft.Owin.Security.Cookies.Interop/DataProtectorShim.cs +++ b/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs @@ -3,13 +3,13 @@ using Microsoft.AspNet.DataProtection; -namespace Microsoft.Owin.Security.Cookies.Interop +namespace Microsoft.Owin.Security.Interop { /// /// Converts an to an /// . /// - internal sealed class DataProtectorShim : Microsoft.Owin.Security.DataProtection.IDataProtector + public sealed class DataProtectorShim : Microsoft.Owin.Security.DataProtection.IDataProtector { private readonly IDataProtector _protector; diff --git a/src/Microsoft.Owin.Security.Cookies.Interop/Microsoft.Owin.Security.Cookies.Interop.xproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj similarity index 70% rename from src/Microsoft.Owin.Security.Cookies.Interop/Microsoft.Owin.Security.Cookies.Interop.xproj rename to src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj index fd666b061d..bb58ad7121 100644 --- a/src/Microsoft.Owin.Security.Cookies.Interop/Microsoft.Owin.Security.Cookies.Interop.xproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj @@ -4,16 +4,17 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + - 21a56e78-31de-4868-9778-7e4dbe2a4e35 - Microsoft.Owin.Security.Cookies.Shareable - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + a7922dd8-09f1-43e4-938b-cc523ea08898 + Microsoft.Owin.Security.Interop + ..\artifacts\obj\$(MSBuildProjectName) + ..\artifacts\bin\$(MSBuildProjectName)\ 2.0 - \ No newline at end of file + diff --git a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..4f0007e9c6 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs @@ -0,0 +1,23 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Microsoft.Owin.Security.Interop")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Microsoft.Owin.Security.Interop")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a7922dd8-09f1-43e4-938b-cc523ea08898")] diff --git a/src/Microsoft.Owin.Security.Interop/project.json b/src/Microsoft.Owin.Security.Interop/project.json new file mode 100644 index 0000000000..b3c352a874 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/project.json @@ -0,0 +1,15 @@ +{ + "version": "1.0.0-*", + "compilationOptions": { + "warningsAsErrors": true, + "keyFile": "../../tools/Key.snk" + }, + "description": "A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNet.Authentication.", + "dependencies": { + "Microsoft.AspNet.DataProtection.Extensions": "1.0.0-*", + "Microsoft.Owin.Security": "3.0.1" + }, + "frameworks": { + "net451": { } + } +} \ No newline at end of file diff --git a/test/Microsoft.Owin.Security.Cookies.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs similarity index 63% rename from test/Microsoft.Owin.Security.Cookies.Interop.Test/TicketInteropTests.cs rename to test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index 71acba5978..9ef81bc7f5 100644 --- a/test/Microsoft.Owin.Security.Cookies.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -1,117 +1,48 @@ -// 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. -using System; using System.IO; using System.Linq; using System.Net.Http; -using Microsoft.AspNet.Http; using System.Security.Claims; using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; -using Microsoft.AspNet.Authentication; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Hosting; +using Microsoft.AspNet.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Owin; using Microsoft.Owin.Security.Cookies; -using Microsoft.Owin.Security.Cookies.Interop; using Microsoft.Owin.Testing; using Owin; using Xunit; -namespace Microsoft.AspNet.CookiePolicy.Test +namespace Microsoft.Owin.Security.Interop { - public class TicketInteropTests + public class CookiesInteropTests { - [Fact] - public void NewSerializerCanReadInteropTicket() - { - var identity = new ClaimsIdentity("scheme"); - identity.AddClaim(new Claim("Test", "Value")); - - var expires = DateTime.Today; - var issued = new DateTime(1979, 11, 11); - var properties = new Owin.Security.AuthenticationProperties(); - properties.IsPersistent = true; - properties.RedirectUri = "/redirect"; - properties.Dictionary["key"] = "value"; - properties.ExpiresUtc = expires; - properties.IssuedUtc = issued; - - var interopTicket = new Owin.Security.AuthenticationTicket(identity, properties); - var interopSerializer = new AspNetTicketSerializer(); - - var bytes = interopSerializer.Serialize(interopTicket); - - var newSerializer = new TicketSerializer(); - var newTicket = newSerializer.Deserialize(bytes); - - Assert.NotNull(newTicket); - Assert.Equal(1, newTicket.Principal.Identities.Count()); - var newIdentity = newTicket.Principal.Identity as ClaimsIdentity; - Assert.NotNull(newIdentity); - Assert.Equal("scheme", newIdentity.AuthenticationType); - Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); - Assert.NotNull(newTicket.Properties); - Assert.True(newTicket.Properties.IsPersistent); - Assert.Equal("/redirect", newTicket.Properties.RedirectUri); - Assert.Equal("value", newTicket.Properties.Items["key"]); - Assert.Equal(expires, newTicket.Properties.ExpiresUtc); - Assert.Equal(issued, newTicket.Properties.IssuedUtc); - } - - [Fact] - public void InteropSerializerCanReadNewTicket() - { - var user = new ClaimsPrincipal(); - var identity = new ClaimsIdentity("scheme"); - identity.AddClaim(new Claim("Test", "Value")); - user.AddIdentity(identity); - - var expires = DateTime.Today; - var issued = new DateTime(1979, 11, 11); - var properties = new Http.Authentication.AuthenticationProperties(); - properties.IsPersistent = true; - properties.RedirectUri = "/redirect"; - properties.Items["key"] = "value"; - properties.ExpiresUtc = expires; - properties.IssuedUtc = issued; - - var newTicket = new AuthenticationTicket(user, properties, "scheme"); - var newSerializer = new TicketSerializer(); - - var bytes = newSerializer.Serialize(newTicket); - - var interopSerializer = new AspNetTicketSerializer(); - var interopTicket = interopSerializer.Deserialize(bytes); - - Assert.NotNull(interopTicket); - var newIdentity = interopTicket.Identity; - Assert.NotNull(newIdentity); - Assert.Equal("scheme", newIdentity.AuthenticationType); - Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); - Assert.NotNull(interopTicket.Properties); - Assert.True(interopTicket.Properties.IsPersistent); - Assert.Equal("/redirect", interopTicket.Properties.RedirectUri); - Assert.Equal("value", interopTicket.Properties.Dictionary["key"]); - Assert.Equal(expires, interopTicket.Properties.ExpiresUtc); - Assert.Equal(issued, interopTicket.Properties.IssuedUtc); - } - [Fact] public async Task AspNet5WithInteropCookieContainsIdentity() { var identity = new ClaimsIdentity("Cookies"); identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); - var dataProtection = new DataProtection.DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); + var dataProtection = new DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNet.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type + CookieAuthenticationDefaults.AuthenticationType, "v2"); + var interopServer = TestServer.Create(app => { app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - app.UseCookieAuthentication(new CookieAuthenticationOptions(), dataProtection); + + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)) + }); + app.Run(context => { context.Authentication.SignIn(identity); @@ -132,7 +63,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test }); }) .ConfigureServices(services => services.AddAuthentication()); - var newServer = new TestHost.TestServer(builder); + var newServer = new AspNet.TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); request.Headers.Add("Cookie", transaction.SetCookie.Split(new[] { ';' }, 2).First()); @@ -149,7 +80,11 @@ namespace Microsoft.AspNet.CookiePolicy.Test identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); user.AddIdentity(identity); - var dataProtection = new DataProtection.DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); + var dataProtection = new DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNet.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type + CookieAuthenticationDefaults.AuthenticationType, "v2"); + var builder = new WebApplicationBuilder() .Configure(app => { @@ -157,14 +92,19 @@ namespace Microsoft.AspNet.CookiePolicy.Test app.Run(context => context.Authentication.SignInAsync("Cookies", user)); }) .ConfigureServices(services => services.AddAuthentication()); - var newServer = new TestHost.TestServer(builder); + var newServer = new AspNet.TestHost.TestServer(builder); var cookie = await SendAndGetCookie(newServer, "http://example.com/login"); var server = TestServer.Create(app => { app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - app.UseCookieAuthentication(new CookieAuthenticationOptions(), dataProtection); + + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)) + }); + app.Run(async context => { var result = await context.Authentication.AuthenticateAsync("Cookies"); @@ -177,7 +117,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); } - private static async Task SendAndGetCookie(TestHost.TestServer server, string uri) + private static async Task SendAndGetCookie(AspNet.TestHost.TestServer server, string uri) { var request = new HttpRequestMessage(HttpMethod.Get, uri); var response = await server.CreateClient().SendAsync(request); @@ -271,4 +211,3 @@ namespace Microsoft.AspNet.CookiePolicy.Test } } - diff --git a/test/Microsoft.Owin.Security.Cookies.Interop.Test/Microsoft.Owin.Security.Cookies.Interop.Test.xproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj similarity index 87% rename from test/Microsoft.Owin.Security.Cookies.Interop.Test/Microsoft.Owin.Security.Cookies.Interop.Test.xproj rename to test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj index 3341cf4e6e..c3f5e576de 100644 --- a/test/Microsoft.Owin.Security.Cookies.Interop.Test/Microsoft.Owin.Security.Cookies.Interop.Test.xproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj @@ -6,8 +6,8 @@ - 73e8e654-a2ac-4848-95f3-eb55512f6c39 - Microsoft.Owin.Security.Cookies.Interop.Test + a2b5dc39-68d5-4145-a8cc-6aeab7d33a24 + Microsoft.Owin.Security.Interop.Test ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ diff --git a/test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs b/test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..10b3c4ae5f --- /dev/null +++ b/test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,23 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Microsoft.Owin.Security.Interop.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Microsoft.Owin.Security.Interop.Test")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a2b5dc39-68d5-4145-a8cc-6aeab7d33a24")] diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs new file mode 100644 index 0000000000..7810805523 --- /dev/null +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -0,0 +1,91 @@ +// 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.Linq; +using System.Security.Claims; +using Microsoft.AspNet.Authentication; +using Xunit; + +namespace Microsoft.Owin.Security.Interop.Test +{ + public class TicketInteropTests + { + [Fact] + public void NewSerializerCanReadInteropTicket() + { + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim("Test", "Value")); + + var expires = DateTime.Today; + var issued = new DateTime(1979, 11, 11); + var properties = new Owin.Security.AuthenticationProperties(); + properties.IsPersistent = true; + properties.RedirectUri = "/redirect"; + properties.Dictionary["key"] = "value"; + properties.ExpiresUtc = expires; + properties.IssuedUtc = issued; + + var interopTicket = new Owin.Security.AuthenticationTicket(identity, properties); + var interopSerializer = new AspNetTicketSerializer(); + + var bytes = interopSerializer.Serialize(interopTicket); + + var newSerializer = new TicketSerializer(); + var newTicket = newSerializer.Deserialize(bytes); + + Assert.NotNull(newTicket); + Assert.Equal(1, newTicket.Principal.Identities.Count()); + var newIdentity = newTicket.Principal.Identity as ClaimsIdentity; + Assert.NotNull(newIdentity); + Assert.Equal("scheme", newIdentity.AuthenticationType); + Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); + Assert.NotNull(newTicket.Properties); + Assert.True(newTicket.Properties.IsPersistent); + Assert.Equal("/redirect", newTicket.Properties.RedirectUri); + Assert.Equal("value", newTicket.Properties.Items["key"]); + Assert.Equal(expires, newTicket.Properties.ExpiresUtc); + Assert.Equal(issued, newTicket.Properties.IssuedUtc); + } + + [Fact] + public void InteropSerializerCanReadNewTicket() + { + var user = new ClaimsPrincipal(); + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim("Test", "Value")); + user.AddIdentity(identity); + + var expires = DateTime.Today; + var issued = new DateTime(1979, 11, 11); + var properties = new AspNet.Http.Authentication.AuthenticationProperties(); + properties.IsPersistent = true; + properties.RedirectUri = "/redirect"; + properties.Items["key"] = "value"; + properties.ExpiresUtc = expires; + properties.IssuedUtc = issued; + + var newTicket = new AspNet.Authentication.AuthenticationTicket(user, properties, "scheme"); + var newSerializer = new TicketSerializer(); + + var bytes = newSerializer.Serialize(newTicket); + + var interopSerializer = new AspNetTicketSerializer(); + var interopTicket = interopSerializer.Deserialize(bytes); + + Assert.NotNull(interopTicket); + var newIdentity = interopTicket.Identity; + Assert.NotNull(newIdentity); + Assert.Equal("scheme", newIdentity.AuthenticationType); + Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); + Assert.NotNull(interopTicket.Properties); + Assert.True(interopTicket.Properties.IsPersistent); + Assert.Equal("/redirect", interopTicket.Properties.RedirectUri); + Assert.Equal("value", interopTicket.Properties.Dictionary["key"]); + Assert.Equal(expires, interopTicket.Properties.ExpiresUtc); + Assert.Equal(issued, interopTicket.Properties.IssuedUtc); + } + } +} + + diff --git a/test/Microsoft.Owin.Security.Cookies.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json similarity index 78% rename from test/Microsoft.Owin.Security.Cookies.Interop.Test/project.json rename to test/Microsoft.Owin.Security.Interop.Test/project.json index c206ad20eb..585c87aa16 100644 --- a/test/Microsoft.Owin.Security.Cookies.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -1,11 +1,12 @@ -{ +{ "compilationOptions": { "warningsAsErrors": true }, "dependencies": { "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNet.TestHost": "1.0.0-*", - "Microsoft.Owin.Security.Cookies.Interop": "1.0.0-*", + "Microsoft.Owin.Security.Cookies": "3.0.1", + "Microsoft.Owin.Security.Interop": "1.0.0-*", "Microsoft.Owin.Testing": "3.0.1", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, From 139070df59b53014f81120c11e1caadb5850c0db Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 8 Jan 2016 14:25:50 -0800 Subject: [PATCH 441/900] Fix AssemblyInfo for Security.Interop. --- .../Properties/AssemblyInfo.cs | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs b/test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs index 10b3c4ae5f..0675f8c9a1 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs @@ -1,23 +1,12 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +// 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.Reflection; +using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Microsoft.Owin.Security.Interop.Test")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.Owin.Security.Interop.Test")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] +[assembly: AssemblyMetadata("Serviceable", "True")] +[assembly: NeutralResourcesLanguage("en-us")] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("a2b5dc39-68d5-4145-a8cc-6aeab7d33a24")] From 990e412326fd68e7add4e7909a43e27444e12ad4 Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 8 Jan 2016 14:47:40 -0800 Subject: [PATCH 442/900] Actually fix the AssemblyInfo --- .../Properties/AssemblyInfo.cs | 25 ++++++------------- .../Properties/AssemblyInfo.cs | 12 --------- 2 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs index 4f0007e9c6..c0526726a4 100644 --- a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs +++ b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs @@ -1,23 +1,12 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +// 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.Reflection; +using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Microsoft.Owin.Security.Interop")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.Owin.Security.Interop")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] +[assembly: AssemblyMetadata("Serviceable", "True")] +[assembly: NeutralResourcesLanguage("en-us")] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("a7922dd8-09f1-43e4-938b-cc523ea08898")] diff --git a/test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs b/test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index 0675f8c9a1..0000000000 --- a/test/Microsoft.Owin.Security.Interop.Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,12 +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.Reflection; -using System.Resources; -using System.Runtime.InteropServices; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a2b5dc39-68d5-4145-a8cc-6aeab7d33a24")] From 417ca6cbe3ddf914b37b0a6b5c16a9d2e48215be Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 6 Jan 2016 13:58:30 -0800 Subject: [PATCH 443/900] Updating to new options pattern --- samples/CookieSample/Startup.cs | 4 +- samples/CookieSessionSample/Startup.cs | 6 +- samples/JwtBearerSample/Startup.cs | 10 +- samples/OpenIdConnectSample/Startup.cs | 16 +- samples/SocialSample/Startup.cs | 134 ++++---- .../CookieAppBuilderExtensions.cs | 30 +- .../CookieAuthenticationHandler.cs | 1 + .../CookieAuthenticationMiddleware.cs | 24 +- .../CookieAuthenticationOptions.cs | 4 +- .../Events/BaseCookieContext.cs | 3 +- .../Events/CookieRedirectContext.cs | 1 + .../Events/CookieSignedInContext.cs | 1 + .../Events/CookieSigningInContext.cs | 1 + .../Events/CookieSigningOutContext.cs | 1 + .../Events/CookieValidatePrincipalContext.cs | 1 + .../project.json | 1 + .../FacebookAppBuilderExtensions.cs | 15 +- .../FacebookHandler.cs | 1 + .../FacebookMiddleware.cs | 3 +- .../FacebookOptions.cs | 4 +- .../GoogleAppBuilderExtensions.cs | 15 +- .../GoogleHandler.cs | 3 +- .../GoogleMiddleware.cs | 3 +- .../GoogleOptions.cs | 4 +- .../Events/AuthenticationFailedContext.cs | 1 + .../Events/BaseJwtBearerContext.cs | 1 + .../Events/JwtBearerChallengeContext.cs | 1 + .../Events/ReceivedTokenContext.cs | 1 + .../Events/ReceivingTokenContext.cs | 1 + .../Events/TokenValidatedContext.cs | 1 + .../JwtBearerAppBuilderExtensions.cs | 15 +- .../JwtBearerHandler.cs | 1 + .../JwtBearerMiddleware.cs | 4 +- .../JwtBearerOptions.cs | 4 +- .../MicrosoftAccountAppBuilderExtensions.cs | 15 +- .../MicrosoftAccountHandler.cs | 1 + .../MicrosoftAccountMiddleware.cs | 3 +- .../MicrosoftAccountOptions.cs | 4 +- .../Events/OAuthCreatingTicketContext.cs | 2 +- .../OAuthRedirectToAuthorizationContext.cs | 1 + .../OAuthAppBuilderExtensions.cs | 15 +- .../OAuthHandler.cs | 1 + .../OAuthMiddleware.cs | 3 +- .../OAuthOptions.cs | 4 +- .../Events/AuthenticationFailedContext.cs | 2 +- .../Events/AuthenticationValidatedContext.cs | 1 + .../AuthorizationCodeReceivedContext.cs | 1 + .../AuthorizationResponseReceivedContext.cs | 2 +- .../Events/BaseOpenIdConnectContext.cs | 1 + .../Events/MessageReceivedContext.cs | 2 +- .../Events/RedirectContext.cs | 2 +- .../Events/TokenResponseReceivedContext.cs | 6 +- .../Events/UserInformationReceivedContext.cs | 2 +- .../OpenIdConnectAppBuilderExtensions.cs | 15 +- .../OpenIdConnectHandler.cs | 1 + .../OpenIdConnectMiddleware.cs | 3 +- .../OpenIdConnectOptions.cs | 4 +- .../Events/BaseTwitterContext.cs | 1 + .../Events/TwitterCreatingTicketContext.cs | 1 + ...rRedirectToAuthorizationEndpointContext.cs | 1 + .../TwitterAppBuilderExtensions.cs | 15 +- .../TwitterHandler.cs | 1 + .../TwitterMiddleware.cs | 3 +- .../TwitterOptions.cs | 5 +- .../AuthenticationHandler.cs | 1 + .../AuthenticationMiddleware.cs | 6 +- .../AuthenticationOptions.cs | 2 +- ...laimsTransformationAppBuilderExtensions.cs | 47 ++- .../ClaimsTransformationMiddleware.cs | 6 +- .../ClaimsTransformationOptions.cs | 4 +- .../Events/TicketReceivedContext.cs | 1 + .../RemoteAuthenticationHandler.cs | 1 + .../RemoteAuthenticationOptions.cs | 4 +- ...uthorizationServiceCollectionExtensions.cs | 3 +- .../CookiePolicyAppBuilderExtensions.cs | 15 +- .../CookiePolicyMiddleware.cs | 7 +- .../CookiePolicyOptions.cs | 3 +- .../project.json | 3 +- .../AuthenticationHandlerFacts.cs | 1 + .../Cookies/CookieMiddlewareTests.cs | 311 ++++++++++-------- .../Facebook/FacebookMiddlewareTests.cs | 57 ++-- .../Google/GoogleMiddlewareTests.cs | 265 +++++++-------- .../JwtBearer/JwtBearerMiddlewareTests.cs | 160 +++++---- .../MicrosoftAccountMiddlewareTests.cs | 72 ++-- .../OpenIdConnectHandlerTests.cs | 23 +- ...ConnectMiddlewareForTestingAuthenticate.cs | 3 +- .../OpenIdConnectMiddlewareTests.cs | 128 ++++--- .../Twitter/TwitterMiddlewareTests.cs | 62 ++-- .../DefaultAuthorizationServiceTests.cs | 1 + .../CookiePolicyTests.cs | 44 ++- .../CookieInteropTests.cs | 14 +- 91 files changed, 838 insertions(+), 840 deletions(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index dca9105128..b3327ac81c 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -20,9 +20,9 @@ namespace CookieSample { loggerfactory.AddConsole(LogLevel.Information); - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.AutomaticAuthenticate = true; + AutomaticAuthenticate = true }); app.Run(async context => diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index bf7200ca6a..6160f56b95 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -21,10 +21,10 @@ namespace CookieSessionSample { loggerfactory.AddConsole(LogLevel.Information); - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.AutomaticAuthenticate = true; - options.SessionStore = new MemoryCacheTicketStore(); + AutomaticAuthenticate = true, + SessionStore = new MemoryCacheTicketStore() }); app.Run(async context => diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 88032b8e69..db91629bcf 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -59,13 +59,13 @@ namespace JwtBearerSample app.UseDefaultFiles(); app.UseStaticFiles(); - app.UseJwtBearerAuthentication(options => + app.UseJwtBearerAuthentication(new JwtBearerOptions { - options.AutomaticAuthenticate = true; - options.AutomaticChallenge = true; + AutomaticAuthenticate = true, + AutomaticChallenge = true, // You also need to update /wwwroot/app/scripts/app.js - options.Authority = Configuration["jwt:authority"]; - options.Audience = Configuration["jwt:audience"]; + Authority = Configuration["jwt:authority"], + Audience = Configuration["jwt:audience"] }); // [Authorize] would usually handle this diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 67a979ea91..bf4a4bc759 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -35,18 +35,18 @@ namespace OpenIdConnectSample app.UseIISPlatformHandler(); - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.AutomaticAuthenticate = true; + AutomaticAuthenticate = true }); - app.UseOpenIdConnectAuthentication(options => + app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions { - options.ClientId = Configuration["oidc:clientid"]; - options.ClientSecret = Configuration["oidc:clientsecret"]; // for code flow - options.Authority = Configuration["oidc:authority"]; - options.ResponseType = OpenIdConnectResponseTypes.Code; - options.GetClaimsFromUserInfoEndpoint = true; + ClientId = Configuration["oidc:clientid"], + ClientSecret = Configuration["oidc:clientsecret"], // for code flow + Authority = Configuration["oidc:authority"], + ResponseType = OpenIdConnectResponseTypes.Code, + GetClaimsFromUserInfoEndpoint = true }); app.Run(async context => diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index f1bc5b335f..65067ada8e 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -63,47 +63,44 @@ namespace CookieSample } }); - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.AutomaticAuthenticate = true; - options.AutomaticChallenge = true; - options.LoginPath = new PathString("/login"); + AutomaticAuthenticate = true, + AutomaticChallenge = true, + LoginPath = new PathString("/login") }); // You must first create an app with facebook and add it's ID and Secret to your config.json or user-secrets. // https://developers.facebook.com/apps/ - app.UseFacebookAuthentication(options => + app.UseFacebookAuthentication(new FacebookOptions { - options.AppId = Configuration["facebook:appid"]; - options.AppSecret = Configuration["facebook:appsecret"]; - options.Scope.Add("email"); - options.Fields.Add("name"); - options.Fields.Add("email"); + AppId = Configuration["facebook:appid"], + AppSecret = Configuration["facebook:appsecret"], + Scope = { "email" }, + Fields = { "name", "email" } }); // See config.json - app.UseOAuthAuthentication(options => + app.UseOAuthAuthentication(new OAuthOptions { - options.AuthenticationScheme = "Google-AccessToken"; - options.DisplayName = "Google-AccessToken"; - options.ClientId = Configuration["google:clientid"]; - options.ClientSecret = Configuration["google:clientsecret"]; - options.CallbackPath = new PathString("/signin-google-token"); - options.AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint; - options.TokenEndpoint = GoogleDefaults.TokenEndpoint; - options.Scope.Add("openid"); - options.Scope.Add("profile"); - options.Scope.Add("email"); - options.SaveTokensAsClaims = true; + AuthenticationScheme = "Google-AccessToken", + DisplayName = "Google-AccessToken", + ClientId = Configuration["google:clientid"], + ClientSecret = Configuration["google:clientsecret"], + CallbackPath = new PathString("/signin-google-token"), + AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint, + TokenEndpoint = GoogleDefaults.TokenEndpoint, + Scope = { "openid", "profile", "email" }, + SaveTokensAsClaims = true }); // See config.json // https://console.developers.google.com/project - app.UseGoogleAuthentication(options => + app.UseGoogleAuthentication(new GoogleOptions { - options.ClientId = Configuration["google:clientid"]; - options.ClientSecret = Configuration["google:clientsecret"]; - options.Events = new OAuthEvents() + ClientId = Configuration["google:clientid"], + ClientSecret = Configuration["google:clientsecret"], + Events = new OAuthEvents() { OnRemoteFailure = ctx => @@ -112,17 +109,16 @@ namespace CookieSample ctx.HandleResponse(); return Task.FromResult(0); } - }; - + } }); // See config.json // https://apps.twitter.com/ - app.UseTwitterAuthentication(options => + app.UseTwitterAuthentication(new TwitterOptions { - options.ConsumerKey = Configuration["twitter:consumerkey"]; - options.ConsumerSecret = Configuration["twitter:consumersecret"]; - options.Events = new TwitterEvents() + ConsumerKey = Configuration["twitter:consumerkey"], + ConsumerSecret = Configuration["twitter:consumersecret"], + Events = new TwitterEvents() { OnRemoteFailure = ctx => { @@ -130,7 +126,7 @@ namespace CookieSample ctx.HandleResponse(); return Task.FromResult(0); } - }; + } }); // You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. @@ -151,56 +147,56 @@ namespace CookieSample The sample app can then be run via: dnx . web */ - app.UseOAuthAuthentication(options => + app.UseOAuthAuthentication(new OAuthOptions { - options.AuthenticationScheme = "Microsoft-AccessToken"; - options.DisplayName = "MicrosoftAccount-AccessToken - Requires project changes"; - options.ClientId = Configuration["msa:clientid"]; - options.ClientSecret = Configuration["msa:clientsecret"]; - options.CallbackPath = new PathString("/signin-microsoft-token"); - options.AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint; - options.TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; - options.Scope.Add("wl.basic"); - options.SaveTokensAsClaims = true; + AuthenticationScheme = "Microsoft-AccessToken", + DisplayName = "MicrosoftAccount-AccessToken - Requires project changes", + ClientId = Configuration["msa:clientid"], + ClientSecret = Configuration["msa:clientsecret"], + CallbackPath = new PathString("/signin-microsoft-token"), + AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint, + TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint, + Scope = { "wl.basic" }, + SaveTokensAsClaims = true }); //// You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. - app.UseMicrosoftAccountAuthentication(options => + app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions { - options.DisplayName = "MicrosoftAccount - Requires project changes"; - options.ClientId = Configuration["msa:clientid"]; - options.ClientSecret = Configuration["msa:clientsecret"]; - options.Scope.Add("wl.emails"); + DisplayName = "MicrosoftAccount - Requires project changes", + ClientId = Configuration["msa:clientid"], + ClientSecret = Configuration["msa:clientsecret"], + Scope = { "wl.emails" } }); // See config.json // https://github.com/settings/applications/ - app.UseOAuthAuthentication(options => + app.UseOAuthAuthentication(new OAuthOptions { - options.AuthenticationScheme = "GitHub-AccessToken"; - options.DisplayName = "Github-AccessToken"; - options.ClientId = Configuration["github-token:clientid"]; - options.ClientSecret = Configuration["github-token:clientsecret"]; - options.CallbackPath = new PathString("/signin-github-token"); - options.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; - options.TokenEndpoint = "https://github.com/login/oauth/access_token"; - options.SaveTokensAsClaims = true; + AuthenticationScheme = "GitHub-AccessToken", + DisplayName = "Github-AccessToken", + ClientId = Configuration["github-token:clientid"], + ClientSecret = Configuration["github-token:clientsecret"], + CallbackPath = new PathString("/signin-github-token"), + AuthorizationEndpoint = "https://github.com/login/oauth/authorize", + TokenEndpoint = "https://github.com/login/oauth/access_token", + SaveTokensAsClaims = true }); // See config.json - app.UseOAuthAuthentication(options => + app.UseOAuthAuthentication(new OAuthOptions { - options.AuthenticationScheme = "GitHub"; - options.DisplayName = "Github"; - options.ClientId = Configuration["github:clientid"]; - options.ClientSecret = Configuration["github:clientsecret"]; - options.CallbackPath = new PathString("/signin-github"); - options.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; - options.TokenEndpoint = "https://github.com/login/oauth/access_token"; - options.UserInformationEndpoint = "https://api.github.com/user"; - options.ClaimsIssuer = "OAuth2-Github"; + AuthenticationScheme = "GitHub", + DisplayName = "Github", + ClientId = Configuration["github:clientid"], + ClientSecret = Configuration["github:clientsecret"], + CallbackPath = new PathString("/signin-github"), + AuthorizationEndpoint = "https://github.com/login/oauth/authorize", + TokenEndpoint = "https://github.com/login/oauth/access_token", + UserInformationEndpoint = "https://api.github.com/user", + ClaimsIssuer = "OAuth2-Github", // Retrieving user information is unique to each provider. - options.Events = new OAuthEvents + Events = new OAuthEvents { OnCreatingTicket = async context => { @@ -246,7 +242,7 @@ namespace CookieSample ClaimValueTypes.String, context.Options.ClaimsIssuer)); } } - }; + } }); // Choose an authentication type diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs index f990df58aa..8582648877 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Authentication.Cookies; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -22,31 +23,8 @@ namespace Microsoft.AspNet.Builder { throw new ArgumentNullException(nameof(app)); } - - return app.UseCookieAuthentication(options => { }); - } - - /// - /// Adds the middleware to the specified , which enables cookie authentication capabilities. - /// - /// The to add the middleware to. - /// An action delegate to configure the provided . - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuilder app, Action configureOptions) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - - var options = new CookieAuthenticationOptions(); - configureOptions(options); - - return app.UseMiddleware(options); + + return app.UseMiddleware(); } /// @@ -66,7 +44,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware(options); + return app.UseMiddleware(Options.Create(options)); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs index 82a47ecaeb..040539d4d9 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -6,6 +6,7 @@ using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features; diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationMiddleware.cs index 9ec4064843..c15b10d345 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationMiddleware.cs @@ -3,9 +3,11 @@ using System; using System.Text.Encodings.Web; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authentication.Cookies { @@ -16,34 +18,14 @@ namespace Microsoft.AspNet.Authentication.Cookies IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, UrlEncoder urlEncoder, - CookieAuthenticationOptions options) + IOptions options) : base(next, options, loggerFactory, urlEncoder) { - if (next == null) - { - throw new ArgumentNullException(nameof(next)); - } - if (dataProtectionProvider == null) { throw new ArgumentNullException(nameof(dataProtectionProvider)); } - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - if (urlEncoder == null) - { - throw new ArgumentNullException(nameof(urlEncoder)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - if (Options.Events == null) { Options.Events = new CookieAuthenticationEvents(); diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs index 830b559c96..075353887f 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -4,11 +4,13 @@ using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; +using Microsoft.AspNet.Authentication; +using Microsoft.AspNet.Authentication.Cookies; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNet.Builder { /// /// Contains the options used by the CookiesAuthenticationMiddleware diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/BaseCookieContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/BaseCookieContext.cs index 6a437551fe..d3e9127eed 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/BaseCookieContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/BaseCookieContext.cs @@ -2,9 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Security.Claims; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; namespace Microsoft.AspNet.Authentication.Cookies { diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieRedirectContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieRedirectContext.cs index 437e8927e1..4f0266b855 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieRedirectContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieRedirectContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Diagnostics.CodeAnalysis; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs index 17f5090cda..2412722c08 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs index fa441b4b0e..709549d0aa 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs index a510dbcb59..2de962ef4e 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.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 Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs index af06533855..435499bf57 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs @@ -3,6 +3,7 @@ using System; using System.Security.Claims; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.Cookies/project.json b/src/Microsoft.AspNet.Authentication.Cookies/project.json index b9b1d5d308..8a6fdac7be 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNet.Authentication.Cookies/project.json @@ -11,6 +11,7 @@ }, "dependencies": { "Microsoft.AspNet.Authentication": "1.0.0-*", + "Microsoft.Extensions.Options": "1.0.0-*", "Microsoft.Extensions.WebEncoders": "1.0.0-*", "Newtonsoft.Json": "6.0.6" }, diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs index f649790a1a..19ff8fa67e 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Authentication.Facebook; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -15,23 +16,15 @@ namespace Microsoft.AspNet.Builder /// Adds the middleware to the specified , which enables Facebook authentication capabilities. /// /// The to add the middleware to. - /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app, Action configureOptions) + public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app) { if (app == null) { throw new ArgumentNullException(nameof(app)); } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - var options = new FacebookOptions(); - configureOptions(options); - - return app.UseMiddleware(options); + return app.UseMiddleware(); } /// @@ -51,7 +44,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware(options); + return app.UseMiddleware(Options.Create(options)); } } } diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs index 44bc1468ee..7c74b253f3 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs @@ -8,6 +8,7 @@ using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Authentication.OAuth; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.WebUtilities; using Newtonsoft.Json.Linq; diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs index 441145681d..f6d04171a9 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs @@ -5,6 +5,7 @@ using System; using System.Globalization; using System.Text.Encodings.Web; using Microsoft.AspNet.Authentication.OAuth; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; @@ -33,7 +34,7 @@ namespace Microsoft.AspNet.Authentication.Facebook ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions sharedOptions, - FacebookOptions options) + IOptions options) : base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options) { if (next == null) diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs index b6ceb5f0f0..25e02cf778 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; -using Microsoft.AspNet.Authentication.OAuth; +using Microsoft.AspNet.Authentication.Facebook; using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Authentication.Facebook +namespace Microsoft.AspNet.Builder { /// /// Configuration options for . diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs index 34f65b112e..e380ebf475 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Authentication.Google; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -15,23 +16,15 @@ namespace Microsoft.AspNet.Builder /// Adds the middleware to the specified , which enables Google authentication capabilities. /// /// The to add the middleware to. - /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app, Action configureOptions) + public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app) { if (app == null) { throw new ArgumentNullException(nameof(app)); } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - var options = new GoogleOptions(); - configureOptions(options); - - return app.UseMiddleware(options); + return app.UseMiddleware(); } /// @@ -51,7 +44,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware(options); + return app.UseMiddleware(Options.Create(options)); } } } diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs index e4b50132ad..675e424422 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs @@ -7,8 +7,9 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; using System.Threading.Tasks; -using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Authentication.OAuth; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.WebUtilities; using Newtonsoft.Json.Linq; diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs index 55d2b0ed13..72ec3dee98 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs @@ -5,6 +5,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Text.Encodings.Web; using Microsoft.AspNet.Authentication.OAuth; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; @@ -34,7 +35,7 @@ namespace Microsoft.AspNet.Authentication.Google ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions sharedOptions, - GoogleOptions options) + IOptions options) : base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options) { if (next == null) diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs index 2c00278c78..eb1f0c3f1b 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs @@ -1,10 +1,10 @@ // 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.Authentication.OAuth; +using Microsoft.AspNet.Authentication.Google; using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Authentication.Google +namespace Microsoft.AspNet.Builder { /// /// Configuration options for . diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs index f8848d210d..02898af9c9 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Authentication.JwtBearer diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs index 91dd8cea22..50ed9ffc5f 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Authentication.JwtBearer diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs index ae6b9d4c69..403e8ab7fd 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerChallengeContext.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 Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivedTokenContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivedTokenContext.cs index 0aadaf2a99..a0c7a98c29 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivedTokenContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivedTokenContext.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 Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Authentication.JwtBearer diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivingTokenContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivingTokenContext.cs index b0d824f3f7..16ee6c1cee 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivingTokenContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivingTokenContext.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 Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Authentication.JwtBearer diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/TokenValidatedContext.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/TokenValidatedContext.cs index 9ae2fa68aa..1f6e24e922 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/Events/TokenValidatedContext.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 Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Authentication.JwtBearer diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index da36d17f08..bea74d7412 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Authentication.JwtBearer; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -21,23 +22,15 @@ namespace Microsoft.AspNet.Builder /// See also http://tools.ietf.org/html/rfc6749 /// /// The to add the middleware to. - /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app, Action configureOptions) + public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app) { if (app == null) { throw new ArgumentNullException(nameof(app)); } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - var options = new JwtBearerOptions(); - configureOptions(options); - - return app.UseMiddleware(options); + return app.UseMiddleware(); } /// @@ -63,7 +56,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware(options); + return app.UseMiddleware(Options.Create(options)); } } } diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs index 08640019c9..be6e83c036 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs index ad518b9667..7102cb61af 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs @@ -4,8 +4,10 @@ using System; using System.Net.Http; using System.Text.Encodings.Web; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -27,7 +29,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer RequestDelegate next, ILoggerFactory loggerFactory, UrlEncoder encoder, - JwtBearerOptions options) + IOptions options) : base(next, options, loggerFactory, encoder) { if (next == null) diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs index ad2160c06a..b028d0b5e8 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs @@ -6,11 +6,13 @@ using System.Collections.Generic; using System.ComponentModel; using System.IdentityModel.Tokens.Jwt; using System.Net.Http; +using Microsoft.AspNet.Authentication; +using Microsoft.AspNet.Authentication.JwtBearer; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNet.Builder { /// /// Options class provides information needed to control Bearer Authentication middleware behavior diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs index 4066fa4ed7..1986227da3 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Authentication.MicrosoftAccount; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -15,23 +16,15 @@ namespace Microsoft.AspNet.Builder /// Adds the middleware to the specified , which enables Microsoft Account authentication capabilities. /// /// The to add the middleware to. - /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app, Action configureOptions) + public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app) { if (app == null) { throw new ArgumentNullException(nameof(app)); } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - var options = new MicrosoftAccountOptions(); - configureOptions(options); - - return app.UseMiddleware(options); + return app.UseMiddleware(); } /// @@ -51,7 +44,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware(options); + return app.UseMiddleware(Options.Create(options)); } } } diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 35dcc92239..f28c7ffc7f 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -6,6 +6,7 @@ using System.Net.Http.Headers; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNet.Authentication.OAuth; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http.Authentication; using Newtonsoft.Json.Linq; diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs index c398b9279e..5f0e36bb45 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs @@ -4,6 +4,7 @@ using System; using System.Text.Encodings.Web; using Microsoft.AspNet.Authentication.OAuth; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; @@ -32,7 +33,7 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions sharedOptions, - MicrosoftAccountOptions options) + IOptions options) : base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options) { if (next == null) diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs index 3339cf4ccd..392df69bf7 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Http; -using Microsoft.AspNet.Authentication.OAuth; +using Microsoft.AspNet.Authentication.MicrosoftAccount; -namespace Microsoft.AspNet.Authentication.MicrosoftAccount +namespace Microsoft.AspNet.Builder { /// /// Configuration options for . diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs index 835bb2e3ae..c2b35349ee 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -5,8 +5,8 @@ using System; using System.Globalization; using System.Net.Http; using System.Security.Claims; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; using Newtonsoft.Json.Linq; namespace Microsoft.AspNet.Authentication.OAuth diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs index 7cc85f11a1..8e3599605f 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.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 Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs index 5599407ca3..8d71400bae 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Authentication.OAuth; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -15,23 +16,15 @@ namespace Microsoft.AspNet.Builder /// Adds the middleware to the specified , which enables OAuth 2.0 authentication capabilities. /// /// The to add the middleware to. - /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app, Action configureOptions) + public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app) { if (app == null) { throw new ArgumentNullException(nameof(app)); } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - var options = new OAuthOptions(); - configureOptions(options); - - return app.UseMiddleware>(options); + return app.UseMiddleware>(); } /// @@ -51,7 +44,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware>(options); + return app.UseMiddleware>(Options.Create(options)); } } } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs index 6f197d86bc..632932a3fb 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs @@ -9,6 +9,7 @@ using System.Security.Claims; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Extensions; diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs index ea145fa6de..72d34cbf78 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Net.Http; using System.Text.Encodings.Web; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; @@ -32,7 +33,7 @@ namespace Microsoft.AspNet.Authentication.OAuth ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions sharedOptions, - TOptions options) + IOptions options) : base(next, options, loggerFactory, encoder) { if (next == null) diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs index a79c546725..d53e0a8bcd 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs @@ -2,9 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using Microsoft.AspNet.Authentication; +using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Http.Authentication; -namespace Microsoft.AspNet.Authentication.OAuth +namespace Microsoft.AspNet.Builder { /// /// Configuration options for . diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs index 6c8edb9f41..a120c24026 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNet.Authentication.OpenIdConnect { diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs index f9998b83e7..2469ef5c86 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.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 Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs index 59f4d49115..f43be81981 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs @@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.IdentityModel.Tokens.Jwt; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs index 8e8b86a13a..e0c74c8db5 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs @@ -1,9 +1,9 @@ // 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.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNet.Authentication.OpenIdConnect { diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs index 76d63e27b1..e207c836a5 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.IdentityModel.Protocols.OpenIdConnect; diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs index 6439257cba..cb42c0f9bc 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs @@ -1,8 +1,8 @@ // 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.Builder; using Microsoft.AspNet.Http; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNet.Authentication.OpenIdConnect { diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/RedirectContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/RedirectContext.cs index fa1ef30d08..a87c3398ed 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/RedirectContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/RedirectContext.cs @@ -1,9 +1,9 @@ // 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.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNet.Authentication.OpenIdConnect { diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs index e9522f70d8..0e12bc2914 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs @@ -1,4 +1,8 @@ -using Microsoft.AspNet.Http; +// 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.Builder; +using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs index fa0bc92773..80935354af 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs @@ -1,8 +1,8 @@ // 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.Builder; using Microsoft.AspNet.Http; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Newtonsoft.Json.Linq; namespace Microsoft.AspNet.Authentication.OpenIdConnect diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs index 329820417c..63cfe5009a 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Authentication.OpenIdConnect; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -15,23 +16,15 @@ namespace Microsoft.AspNet.Builder /// Adds the middleware to the specified , which enables OpenID Connect authentication capabilities. /// /// The to add the middleware to. - /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app, Action configureOptions) + public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app) { if (app == null) { throw new ArgumentNullException(nameof(app)); } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - var options = new OpenIdConnectOptions(); - configureOptions(options); - - return app.UseMiddleware(options); + return app.UseMiddleware(); } /// @@ -51,7 +44,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware(options); + return app.UseMiddleware(Options.Create(options)); } } } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 2d157e48c3..12d61e334b 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -13,6 +13,7 @@ using System.Security.Cryptography; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs index a6f9971705..5dcd74d3c1 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text; using System.Text.Encodings.Web; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; @@ -38,7 +39,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect UrlEncoder encoder, IServiceProvider services, IOptions sharedOptions, - OpenIdConnectOptions options, + IOptions options, HtmlEncoder htmlEncoder) : base(next, options, loggerFactory, encoder) { diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 06b7442de0..af7a621de0 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -5,13 +5,15 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IdentityModel.Tokens.Jwt; +using Microsoft.AspNet.Authentication; +using Microsoft.AspNet.Authentication.OpenIdConnect; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNet.Builder { /// /// Configuration options for diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/BaseTwitterContext.cs b/src/Microsoft.AspNet.Authentication.Twitter/Events/BaseTwitterContext.cs index 5a2f337581..d928fdcc71 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/Events/BaseTwitterContext.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/Events/BaseTwitterContext.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 Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Authentication.Twitter diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs index d727eeb152..d5537ef95c 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs index 455f522029..5569e82735 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.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 Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs index 1701122b0a..6303707521 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Authentication.Twitter; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -15,23 +16,15 @@ namespace Microsoft.AspNet.Builder /// Adds the middleware to the specified , which enables Twitter authentication capabilities. /// /// The to add the middleware to. - /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, Action configureOptions) + public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app) { if (app == null) { throw new ArgumentNullException(nameof(app)); } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - var options = new TwitterOptions(); - configureOptions(options); - - return app.UseMiddleware(options); + return app.UseMiddleware(); } /// @@ -51,7 +44,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware(options); + return app.UseMiddleware(Options.Create(options)); } } } diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs index 0552ed2d76..3de3b37fdf 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs @@ -9,6 +9,7 @@ using System.Security.Claims; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs index e1a1c17211..6b708a3a73 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Net.Http; using System.Text.Encodings.Web; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; @@ -37,7 +38,7 @@ namespace Microsoft.AspNet.Authentication.Twitter ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions sharedOptions, - TwitterOptions options) + IOptions options) : base(next, options, loggerFactory, encoder) { if (next == null) diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs index 85e266326a..19a3ca78aa 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs @@ -2,10 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Net.Http; +using Microsoft.AspNet.Authentication; +using Microsoft.AspNet.Authentication.Twitter; using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNet.Builder { /// /// Options for the Twitter authentication middleware. diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs index c45fdfa7e6..f68bddaf89 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs @@ -4,6 +4,7 @@ using System; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication/AuthenticationMiddleware.cs index ef7cb5056d..08e325bc0b 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticationMiddleware.cs @@ -4,8 +4,10 @@ using System; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authentication { @@ -15,7 +17,7 @@ namespace Microsoft.AspNet.Authentication protected AuthenticationMiddleware( RequestDelegate next, - TOptions options, + IOptions options, ILoggerFactory loggerFactory, UrlEncoder encoder) { @@ -39,7 +41,7 @@ namespace Microsoft.AspNet.Authentication throw new ArgumentNullException(nameof(encoder)); } - Options = options; + Options = options.Value; Logger = loggerFactory.CreateLogger(this.GetType().FullName); UrlEncoder = encoder; diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication/AuthenticationOptions.cs index 7583642443..5f8e562935 100644 --- a/src/Microsoft.AspNet.Authentication/AuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication/AuthenticationOptions.cs @@ -3,7 +3,7 @@ using Microsoft.AspNet.Http.Authentication; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNet.Builder { /// /// Base Options for all authentication middleware diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs index 21f80419f7..7dfa482174 100644 --- a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs @@ -5,6 +5,7 @@ using System; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNet.Authentication; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -13,6 +14,21 @@ namespace Microsoft.AspNet.Builder /// public static class ClaimsTransformationAppBuilderExtensions { + /// + /// Adds the middleware to the specified , which enables claims transformation capabilities. + /// + /// The to add the middleware to. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + + return app.UseMiddleware(); + } + /// /// Adds the middleware to the specified , which enables claims transformation capabilities. /// @@ -30,35 +46,12 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(transform)); } - return app.UseClaimsTransformation(options => + return app.UseClaimsTransformation(new ClaimsTransformationOptions { - options.Transformer = new ClaimsTransformer { OnTransform = transform }; + Transformer = new ClaimsTransformer { OnTransform = transform } }); } - - /// - /// Adds the middleware to the specified , which enables claims transformation capabilities. - /// - /// The to add the middleware to. - /// An action delegate to configure the provided . - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, Action configureOptions) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - - var options = new ClaimsTransformationOptions(); - configureOptions(options); - - return app.UseMiddleware(options); - } - + /// /// Adds the middleware to the specified , which enables claims transformation capabilities. /// @@ -76,7 +69,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware(options); + return app.UseMiddleware(Options.Create(options)); } } } diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationMiddleware.cs b/src/Microsoft.AspNet.Authentication/ClaimsTransformationMiddleware.cs index c84777cd81..f490af4a4f 100644 --- a/src/Microsoft.AspNet.Authentication/ClaimsTransformationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication/ClaimsTransformationMiddleware.cs @@ -3,7 +3,9 @@ using System; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Authentication { @@ -13,7 +15,7 @@ namespace Microsoft.AspNet.Authentication public ClaimsTransformationMiddleware( RequestDelegate next, - ClaimsTransformationOptions options) + IOptions options) { if (next == null) { @@ -25,7 +27,7 @@ namespace Microsoft.AspNet.Authentication throw new ArgumentNullException(nameof(options)); } - Options = options; + Options = options.Value; _next = next; } diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationOptions.cs b/src/Microsoft.AspNet.Authentication/ClaimsTransformationOptions.cs index 19475ba023..e1ca6b9004 100644 --- a/src/Microsoft.AspNet.Authentication/ClaimsTransformationOptions.cs +++ b/src/Microsoft.AspNet.Authentication/ClaimsTransformationOptions.cs @@ -1,7 +1,9 @@ // 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 +using Microsoft.AspNet.Authentication; + +namespace Microsoft.AspNet.Builder { public class ClaimsTransformationOptions { diff --git a/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs b/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs index 28f6649fee..0663248cf1 100644 --- a/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs +++ b/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; diff --git a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs index dda9063697..cc1487d55d 100644 --- a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.Extensions.Logging; diff --git a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs index 5fb3b4caf6..afaee6c7b1 100644 --- a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs @@ -3,10 +3,10 @@ using System; using System.Net.Http; -using System.Threading.Tasks; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Authentication; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNet.Builder { public class RemoteAuthenticationOptions : AuthenticationOptions { diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Authorization/AuthorizationServiceCollectionExtensions.cs index dff8bf6fcd..599a8fb27c 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -24,8 +24,7 @@ namespace Microsoft.Extensions.DependencyInjection { throw new ArgumentNullException(nameof(services)); } - - services.AddOptions(); + services.TryAdd(ServiceDescriptor.Transient()); services.TryAddEnumerable(ServiceDescriptor.Transient()); return services; diff --git a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs index 95d52e55f0..02cbd22f96 100644 --- a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.CookiePolicy; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Builder { @@ -15,23 +16,15 @@ namespace Microsoft.AspNet.Builder /// Adds the middleware to the specified , which enables cookie policy capabilities. /// /// The to add the middleware to. - /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app, Action configureOptions) + public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app) { if (app == null) { throw new ArgumentNullException(nameof(app)); } - if (configureOptions == null) - { - throw new ArgumentNullException(nameof(configureOptions)); - } - var options = new CookiePolicyOptions(); - configureOptions(options); - - return app.UseMiddleware(options); + return app.UseMiddleware(); } /// @@ -51,7 +44,7 @@ namespace Microsoft.AspNet.Builder throw new ArgumentNullException(nameof(options)); } - return app.UseMiddleware(options); + return app.UseMiddleware(Options.Create(options)); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyMiddleware.cs index 5c49b9e180..2fb299d165 100644 --- a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyMiddleware.cs @@ -3,9 +3,10 @@ using System; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Http.Features.Internal; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.CookiePolicy { @@ -15,9 +16,9 @@ namespace Microsoft.AspNet.CookiePolicy public CookiePolicyMiddleware( RequestDelegate next, - CookiePolicyOptions options) + IOptions options) { - Options = options; + Options = options.Value; _next = next; } diff --git a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyOptions.cs index ce5a866980..ffc2fa7b74 100644 --- a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyOptions.cs @@ -2,8 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.CookiePolicy; -namespace Microsoft.AspNet.CookiePolicy +namespace Microsoft.AspNet.Builder { public class CookiePolicyOptions { diff --git a/src/Microsoft.AspNet.CookiePolicy/project.json b/src/Microsoft.AspNet.CookiePolicy/project.json index 3eab1d58f9..79ccda4a15 100644 --- a/src/Microsoft.AspNet.CookiePolicy/project.json +++ b/src/Microsoft.AspNet.CookiePolicy/project.json @@ -10,7 +10,8 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Http": "1.0.0-*" + "Microsoft.AspNet.Http": "1.0.0-*", + "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { "net451": {}, diff --git a/test/Microsoft.AspNet.Authentication.Test/AuthenticationHandlerFacts.cs b/test/Microsoft.AspNet.Authentication.Test/AuthenticationHandlerFacts.cs index 073d6f1e4b..b5935938ae 100644 --- a/test/Microsoft.AspNet.Authentication.Test/AuthenticationHandlerFacts.cs +++ b/test/Microsoft.AspNet.Authentication.Test/AuthenticationHandlerFacts.cs @@ -6,6 +6,7 @@ using System.IO; using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features; diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs index ffcf6d8792..7827566a9f 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -27,9 +27,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task NormalRequestPassesThrough() { - var server = CreateServer(options => - { - }); + var server = CreateServer(new CookieAuthenticationOptions()); var response = await server.CreateClient().GetAsync("http://example.com/normal"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } @@ -37,10 +35,10 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task AjaxLoginRedirectToReturnUrlTurnsInto200WithLocationHeader() { - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.AutomaticChallenge = true; - options.LoginPath = "/login"; + AutomaticChallenge = true, + LoginPath = "/login" }); var transaction = await SendAsync(server, "http://example.com/protected?X-Requested-With=XMLHttpRequest"); @@ -53,9 +51,9 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task AjaxForbidTurnsInto403WithLocationHeader() { - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.AccessDeniedPath = "/denied"; + AccessDeniedPath = "/denied" }); var transaction = await SendAsync(server, "http://example.com/forbid?X-Requested-With=XMLHttpRequest"); @@ -68,9 +66,9 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task AjaxLogoutRedirectToReturnUrlTurnsInto200WithLocationHeader() { - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.LogoutPath = "/signout"; + LogoutPath = "/signout" }); var transaction = await SendAsync(server, "http://example.com/signout?X-Requested-With=XMLHttpRequest&ReturnUrl=/"); @@ -83,9 +81,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task AjaxChallengeRedirectTurnsInto200WithLocationHeader() { - var server = CreateServer(options => - { - }); + var server = CreateServer(new CookieAuthenticationOptions()); var transaction = await SendAsync(server, "http://example.com/challenge?X-Requested-With=XMLHttpRequest&ReturnUrl=/"); Assert.Equal(HttpStatusCode.Unauthorized, transaction.Response.StatusCode); @@ -100,10 +96,10 @@ namespace Microsoft.AspNet.Authentication.Cookies [InlineData(false)] public async Task ProtectedRequestShouldRedirectToLoginOnlyWhenAutomatic(bool auto) { - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.LoginPath = new PathString("/login"); - options.AutomaticChallenge = auto; + LoginPath = new PathString("/login"), + AutomaticChallenge = auto }); var transaction = await SendAsync(server, "http://example.com/protected"); @@ -120,7 +116,10 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task ProtectedCustomRequestShouldRedirectToCustomRedirectUri() { - var server = CreateServer(options => options.AutomaticChallenge = true); + var server = CreateServer(new CookieAuthenticationOptions + { + AutomaticChallenge = true + }); var transaction = await SendAsync(server, "http://example.com/protected/CustomRedirect"); @@ -151,10 +150,10 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task SignInCausesDefaultCookieToBeCreated() { - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.LoginPath = new PathString("/login"); - options.CookieName = "TestCookie"; + LoginPath = new PathString("/login"), + CookieName = "TestCookie" }, SignInAsAlice); var transaction = await SendAsync(server, "http://example.com/testpath"); @@ -171,10 +170,10 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task SignInWrongAuthTypeThrows() { - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.LoginPath = new PathString("/login"); - options.CookieName = "TestCookie"; + LoginPath = new PathString("/login"), + CookieName = "TestCookie" }, SignInAsWrong); await Assert.ThrowsAsync(async () => await SendAsync(server, "http://example.com/testpath")); @@ -183,10 +182,10 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task SignOutWrongAuthTypeThrows() { - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.LoginPath = new PathString("/login"); - options.CookieName = "TestCookie"; + LoginPath = new PathString("/login"), + CookieName = "TestCookie" }, SignOutAsWrong); await Assert.ThrowsAsync(async () => await SendAsync(server, "http://example.com/testpath")); @@ -204,11 +203,11 @@ namespace Microsoft.AspNet.Authentication.Cookies string requestUri, bool shouldBeSecureOnly) { - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.LoginPath = new PathString("/login"); - options.CookieName = "TestCookie"; - options.CookieSecure = cookieSecureOption; + LoginPath = new PathString("/login"), + CookieName = "TestCookie", + CookieSecure = cookieSecureOption }, SignInAsAlice); var transaction = await SendAsync(server, requestUri); @@ -227,13 +226,13 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task CookieOptionsAlterSetCookieHeader() { - TestServer server1 = CreateServer(options => + TestServer server1 = CreateServer(new CookieAuthenticationOptions { - options.CookieName = "TestCookie"; - options.CookiePath = "/foo"; - options.CookieDomain = "another.com"; - options.CookieSecure = CookieSecureOption.Always; - options.CookieHttpOnly = true; + CookieName = "TestCookie", + CookiePath = "/foo", + CookieDomain = "another.com", + CookieSecure = CookieSecureOption.Always, + CookieHttpOnly = true }, SignInAsAlice, new Uri("http://example.com/base")); var transaction1 = await SendAsync(server1, "http://example.com/base/testpath"); @@ -246,11 +245,11 @@ namespace Microsoft.AspNet.Authentication.Cookies Assert.Contains(" secure", setCookie1); Assert.Contains(" httponly", setCookie1); - var server2 = CreateServer(options => + var server2 = CreateServer(new CookieAuthenticationOptions { - options.CookieName = "SecondCookie"; - options.CookieSecure = CookieSecureOption.Never; - options.CookieHttpOnly = false; + CookieName = "SecondCookie", + CookieSecure = CookieSecureOption.Never, + CookieHttpOnly = false }, SignInAsAlice, new Uri("http://example.com/base")); var transaction2 = await SendAsync(server2, "http://example.com/base/testpath"); @@ -268,9 +267,9 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieContainsIdentity() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; + SystemClock = clock }, SignInAsAlice); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -284,24 +283,27 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieAppliesClaimsTransform() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; + SystemClock = clock }, SignInAsAlice, baseAddress: null, - claimsTransform: o => o.Transformer = new ClaimsTransformer + claimsTransform: new ClaimsTransformationOptions { - OnTransform = p => + Transformer = new ClaimsTransformer { - if (!p.Identities.Any(i => i.AuthenticationType == "xform")) + OnTransform = p => { - // REVIEW: Xform runs twice, once on Authenticate, and then once from the middleware - var id = new ClaimsIdentity("xform"); - id.AddClaim(new Claim("xform", "yup")); - p.AddIdentity(id); + if (!p.Identities.Any(i => i.AuthenticationType == "xform")) + { + // REVIEW: Xform runs twice, once on Authenticate, and then once from the middleware + var id = new ClaimsIdentity("xform"); + id.AddClaim(new Claim("xform", "yup")); + p.AddIdentity(id); + } + return Task.FromResult(p); } - return Task.FromResult(p); } }); @@ -318,11 +320,11 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieStopsWorkingAfterExpiration() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.ExpireTimeSpan = TimeSpan.FromMinutes(10); - options.SlidingExpiration = false; + SystemClock = clock, + ExpireTimeSpan = TimeSpan.FromMinutes(10), + SlidingExpiration = false }, SignInAsAlice); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -349,11 +351,11 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieExpirationCanBeOverridenInSignin() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.ExpireTimeSpan = TimeSpan.FromMinutes(10); - options.SlidingExpiration = false; + SystemClock = clock, + ExpireTimeSpan = TimeSpan.FromMinutes(10), + SlidingExpiration = false }, context => context.Authentication.SignInAsync("Cookies", @@ -384,18 +386,18 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task ExpiredCookieWithValidatorStillExpired() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.ExpireTimeSpan = TimeSpan.FromMinutes(10); - options.Events = new CookieAuthenticationEvents + SystemClock = clock, + ExpireTimeSpan = TimeSpan.FromMinutes(10), + Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { ctx.ShouldRenew = true; return Task.FromResult(0); } - }; + } }, context => context.Authentication.SignInAsync("Cookies", @@ -414,12 +416,12 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieCanBeRejectedAndSignedOutByValidator() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.ExpireTimeSpan = TimeSpan.FromMinutes(10); - options.SlidingExpiration = false; - options.Events = new CookieAuthenticationEvents + SystemClock = clock, + ExpireTimeSpan = TimeSpan.FromMinutes(10), + SlidingExpiration = false, + Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { @@ -427,7 +429,7 @@ namespace Microsoft.AspNet.Authentication.Cookies ctx.HttpContext.Authentication.SignOutAsync("Cookies"); return Task.FromResult(0); } - }; + } }, context => context.Authentication.SignInAsync("Cookies", @@ -444,19 +446,19 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieCanBeRenewedByValidator() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.ExpireTimeSpan = TimeSpan.FromMinutes(10); - options.SlidingExpiration = false; - options.Events = new CookieAuthenticationEvents + SystemClock = clock, + ExpireTimeSpan = TimeSpan.FromMinutes(10), + SlidingExpiration = false, + Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { ctx.ShouldRenew = true; return Task.FromResult(0); } - }; + } }, context => context.Authentication.SignInAsync("Cookies", @@ -491,18 +493,18 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.ExpireTimeSpan = TimeSpan.FromMinutes(10); - options.Events = new CookieAuthenticationEvents + SystemClock = clock, + ExpireTimeSpan = TimeSpan.FromMinutes(10), + Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { ctx.ShouldRenew = true; return Task.FromResult(0); } - }; + } }, context => context.Authentication.SignInAsync("Cookies", @@ -537,19 +539,19 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieValidatorOnlyCalledOnce() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.ExpireTimeSpan = TimeSpan.FromMinutes(10); - options.SlidingExpiration = false; - options.Events = new CookieAuthenticationEvents + SystemClock = clock, + ExpireTimeSpan = TimeSpan.FromMinutes(10), + SlidingExpiration = false, + Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { ctx.ShouldRenew = true; return Task.FromResult(0); } - }; + } }, context => context.Authentication.SignInAsync("Cookies", @@ -588,12 +590,12 @@ namespace Microsoft.AspNet.Authentication.Cookies var clock = new TestClock(); DateTimeOffset? lastValidateIssuedDate = null; DateTimeOffset? lastExpiresDate = null; - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.ExpireTimeSpan = TimeSpan.FromMinutes(10); - options.SlidingExpiration = sliding; - options.Events = new CookieAuthenticationEvents + SystemClock = clock, + ExpireTimeSpan = TimeSpan.FromMinutes(10), + SlidingExpiration = sliding, + Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { @@ -602,7 +604,7 @@ namespace Microsoft.AspNet.Authentication.Cookies ctx.ShouldRenew = true; return Task.FromResult(0); } - }; + } }, context => context.Authentication.SignInAsync("Cookies", @@ -640,19 +642,19 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieExpirationCanBeOverridenInEvent() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.ExpireTimeSpan = TimeSpan.FromMinutes(10); - options.SlidingExpiration = false; - options.Events = new CookieAuthenticationEvents() + SystemClock = clock, + ExpireTimeSpan = TimeSpan.FromMinutes(10), + SlidingExpiration = false, + Events = new CookieAuthenticationEvents() { OnSigningIn = context => { context.Properties.ExpiresUtc = clock.UtcNow.Add(TimeSpan.FromMinutes(5)); return Task.FromResult(0); } - }; + } }, SignInAsAlice); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -678,11 +680,11 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieIsRenewedWithSlidingExpiration() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.ExpireTimeSpan = TimeSpan.FromMinutes(10); - options.SlidingExpiration = true; + SystemClock = clock, + ExpireTimeSpan = TimeSpan.FromMinutes(10), + SlidingExpiration = true }, SignInAsAlice); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -715,7 +717,7 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieUsesPathBaseByDefault() { var clock = new TestClock(); - var server = CreateServer(options => { }, + var server = CreateServer(new CookieAuthenticationOptions(), context => { Assert.Equal(new PathString("/base"), context.Request.PathBase); @@ -734,10 +736,10 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieTurnsChallengeIntoForbidWithCookie(bool automatic) { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.AutomaticAuthenticate = automatic; - options.SystemClock = clock; + AutomaticAuthenticate = automatic, + SystemClock = clock }, SignInAsAlice); @@ -758,10 +760,10 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieChallengeRedirectsToLoginWithoutCookie(bool automatic) { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.AutomaticAuthenticate = automatic; - options.SystemClock = clock; + AutomaticAuthenticate = automatic, + SystemClock = clock }, SignInAsAlice); @@ -779,10 +781,10 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieForbidRedirectsWithoutCookie(bool automatic) { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.AutomaticAuthenticate = automatic; - options.SystemClock = clock; + AutomaticAuthenticate = automatic, + SystemClock = clock }, SignInAsAlice); @@ -798,10 +800,10 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieTurns401ToAccessDeniedWhenSetWithCookie() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.AccessDeniedPath = new PathString("/accessdenied"); + SystemClock = clock, + AccessDeniedPath = new PathString("/accessdenied") }, SignInAsAlice); @@ -819,10 +821,10 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieChallengeRedirectsWithLoginPath() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.LoginPath = new PathString("/page"); + SystemClock = clock, + LoginPath = new PathString("/page") }); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -836,10 +838,10 @@ namespace Microsoft.AspNet.Authentication.Cookies public async Task CookieChallengeWithUnauthorizedRedirectsToLoginIfNotAuthenticated() { var clock = new TestClock(); - var server = CreateServer(options => + var server = CreateServer(new CookieAuthenticationOptions { - options.SystemClock = clock; - options.LoginPath = new PathString("/page"); + SystemClock = clock, + LoginPath = new PathString("/page") }); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -855,7 +857,10 @@ namespace Microsoft.AspNet.Authentication.Cookies var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => options.LoginPath = new PathString("/page")); + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + LoginPath = new PathString("/page") + }); app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); }) .ConfigureServices(services => services.AddAuthentication()); @@ -895,7 +900,10 @@ namespace Microsoft.AspNet.Authentication.Cookies var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => options.CookieName = "One"); + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + CookieName = "One" + }); app.UseCookieAuthentication(); app.Run(context => context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity()))); }) @@ -914,7 +922,10 @@ namespace Microsoft.AspNet.Authentication.Cookies var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => options.LoginPath = new PathString("/login")); + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + LoginPath = new PathString("/login") + }); app.Map("/notlogin", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies", new ClaimsPrincipal()))); }) @@ -932,7 +943,10 @@ namespace Microsoft.AspNet.Authentication.Cookies var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => options.LoginPath = new PathString("/login")); + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + LoginPath = new PathString("/login") + }); app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies", new ClaimsPrincipal()))); }) @@ -954,7 +968,10 @@ namespace Microsoft.AspNet.Authentication.Cookies var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => options.LogoutPath = new PathString("/logout")); + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + LogoutPath = new PathString("/logout") + }); app.Map("/notlogout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies"))); }) .ConfigureServices(services => services.AddAuthentication()); @@ -971,7 +988,10 @@ namespace Microsoft.AspNet.Authentication.Cookies var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => options.LogoutPath = new PathString("/logout")); + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + LogoutPath = new PathString("/logout") + }); app.Map("/logout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies"))); }) .ConfigureServices(services => services.AddAuthentication()); @@ -992,7 +1012,10 @@ namespace Microsoft.AspNet.Authentication.Cookies var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => options.AccessDeniedPath = new PathString("/denied")); + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + AccessDeniedPath = new PathString("/denied") + }); app.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies"))); }) .ConfigureServices(services => services.AddAuthentication()); @@ -1012,7 +1035,10 @@ namespace Microsoft.AspNet.Authentication.Cookies .Configure(app => app.Map("/base", map => { - map.UseCookieAuthentication(options => options.LoginPath = new PathString("/page")); + map.UseCookieAuthentication(new CookieAuthenticationOptions + { + LoginPath = new PathString("/page") + }); map.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); })) .ConfigureServices(services => services.AddAuthentication()); @@ -1033,7 +1059,10 @@ namespace Microsoft.AspNet.Authentication.Cookies .Configure(app => app.Map("/base", map => { - map.UseCookieAuthentication(options => options.AccessDeniedPath = new PathString("/denied")); + map.UseCookieAuthentication(new CookieAuthenticationOptions + { + AccessDeniedPath = new PathString("/denied") + }); map.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies"))); })) .ConfigureServices(services => services.AddAuthentication()); @@ -1054,10 +1083,10 @@ namespace Microsoft.AspNet.Authentication.Cookies var builder1 = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.TicketDataFormat = new TicketDataFormat(dp); - options.CookieName = "Cookie"; + TicketDataFormat = new TicketDataFormat(dp), + CookieName = "Cookie" }); app.Use((context, next) => context.Authentication.SignInAsync("Cookies", @@ -1073,11 +1102,11 @@ namespace Microsoft.AspNet.Authentication.Cookies var builder2 = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.AuthenticationScheme = "Cookies"; - options.CookieName = "Cookie"; - options.TicketDataFormat = new TicketDataFormat(dp); + AuthenticationScheme = "Cookies", + CookieName = "Cookie", + TicketDataFormat = new TicketDataFormat(dp) }); app.Use(async (context, next) => { @@ -1131,12 +1160,12 @@ namespace Microsoft.AspNet.Authentication.Cookies return me; } - private static TestServer CreateServer(Action configureOptions, Func testpath = null, Uri baseAddress = null, Action claimsTransform = null) + private static TestServer CreateServer(CookieAuthenticationOptions options, Func testpath = null, Uri baseAddress = null, ClaimsTransformationOptions claimsTransform = null) { var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(configureOptions); + app.UseCookieAuthentication(options); // app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "Cookie2" }); if (claimsTransform != null) diff --git a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs index 5263dadb57..95dcb2e5b7 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -30,23 +30,23 @@ namespace Microsoft.AspNet.Authentication.Facebook var server = CreateServer( app => { - app.UseFacebookAuthentication(options => + app.UseFacebookAuthentication(new FacebookOptions { - options.AppId = "Test App Id"; - options.AppSecret = "Test App Secret"; - options.Events = new OAuthEvents + AppId = "Test App Id", + AppSecret = "Test App Secret", + Events = new OAuthEvents { OnRedirectToAuthorizationEndpoint = context => { context.Response.Redirect(context.RedirectUri + "&custom=test"); return Task.FromResult(0); } - }; + } }); - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.AuthenticationScheme = "External"; - options.AutomaticAuthenticate = true; + AuthenticationScheme = "External", + AutomaticAuthenticate = true }); }, services => @@ -73,11 +73,11 @@ namespace Microsoft.AspNet.Authentication.Facebook { var server = CreateServer(app => app.Map("/base", map => { - map.UseFacebookAuthentication(options => + map.UseFacebookAuthentication(new FacebookOptions { - options.AppId = "Test App Id"; - options.AppSecret = "Test App Secret"; - options.SignInScheme = "External"; + AppId = "Test App Id", + AppSecret = "Test App Secret", + SignInScheme = "External" }); map.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Facebook", new AuthenticationProperties() { RedirectUri = "/" }))); }), @@ -100,11 +100,11 @@ namespace Microsoft.AspNet.Authentication.Facebook var server = CreateServer( app => { - app.UseFacebookAuthentication(options => + app.UseFacebookAuthentication(new FacebookOptions { - options.AppId = "Test App Id"; - options.AppSecret = "Test App Secret"; - options.SignInScheme = "External"; + AppId = "Test App Id", + AppSecret = "Test App Secret", + SignInScheme = "External" }); app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Facebook", new AuthenticationProperties() { RedirectUri = "/" }))); }, @@ -127,12 +127,15 @@ namespace Microsoft.AspNet.Authentication.Facebook var server = CreateServer( app => { - app.UseFacebookAuthentication(options => + app.UseFacebookAuthentication(new FacebookOptions { - options.AppId = "Test App Id"; - options.AppSecret = "Test App Secret"; + AppId = "Test App Id", + AppSecret = "Test App Secret" + }); + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + AuthenticationScheme = "External" }); - app.UseCookieAuthentication(options => options.AuthenticationScheme = "External"); }, services => { @@ -165,13 +168,13 @@ namespace Microsoft.AspNet.Authentication.Facebook app => { app.UseCookieAuthentication(); - app.UseFacebookAuthentication(options => + app.UseFacebookAuthentication(new FacebookOptions { - options.AppId = "Test App Id"; - options.AppSecret = "Test App Secret"; - options.StateDataFormat = stateFormat; - options.UserInformationEndpoint = customUserInfoEndpoint; - options.BackchannelHttpHandler = new TestHttpMessageHandler + AppId = "Test App Id", + AppSecret = "Test App Secret", + StateDataFormat = stateFormat, + UserInformationEndpoint = customUserInfoEndpoint, + BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -200,7 +203,7 @@ namespace Microsoft.AspNet.Authentication.Facebook } return null; } - }; + } }); }, services => diff --git a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs index dcfe91e5a1..6a6f028282 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -28,10 +28,10 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task ChallengeWillTriggerRedirection() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -50,10 +50,10 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task SignInThrows() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/signIn"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -62,10 +62,10 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task SignOutThrows() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -74,10 +74,10 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task ForbidThrows() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -86,11 +86,11 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task Challenge401WillTriggerRedirection() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.AutomaticChallenge = true; + ClientId = "Test Id", + ClientSecret = "Test Secret", + AutomaticChallenge = true }); var transaction = await server.SendAsync("https://example.com/401"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -105,10 +105,10 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task ChallengeWillSetCorrelationCookie() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/challenge"); Assert.Contains(".AspNet.Correlation.Google=", transaction.SetCookie.Single()); @@ -117,11 +117,11 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task Challenge401WillSetCorrelationCookie() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.AutomaticChallenge = true; + ClientId = "Test Id", + ClientSecret = "Test Secret", + AutomaticChallenge = true }); var transaction = await server.SendAsync("https://example.com/401"); Assert.Contains(".AspNet.Correlation.Google=", transaction.SetCookie.Single()); @@ -130,10 +130,10 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task ChallengeWillSetDefaultScope() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -144,11 +144,11 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task Challenge401WillSetDefaultScope() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.AutomaticChallenge = true; + ClientId = "Test Id", + ClientSecret = "Test Secret", + AutomaticChallenge = true }); var transaction = await server.SendAsync("https://example.com/401"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -159,11 +159,11 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.AutomaticChallenge = true; + ClientId = "Test Id", + ClientSecret = "Test Secret", + AutomaticChallenge = true }, context => { @@ -195,18 +195,18 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task ChallengeWillTriggerApplyRedirectEvent() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.Events = new OAuthEvents + ClientId = "Test Id", + ClientSecret = "Test Secret", + Events = new OAuthEvents { OnRedirectToAuthorizationEndpoint = context => { context.Response.Redirect(context.RedirectUri + "&custom=test"); return Task.FromResult(0); } - }; + } }); var transaction = await server.SendAsync("https://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -217,10 +217,10 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task AuthenticateWillFail() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }, async context => { @@ -240,10 +240,10 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task ReplyPathWithoutStateQueryStringWillBeRejected() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); var error = await Assert.ThrowsAnyAsync(() => server.SendAsync("https://example.com/signin-google?code=TestCode")); Assert.Equal("The oauth state was missing or invalid.", error.GetBaseException().Message); @@ -254,22 +254,19 @@ namespace Microsoft.AspNet.Authentication.Google [InlineData(false)] public async Task ReplyPathWithErrorFails(bool redirect) { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - if (redirect) + ClientId = "Test Id", + ClientSecret = "Test Secret", + Events = redirect ? new OAuthEvents() { - options.Events = new OAuthEvents() + OnRemoteFailure = ctx => { - OnRemoteFailure = ctx => - { - ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); - ctx.HandleResponse(); - return Task.FromResult(0); - } - }; - } + ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); + ctx.HandleResponse(); + return Task.FromResult(0); + } + } : new OAuthEvents() }); var sendTask = server.SendAsync("https://example.com/signin-google?error=OMG&error_description=SoBad&error_uri=foobar"); if (redirect) @@ -291,13 +288,13 @@ namespace Microsoft.AspNet.Authentication.Google public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string claimsIssuer) { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.StateDataFormat = stateFormat; - options.ClaimsIssuer = claimsIssuer; - options.BackchannelHttpHandler = new TestHttpMessageHandler + ClientId = "Test Id", + ClientSecret = "Test Secret", + StateDataFormat = stateFormat, + ClaimsIssuer = claimsIssuer, + BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -335,7 +332,7 @@ namespace Microsoft.AspNet.Authentication.Google throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - }; + } }); var properties = new AuthenticationProperties(); var correlationKey = ".AspNet.Correlation.Google"; @@ -373,31 +370,28 @@ namespace Microsoft.AspNet.Authentication.Google public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.StateDataFormat = stateFormat; - options.BackchannelHttpHandler = new TestHttpMessageHandler + ClientId = "Test Id", + ClientSecret = "Test Secret", + StateDataFormat = stateFormat, + BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { - return ReturnJsonResponse(new { Error = "Error" }, + return ReturnJsonResponse(new { Error = "Error" }, HttpStatusCode.BadRequest); } - }; - if (redirect) + }, + Events = redirect ? new OAuthEvents() { - options.Events = new OAuthEvents() + OnRemoteFailure = ctx => { - OnRemoteFailure = ctx => - { - ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); - ctx.HandleResponse(); - return Task.FromResult(0); - } - }; - } + ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); + ctx.HandleResponse(); + return Task.FromResult(0); + } + } : new OAuthEvents() }); var properties = new AuthenticationProperties(); var correlationKey = ".AspNet.Correlation.Google"; @@ -429,30 +423,27 @@ namespace Microsoft.AspNet.Authentication.Google public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.StateDataFormat = stateFormat; - options.BackchannelHttpHandler = new TestHttpMessageHandler + ClientId = "Test Id", + ClientSecret = "Test Secret", + StateDataFormat = stateFormat, + BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { return ReturnJsonResponse(new object()); } - }; - if (redirect) + }, + Events = redirect ? new OAuthEvents() { - options.Events = new OAuthEvents() + OnRemoteFailure = ctx => { - OnRemoteFailure = ctx => - { - ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); - ctx.HandleResponse(); - return Task.FromResult(0); - } - }; - } + ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); + ctx.HandleResponse(); + return Task.FromResult(0); + } + } : new OAuthEvents() }); var properties = new AuthenticationProperties(); var correlationKey = ".AspNet.Correlation.Google"; @@ -481,12 +472,12 @@ namespace Microsoft.AspNet.Authentication.Google public async Task AuthenticatedEventCanGetRefreshToken() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.StateDataFormat = stateFormat; - options.BackchannelHttpHandler = new TestHttpMessageHandler + ClientId = "Test Id", + ClientSecret = "Test Secret", + StateDataFormat = stateFormat, + BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -525,8 +516,8 @@ namespace Microsoft.AspNet.Authentication.Google throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - }; - options.Events = new OAuthEvents + }, + Events = new OAuthEvents { OnCreatingTicket = context => { @@ -534,7 +525,7 @@ namespace Microsoft.AspNet.Authentication.Google context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Google") }, "Google")); return Task.FromResult(0); } - }; + } }); var properties = new AuthenticationProperties(); var correlationKey = ".AspNet.Correlation.Google"; @@ -561,12 +552,12 @@ namespace Microsoft.AspNet.Authentication.Google public async Task NullRedirectUriWillRedirectToSlash() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.StateDataFormat = stateFormat; - options.BackchannelHttpHandler = new TestHttpMessageHandler + ClientId = "Test Id", + ClientSecret = "Test Secret", + StateDataFormat = stateFormat, + BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -605,15 +596,15 @@ namespace Microsoft.AspNet.Authentication.Google throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - }; - options.Events = new OAuthEvents + }, + Events = new OAuthEvents { OnTicketReceived = context => { context.Ticket.Properties.RedirectUri = null; return Task.FromResult(0); } - }; + } }); var properties = new AuthenticationProperties(); var correlationKey = ".AspNet.Correlation.Google"; @@ -634,13 +625,13 @@ namespace Microsoft.AspNet.Authentication.Google public async Task ValidateAuthenticatedContext() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.StateDataFormat = stateFormat; - options.AccessType = "offline"; - options.Events = new OAuthEvents() + ClientId = "Test Id", + ClientSecret = "Test Secret", + StateDataFormat = stateFormat, + AccessType = "offline", + Events = new OAuthEvents() { OnCreatingTicket = context => { @@ -655,8 +646,8 @@ namespace Microsoft.AspNet.Authentication.Google Assert.Equal(GoogleHelper.GetGivenName(context.User), "Test Given Name"); return Task.FromResult(0); } - }; - options.BackchannelHttpHandler = new TestHttpMessageHandler + }, + BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -695,7 +686,7 @@ namespace Microsoft.AspNet.Authentication.Google throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - }; + } }); var properties = new AuthenticationProperties(); @@ -717,10 +708,10 @@ namespace Microsoft.AspNet.Authentication.Google [Fact] public async Task NoStateCausesException() { - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); //Post a message to the Google middleware @@ -732,11 +723,11 @@ namespace Microsoft.AspNet.Authentication.Google public async Task CanRedirectOnError() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); - var server = CreateServer(options => + var server = CreateServer(new GoogleOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; - options.Events = new OAuthEvents() + ClientId = "Test Id", + ClientSecret = "Test Secret", + Events = new OAuthEvents() { OnRemoteFailure = ctx => { @@ -744,7 +735,7 @@ namespace Microsoft.AspNet.Authentication.Google ctx.HandleResponse(); return Task.FromResult(0); } - }; + } }); //Post a message to the Google middleware @@ -764,17 +755,17 @@ namespace Microsoft.AspNet.Authentication.Google return res; } - private static TestServer CreateServer(Action configureOptions, Func testpath = null) + private static TestServer CreateServer(GoogleOptions options, Func testpath = null) { var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.AuthenticationScheme = TestExtensions.CookieAuthenticationScheme; - options.AutomaticAuthenticate = true; + AuthenticationScheme = TestExtensions.CookieAuthenticationScheme, + AutomaticAuthenticate = true }); - app.UseGoogleAuthentication(configureOptions); + app.UseGoogleAuthentication(options); app.UseClaimsTransformation(p => { var id = new ClaimsIdentity("xform"); @@ -833,7 +824,7 @@ namespace Microsoft.AspNet.Authentication.Google }) .ConfigureServices(services => { - services.AddAuthentication(options => options.SignInScheme = TestExtensions.CookieAuthenticationScheme); + services.AddAuthentication(authOptions => authOptions.SignInScheme = TestExtensions.CookieAuthenticationScheme); }); return new TestServer(builder); } diff --git a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index a3e7fbd54e..2732d0caaa 100644 --- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Security.Claims; @@ -27,14 +28,14 @@ namespace Microsoft.AspNet.Authentication.JwtBearer // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/179 public async Task BearerTokenValidation() { - var server = CreateServer(options => + var options = new JwtBearerOptions { - options.AutomaticAuthenticate = true; - - options.Authority = "https://login.windows.net/tushartest.onmicrosoft.com"; - options.Audience = "https://TusharTest.onmicrosoft.com/TodoListService-ManualJwt"; - options.TokenValidationParameters.ValidateLifetime = false; - }); + AutomaticAuthenticate = true, + Authority = "https://login.windows.net/tushartest.onmicrosoft.com", + Audience = "https://TusharTest.onmicrosoft.com/TodoListService-ManualJwt" + }; + options.TokenValidationParameters.ValidateLifetime = false; + var server = CreateServer(options); var newBearerToken = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtyaU1QZG1Cdng2OHNrVDgtbVBBQjNCc2VlQSJ9.eyJhdWQiOiJodHRwczovL1R1c2hhclRlc3Qub25taWNyb3NvZnQuY29tL1RvZG9MaXN0U2VydmljZS1NYW51YWxKd3QiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9hZmJlY2UwMy1hZWFhLTRmM2YtODVlNy1jZTA4ZGQyMGNlNTAvIiwiaWF0IjoxNDE4MzMwNjE0LCJuYmYiOjE0MTgzMzA2MTQsImV4cCI6MTQxODMzNDUxNCwidmVyIjoiMS4wIiwidGlkIjoiYWZiZWNlMDMtYWVhYS00ZjNmLTg1ZTctY2UwOGRkMjBjZTUwIiwiYW1yIjpbInB3ZCJdLCJvaWQiOiI1Mzk3OTdjMi00MDE5LTQ2NTktOWRiNS03MmM0Yzc3NzhhMzMiLCJ1cG4iOiJWaWN0b3JAVHVzaGFyVGVzdC5vbm1pY3Jvc29mdC5jb20iLCJ1bmlxdWVfbmFtZSI6IlZpY3RvckBUdXNoYXJUZXN0Lm9ubWljcm9zb2Z0LmNvbSIsInN1YiI6IkQyMm9aMW9VTzEzTUFiQXZrdnFyd2REVE80WXZJdjlzMV9GNWlVOVUwYnciLCJmYW1pbHlfbmFtZSI6Ikd1cHRhIiwiZ2l2ZW5fbmFtZSI6IlZpY3RvciIsImFwcGlkIjoiNjEzYjVhZjgtZjJjMy00MWI2LWExZGMtNDE2Yzk3ODAzMGI3IiwiYXBwaWRhY3IiOiIwIiwic2NwIjoidXNlcl9pbXBlcnNvbmF0aW9uIiwiYWNyIjoiMSJ9.N_Kw1EhoVGrHbE6hOcm7ERdZ7paBQiNdObvp2c6T6n5CE8p0fZqmUd-ya_EqwElcD6SiKSiP7gj0gpNUnOJcBl_H2X8GseaeeMxBrZdsnDL8qecc6_ygHruwlPltnLTdka67s1Ow4fDSHaqhVTEk6lzGmNEcbNAyb0CxQxU6o7Fh0yHRiWoLsT8yqYk8nKzsHXfZBNby4aRo3_hXaa4i0SZLYfDGGYPdttG4vT_u54QGGd4Wzbonv2gjDlllOVGOwoJS6kfl1h8mk0qxdiIaT_ChbDWgkWvTB7bTvBE-EgHgV0XmAo0WtJeSxgjsG3KhhEPsONmqrSjhIUV4IVnF2w"; var response = await SendAsync(server, "http://example.com/oauth", newBearerToken); @@ -44,9 +45,9 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task SignInThrows() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.AutomaticAuthenticate = true; + AutomaticAuthenticate = true }); var transaction = await server.SendAsync("https://example.com/signIn"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -55,9 +56,9 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task SignOutThrows() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.AutomaticAuthenticate = true; + AutomaticAuthenticate = true }); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -67,11 +68,10 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task CustomHeaderReceived() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.AutomaticAuthenticate = true; - - options.Events = new JwtBearerEvents() + AutomaticAuthenticate = true, + Events = new JwtBearerEvents() { OnReceivingToken = context => { @@ -90,7 +90,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer return Task.FromResult(null); } - }; + } }); var response = await SendAsync(server, "http://example.com/oauth", "someHeader someblob"); @@ -101,7 +101,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task NoHeaderReceived() { - var server = CreateServer(options => { }); + var server = CreateServer(new JwtBearerOptions()); var response = await SendAsync(server, "http://example.com/oauth"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); } @@ -109,7 +109,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task HeaderWithoutBearerReceived() { - var server = CreateServer(options => { }); + var server = CreateServer(new JwtBearerOptions()); var response = await SendAsync(server, "http://example.com/oauth","Token"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); } @@ -117,9 +117,9 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task UnrecognizedTokenReceived() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.AutomaticAuthenticate = true; + AutomaticAuthenticate = true }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); @@ -130,12 +130,13 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task InvalidTokenReceived() { - var server = CreateServer(options => + var options = new JwtBearerOptions { - options.AutomaticAuthenticate = true; - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new InvalidTokenValidator()); - }); + AutomaticAuthenticate = true + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new InvalidTokenValidator()); + var server = CreateServer(options); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); @@ -145,11 +146,10 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task CustomTokenReceived() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.AutomaticAuthenticate = true; - - options.Events = new JwtBearerEvents() + AutomaticAuthenticate = true, + Events = new JwtBearerEvents() { OnReceivedToken = context => { @@ -168,7 +168,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer return Task.FromResult(null); } - }; + } }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); @@ -179,11 +179,10 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task CustomTokenValidated() { - var server = CreateServer(options => + var options = new JwtBearerOptions { - options.AutomaticAuthenticate = true; - - options.Events = new JwtBearerEvents() + AutomaticAuthenticate = true, + Events = new JwtBearerEvents() { OnValidatedToken = context => { @@ -203,10 +202,10 @@ namespace Microsoft.AspNet.Authentication.JwtBearer return Task.FromResult(null); } - }; - - options.SecurityTokenValidators.Add(new BlobTokenValidator(options.AuthenticationScheme)); - }); + } + }; + options.SecurityTokenValidators.Add(new BlobTokenValidator(options.AuthenticationScheme)); + var server = CreateServer(options); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); @@ -216,11 +215,10 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task RetrievingTokenFromAlternateLocation() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.AutomaticAuthenticate = true; - - options.Events = new JwtBearerEvents() + AutomaticAuthenticate = true, + Events = new JwtBearerEvents() { OnReceivingToken = context => { @@ -244,7 +242,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer return Task.FromResult(null); } - }; + } }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer Token"); @@ -255,9 +253,9 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task BearerTurns401To403IfAuthenticated() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.Events = new JwtBearerEvents() + Events = new JwtBearerEvents() { OnReceivedToken = context => { @@ -276,7 +274,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer return Task.FromResult(null); } - }; + } }); var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); @@ -286,9 +284,9 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task BearerDoesNothingTo401IfNotAuthenticated() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.Events = new JwtBearerEvents() + Events = new JwtBearerEvents() { OnReceivedToken = context => { @@ -307,7 +305,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer return Task.FromResult(null); } - }; + } }); var response = await SendAsync(server, "http://example.com/unauthorized"); @@ -317,11 +315,10 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task EventOnReceivingTokenSkipped_NoMoreEventsExecuted() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.AutomaticAuthenticate = true; - - options.Events = new JwtBearerEvents() + AutomaticAuthenticate = true, + Events = new JwtBearerEvents() { OnReceivingToken = context => { @@ -344,7 +341,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer { throw new NotImplementedException(); }, - }; + } }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); @@ -355,11 +352,10 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task EventOnReceivedTokenSkipped_NoMoreEventsExecuted() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.AutomaticAuthenticate = true; - - options.Events = new JwtBearerEvents() + AutomaticAuthenticate = true, + Events = new JwtBearerEvents() { OnReceivedToken = context => { @@ -378,7 +374,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer { throw new NotImplementedException(); }, - }; + } }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); @@ -389,12 +385,10 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task EventOnValidatedTokenSkipped_NoMoreEventsExecuted() { - var server = CreateServer(options => + var options = new JwtBearerOptions { - options.AutomaticAuthenticate = true; - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); - options.Events = new JwtBearerEvents() + AutomaticAuthenticate = true, + Events = new JwtBearerEvents() { OnValidatedToken = context => { @@ -409,8 +403,11 @@ namespace Microsoft.AspNet.Authentication.JwtBearer { throw new NotImplementedException(); }, - }; - }); + } + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + var server = CreateServer(options); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); @@ -420,12 +417,10 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() { - var server = CreateServer(options => + var options = new JwtBearerOptions { - options.AutomaticAuthenticate = true; - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); - options.Events = new JwtBearerEvents() + AutomaticAuthenticate = true, + Events = new JwtBearerEvents() { OnValidatedToken = context => { @@ -440,8 +435,11 @@ namespace Microsoft.AspNet.Authentication.JwtBearer { throw new NotImplementedException(); }, - }; - }); + } + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + var server = CreateServer(options); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); @@ -451,18 +449,18 @@ namespace Microsoft.AspNet.Authentication.JwtBearer [Fact] public async Task EventOnChallengeSkipped_ResponseNotModified() { - var server = CreateServer(options => + var server = CreateServer(new JwtBearerOptions { - options.AutomaticAuthenticate = true; - options.AutomaticChallenge = true; - options.Events = new JwtBearerEvents() + AutomaticAuthenticate = true, + AutomaticChallenge = true, + Events = new JwtBearerEvents() { OnChallenge = context => { context.SkipToNextMiddleware(); return Task.FromResult(0); }, - }; + } }); var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); @@ -535,14 +533,14 @@ namespace Microsoft.AspNet.Authentication.JwtBearer } } - private static TestServer CreateServer(Action configureOptions, Func handler = null) + private static TestServer CreateServer(JwtBearerOptions options, Func handler = null) { var builder = new WebApplicationBuilder() .Configure(app => { - if (configureOptions != null) + if (options != null) { - app.UseJwtBearerAuthentication(configureOptions); + app.UseJwtBearerAuthentication(options); } app.Use(async (context, next) => diff --git a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index 849cdfe0a2..29f6e0edcc 100644 --- a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -8,7 +8,6 @@ using System.Security.Claims; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Authentication.MicrosoftAccount; using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; @@ -27,19 +26,18 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount [Fact] public async Task ChallengeWillTriggerApplyRedirectEvent() { - var server = CreateServer( - options => + var server = CreateServer(new MicrosoftAccountOptions { - options.ClientId = "Test Client Id"; - options.ClientSecret = "Test Client Secret"; - options.Events = new OAuthEvents + ClientId = "Test Client Id", + ClientSecret = "Test Client Secret", + Events = new OAuthEvents { OnRedirectToAuthorizationEndpoint = context => { context.Response.Redirect(context.RedirectUri + "&custom=test"); return Task.FromResult(0); } - }; + } }); var transaction = await server.SendAsync("http://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -50,10 +48,10 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount [Fact] public async Task SignInThrows() { - var server = CreateServer(options => + var server = CreateServer(new MicrosoftAccountOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/signIn"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -62,10 +60,10 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount [Fact] public async Task SignOutThrows() { - var server = CreateServer(options => + var server = CreateServer(new MicrosoftAccountOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -74,10 +72,10 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount [Fact] public async Task ForbidThrows() { - var server = CreateServer(options => + var server = CreateServer(new MicrosoftAccountOptions { - options.ClientId = "Test Id"; - options.ClientSecret = "Test Secret"; + ClientId = "Test Id", + ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -86,11 +84,10 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount [Fact] public async Task ChallengeWillTriggerRedirection() { - var server = CreateServer( - options => - { - options.ClientId = "Test Client Id"; - options.ClientSecret = "Test Client Secret"; + var server = CreateServer(new MicrosoftAccountOptions + { + ClientId = "Test Client Id", + ClientSecret = "Test Client Secret" }); var transaction = await server.SendAsync("http://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -107,13 +104,12 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount public async Task AuthenticatedEventCanGetRefreshToken() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("MsftTest")); - var server = CreateServer( - options => - { - options.ClientId = "Test Client Id"; - options.ClientSecret = "Test Client Secret"; - options.StateDataFormat = stateFormat; - options.BackchannelHttpHandler = new TestHttpMessageHandler + var server = CreateServer(new MicrosoftAccountOptions + { + ClientId = "Test Client Id", + ClientSecret = "Test Client Secret", + StateDataFormat = stateFormat, + BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -144,8 +140,8 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount return null; } - }; - options.Events = new OAuthEvents + }, + Events = new OAuthEvents { OnCreatingTicket = context => { @@ -153,7 +149,7 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Microsoft") }, "Microsoft")); return Task.FromResult(null); } - }; + } }); var properties = new AuthenticationProperties(); var correlationKey = ".AspNet.Correlation.Microsoft"; @@ -176,17 +172,17 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount Assert.Equal("Test Refresh Token", transaction.FindClaimValue("RefreshToken")); } - private static TestServer CreateServer(Action configureOptions) + private static TestServer CreateServer(MicrosoftAccountOptions options) { var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.AuthenticationScheme = TestExtensions.CookieAuthenticationScheme; - options.AutomaticAuthenticate = true; + AuthenticationScheme = TestExtensions.CookieAuthenticationScheme, + AutomaticAuthenticate = true }); - app.UseMicrosoftAccountAuthentication(configureOptions); + app.UseMicrosoftAccountAuthentication(options); app.Use(async (context, next) => { @@ -221,9 +217,9 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount .ConfigureServices(services => { services.AddAuthentication(); - services.Configure(options => + services.Configure(authOptions => { - options.SignInScheme = TestExtensions.CookieAuthenticationScheme; + authOptions.SignInScheme = TestExtensions.CookieAuthenticationScheme; }); }); return new TestServer(builder); diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs index 801cc71f95..0166c13e48 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs @@ -15,6 +15,7 @@ using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Xunit; @@ -31,20 +32,20 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect private const string ExpectedStateParameter = "expectedState"; [Theory, MemberData(nameof(AuthenticateCoreStateDataSet))] - public async Task AuthenticateCoreState(Action action, OpenIdConnectMessage message) + public async Task AuthenticateCoreState(OpenIdConnectOptions option, OpenIdConnectMessage message) { var handler = new OpenIdConnectHandlerForTestingAuthenticate(); - var server = CreateServer(action, UrlEncoder.Default, handler); + var server = CreateServer(option, UrlEncoder.Default, handler); await server.CreateClient().PostAsync("http://localhost", new FormUrlEncodedContent(message.Parameters.Where(pair => pair.Value != null))); } - public static TheoryData, OpenIdConnectMessage> AuthenticateCoreStateDataSet + public static TheoryData AuthenticateCoreStateDataSet { get { var formater = new AuthenticationPropertiesFormaterKeyValue(); var properties = new AuthenticationProperties(); - var dataset = new TheoryData, OpenIdConnectMessage>(); + var dataset = new TheoryData(); // expected user state is added to the message.Parameters.Items[ExpectedStateParameter] // Userstate == null @@ -52,7 +53,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect message.State = UrlEncoder.Default.Encode(formater.Protect(properties)); message.Code = Guid.NewGuid().ToString(); message.Parameters.Add(ExpectedStateParameter, null); - dataset.Add(SetStateOptions, message); + dataset.Add(GetStateOptions(), message); // Userstate != null message = new OpenIdConnectMessage(); @@ -62,15 +63,16 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect properties.Items.Add(OpenIdConnectDefaults.UserstatePropertiesKey, userstate); message.State = UrlEncoder.Default.Encode(formater.Protect(properties)); message.Parameters.Add(ExpectedStateParameter, userstate); - dataset.Add(SetStateOptions, message); + dataset.Add(GetStateOptions(), message); return dataset; } } // Setup an event to check for expected state. // The state gets set by the runtime after the 'MessageReceivedContext' - private static void SetStateOptions(OpenIdConnectOptions options) + private static OpenIdConnectOptions GetStateOptions() { + var options = new OpenIdConnectOptions(); options.AuthenticationScheme = "OpenIdConnectHandlerTest"; options.ConfigurationManager = TestUtilities.DefaultOpenIdConnectConfigurationManager; options.ClientId = Guid.NewGuid().ToString(); @@ -91,16 +93,15 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect return Task.FromResult(null); } }; + return options; } - private static TestServer CreateServer(Action configureOptions, UrlEncoder encoder, OpenIdConnectHandler handler = null) + private static TestServer CreateServer(OpenIdConnectOptions options, UrlEncoder encoder, OpenIdConnectHandler handler = null) { var builder = new WebApplicationBuilder() .Configure(app => { - var options = new OpenIdConnectOptions(); - configureOptions(options); - app.UseMiddleware(options, encoder, handler); + app.UseMiddleware(Options.Create(options), encoder, handler); app.Use(async (context, next) => { await next(); diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs index 2a91eecdbc..c73cf8f942 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs @@ -4,6 +4,7 @@ using System; using System.Text.Encodings.Web; using Microsoft.AspNet.Authentication.OpenIdConnect; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.Http; using Microsoft.Extensions.Logging; @@ -27,7 +28,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect UrlEncoder encoder, IServiceProvider services, IOptions sharedOptions, - OpenIdConnectOptions options, + IOptions options, HtmlEncoder htmlEncoder, OpenIdConnectHandler handler = null ) diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 9446be945a..992f7b9c90 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -42,12 +42,12 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect [Fact] public async Task ChallengeWillIssueHtmlFormWhenEnabled() { - var server = CreateServer(options => + var server = CreateServer(new OpenIdConnectOptions { - options.Authority = DefaultAuthority; - options.ClientId = "Test Id"; - options.Configuration = TestUtilities.DefaultOpenIdConnectConfiguration; - options.AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost; + Authority = DefaultAuthority, + ClientId = "Test Id", + Configuration = TestUtilities.DefaultOpenIdConnectConfiguration, + AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost }); var transaction = await SendAsync(server, DefaultHost + Challenge); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -61,10 +61,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect var stateDataFormat = new AuthenticationPropertiesFormaterKeyValue(); var queryValues = ExpectedQueryValues.Defaults(DefaultAuthority); queryValues.State = OpenIdConnectDefaults.AuthenticationPropertiesKey + "=" + stateDataFormat.Protect(new AuthenticationProperties()); - var server = CreateServer(options => - { - SetOptions(options, DefaultParameters(), queryValues); - }); + var server = CreateServer(GetOptions(DefaultParameters(), queryValues)); var transaction = await SendAsync(server, DefaultHost + Challenge); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -74,11 +71,11 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect [Fact] public async Task ChallengeWillSetNonceAndStateCookies() { - var server = CreateServer(options => + var server = CreateServer(new OpenIdConnectOptions { - options.Authority = DefaultAuthority; - options.ClientId = "Test Id"; - options.Configuration = TestUtilities.DefaultOpenIdConnectConfiguration; + Authority = DefaultAuthority, + ClientId = "Test Id", + Configuration = TestUtilities.DefaultOpenIdConnectConfiguration }); var transaction = await SendAsync(server, DefaultHost + Challenge); @@ -95,10 +92,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect public async Task ChallengeWillUseOptionsProperties() { var queryValues = new ExpectedQueryValues(DefaultAuthority); - var server = CreateServer(options => - { - SetOptions(options, DefaultParameters(), queryValues); - }); + var server = CreateServer(GetOptions(DefaultParameters(), queryValues)); var transaction = await SendAsync(server, DefaultHost + Challenge); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -121,7 +115,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect { RequestType = OpenIdConnectRequestType.AuthenticationRequest }; - var server = CreateServer(SetProtocolMessageOptions); + var server = CreateServer(GetProtocolMessageOptions()); var transaction = await SendAsync(server, DefaultHost + Challenge); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); queryValues.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, new string[] {}); @@ -143,14 +137,15 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect { RequestType = OpenIdConnectRequestType.LogoutRequest }; - var server = CreateServer(SetProtocolMessageOptions); + var server = CreateServer(GetProtocolMessageOptions()); var transaction = await SendAsync(server, DefaultHost + Signout); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); queryValues.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, new string[] { }); } - private static void SetProtocolMessageOptions(OpenIdConnectOptions options) + private static OpenIdConnectOptions GetProtocolMessageOptions() { + var options = new OpenIdConnectOptions(); var fakeOpenIdRequestMessage = new FakeOpenIdConnectMessage(ExpectedAuthorizeRequest, ExpectedLogoutRequest); options.AutomaticChallenge = true; options.Events = new OpenIdConnectEvents() @@ -166,7 +161,9 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect return Task.FromResult(0); } }; + return options; } + private class FakeOpenIdConnectMessage : OpenIdConnectMessage { private readonly string _authorizeRequest; @@ -207,21 +204,19 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect properties.Items.Add("item1", Guid.NewGuid().ToString()); } - var server = CreateServer(options => + var options = GetOptions(DefaultParameters(new string[] { OpenIdConnectParameterNames.State }), queryValues, stateDataFormat); + options.AutomaticChallenge = challenge.Equals(ChallengeWithOutContext); + options.Events = new OpenIdConnectEvents() { - SetOptions(options, DefaultParameters(new string[] { OpenIdConnectParameterNames.State }), queryValues, stateDataFormat); - options.AutomaticChallenge = challenge.Equals(ChallengeWithOutContext); - options.Events = new OpenIdConnectEvents() + OnRedirectToAuthenticationEndpoint = context => { - OnRedirectToAuthenticationEndpoint = context => - { - context.ProtocolMessage.State = userState; - context.ProtocolMessage.RedirectUri = queryValues.RedirectUri; - return Task.FromResult(null); - } + context.ProtocolMessage.State = userState; + context.ProtocolMessage.RedirectUri = queryValues.RedirectUri; + return Task.FromResult(null); + } - }; - }, null, properties); + }; + var server = CreateServer(options, null, properties); var transaction = await SendAsync(server, DefaultHost + challenge); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -260,29 +255,28 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect { var queryValues = new ExpectedQueryValues(DefaultAuthority); var queryValuesSetInEvent = new ExpectedQueryValues(DefaultAuthority); - var server = CreateServer(options => + var options = GetOptions(DefaultParameters(), queryValues); + options.Events = new OpenIdConnectEvents() { - SetOptions(options, DefaultParameters(), queryValues); - options.Events = new OpenIdConnectEvents() + OnRedirectToAuthenticationEndpoint = context => { - OnRedirectToAuthenticationEndpoint = context => - { - context.ProtocolMessage.ClientId = queryValuesSetInEvent.ClientId; - context.ProtocolMessage.RedirectUri = queryValuesSetInEvent.RedirectUri; - context.ProtocolMessage.Resource = queryValuesSetInEvent.Resource; - context.ProtocolMessage.Scope = queryValuesSetInEvent.Scope; - return Task.FromResult(null); - } - }; - }); + context.ProtocolMessage.ClientId = queryValuesSetInEvent.ClientId; + context.ProtocolMessage.RedirectUri = queryValuesSetInEvent.RedirectUri; + context.ProtocolMessage.Resource = queryValuesSetInEvent.Resource; + context.ProtocolMessage.Scope = queryValuesSetInEvent.Scope; + return Task.FromResult(null); + } + }; + var server = CreateServer(options); var transaction = await SendAsync(server, DefaultHost + Challenge); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); queryValuesSetInEvent.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, DefaultParameters()); } - private void SetOptions(OpenIdConnectOptions options, List parameters, ExpectedQueryValues queryValues, ISecureDataFormat secureDataFormat = null) + private OpenIdConnectOptions GetOptions(List parameters, ExpectedQueryValues queryValues, ISecureDataFormat secureDataFormat = null) { + var options = new OpenIdConnectOptions(); foreach (var param in parameters) { if (param.Equals(OpenIdConnectParameterNames.ClientId)) @@ -301,6 +295,8 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect options.Authority = queryValues.Authority; options.Configuration = queryValues.Configuration; options.StateDataFormat = secureDataFormat ?? new AuthenticationPropertiesFormaterKeyValue(); + + return options; } private List DefaultParameters(string[] additionalParams = null) @@ -333,11 +329,11 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect public async Task SignOutWithDefaultRedirectUri() { var configuration = TestUtilities.DefaultOpenIdConnectConfiguration; - var server = CreateServer(options => + var server = CreateServer(new OpenIdConnectOptions { - options.Authority = DefaultAuthority; - options.ClientId = "Test Id"; - options.Configuration = configuration; + Authority = DefaultAuthority, + ClientId = "Test Id", + Configuration = configuration }); var transaction = await SendAsync(server, DefaultHost + Signout); @@ -349,12 +345,12 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect public async Task SignOutWithCustomRedirectUri() { var configuration = TestUtilities.DefaultOpenIdConnectConfiguration; - var server = CreateServer(options => + var server = CreateServer(new OpenIdConnectOptions { - options.Authority = DefaultAuthority; - options.ClientId = "Test Id"; - options.Configuration = configuration; - options.PostLogoutRedirectUri = "https://example.com/logout"; + Authority = DefaultAuthority, + ClientId = "Test Id", + Configuration = configuration, + PostLogoutRedirectUri = "https://example.com/logout" }); var transaction = await SendAsync(server, DefaultHost + Signout); @@ -366,12 +362,12 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properites() { var configuration = TestUtilities.DefaultOpenIdConnectConfiguration; - var server = CreateServer(options => + var server = CreateServer(new OpenIdConnectOptions { - options.Authority = DefaultAuthority; - options.ClientId = "Test Id"; - options.Configuration = configuration; - options.PostLogoutRedirectUri = "https://example.com/logout"; + Authority = DefaultAuthority, + ClientId = "Test Id", + Configuration = configuration, + PostLogoutRedirectUri = "https://example.com/logout" }); var transaction = await SendAsync(server, "https://example.com/signout_with_specific_redirect_uri"); @@ -379,16 +375,16 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect Assert.Contains(UrlEncoder.Default.Encode("http://www.example.com/specific_redirect_uri"), transaction.Response.Headers.Location.AbsoluteUri); } - private static TestServer CreateServer(Action configureOptions, Func handler = null, AuthenticationProperties properties = null) + private static TestServer CreateServer(OpenIdConnectOptions options, Func handler = null, AuthenticationProperties properties = null) { var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme; + AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme }); - app.UseOpenIdConnectAuthentication(configureOptions); + app.UseOpenIdConnectAuthentication(options); app.Use(async (context, next) => { var req = context.Request; @@ -434,9 +430,9 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect .ConfigureServices(services => { services.AddAuthentication(); - services.Configure(options => + services.Configure(authOptions => { - options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + authOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; }); }); return new TestServer(builder); diff --git a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs index db77d7f5ff..2d00d617de 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs @@ -20,19 +20,19 @@ namespace Microsoft.AspNet.Authentication.Twitter [Fact] public async Task ChallengeWillTriggerApplyRedirectEvent() { - var server = CreateServer(options => + var server = CreateServer(new TwitterOptions { - options.ConsumerKey = "Test Consumer Key"; - options.ConsumerSecret = "Test Consumer Secret"; - options.Events = new TwitterEvents + ConsumerKey = "Test Consumer Key", + ConsumerSecret = "Test Consumer Secret", + Events = new TwitterEvents { OnRedirectToAuthorizationEndpoint = context => { context.Response.Redirect(context.RedirectUri + "&custom=test"); return Task.FromResult(0); } - }; - options.BackchannelHttpHandler = new TestHttpMessageHandler + }, + BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -48,7 +48,7 @@ namespace Microsoft.AspNet.Authentication.Twitter } return null; } - }; + } }, context => { @@ -65,10 +65,10 @@ namespace Microsoft.AspNet.Authentication.Twitter [Fact] public async Task BadSignInWillThrow() { - var server = CreateServer(options => + var server = CreateServer(new TwitterOptions { - options.ConsumerKey = "Test Consumer Key"; - options.ConsumerSecret = "Test Consumer Secret"; + ConsumerKey = "Test Consumer Key", + ConsumerSecret = "Test Consumer Secret" }); // Send a bogus sign in @@ -79,10 +79,10 @@ namespace Microsoft.AspNet.Authentication.Twitter [Fact] public async Task SignInThrows() { - var server = CreateServer(options => + var server = CreateServer(new TwitterOptions { - options.ConsumerKey = "Test Consumer Key"; - options.ConsumerSecret = "Test Consumer Secret"; + ConsumerKey = "Test Consumer Key", + ConsumerSecret = "Test Consumer Secret" }); var transaction = await server.SendAsync("https://example.com/signIn"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -91,10 +91,10 @@ namespace Microsoft.AspNet.Authentication.Twitter [Fact] public async Task SignOutThrows() { - var server = CreateServer(options => + var server = CreateServer(new TwitterOptions { - options.ConsumerKey = "Test Consumer Key"; - options.ConsumerSecret = "Test Consumer Secret"; + ConsumerKey = "Test Consumer Key", + ConsumerSecret = "Test Consumer Secret" }); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -103,10 +103,10 @@ namespace Microsoft.AspNet.Authentication.Twitter [Fact] public async Task ForbidThrows() { - var server = CreateServer(options => + var server = CreateServer(new TwitterOptions { - options.ConsumerKey = "Test Consumer Key"; - options.ConsumerSecret = "Test Consumer Secret"; + ConsumerKey = "Test Consumer Key", + ConsumerSecret = "Test Consumer Secret" }); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -116,11 +116,11 @@ namespace Microsoft.AspNet.Authentication.Twitter [Fact] public async Task ChallengeWillTriggerRedirection() { - var server = CreateServer(options => - { - options.ConsumerKey = "Test Consumer Key"; - options.ConsumerSecret = "Test Consumer Secret"; - options.BackchannelHttpHandler = new TestHttpMessageHandler + var server = CreateServer(new TwitterOptions + { + ConsumerKey = "Test Consumer Key", + ConsumerSecret = "Test Consumer Secret", + BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -136,7 +136,7 @@ namespace Microsoft.AspNet.Authentication.Twitter } return null; } - }; + } }, context => { @@ -150,16 +150,16 @@ namespace Microsoft.AspNet.Authentication.Twitter Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); } - private static TestServer CreateServer(Action configure, Func handler = null) + private static TestServer CreateServer(TwitterOptions options, Func handler = null) { var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => + app.UseCookieAuthentication(new CookieAuthenticationOptions { - options.AuthenticationScheme = "External"; + AuthenticationScheme = "External" }); - app.UseTwitterAuthentication(configure); + app.UseTwitterAuthentication(options); app.Use(async (context, next) => { var req = context.Request; @@ -185,9 +185,9 @@ namespace Microsoft.AspNet.Authentication.Twitter .ConfigureServices(services => { services.AddAuthentication(); - services.Configure(options => + services.Configure(authOptions => { - options.SignInScheme = "External"; + authOptions.SignInScheme = "External"; }); }); return new TestServer(builder); diff --git a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs index f2b28f6aba..902bf17cea 100644 --- a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -19,6 +19,7 @@ namespace Microsoft.AspNet.Authorization.Test var services = new ServiceCollection(); services.AddAuthorization(); services.AddLogging(); + services.AddOptions(); if (setupServices != null) { setupServices(services); diff --git a/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs index 4b798c5613..d0639e627d 100644 --- a/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs @@ -36,7 +36,10 @@ namespace Microsoft.AspNet.CookiePolicy.Test public async Task SecureAlwaysSetsSecure() { await RunTest("/secureAlways", - options => options.Secure = SecurePolicy.Always, + new CookiePolicyOptions + { + Secure = SecurePolicy.Always + }, SecureCookieAppends, new RequestTest("http://example.com/secureAlways", transaction => @@ -53,7 +56,10 @@ namespace Microsoft.AspNet.CookiePolicy.Test public async Task SecureNoneLeavesSecureUnchanged() { await RunTest("/secureNone", - options => options.Secure = SecurePolicy.None, + new CookiePolicyOptions + { + Secure = SecurePolicy.None + }, SecureCookieAppends, new RequestTest("http://example.com/secureNone", transaction => @@ -71,7 +77,10 @@ namespace Microsoft.AspNet.CookiePolicy.Test public async Task SecureSameUsesRequest() { await RunTest("/secureSame", - options => options.Secure = SecurePolicy.SameAsRequest, + new CookiePolicyOptions + { + Secure = SecurePolicy.SameAsRequest + }, SecureCookieAppends, new RequestTest("http://example.com/secureSame", transaction => @@ -97,7 +106,10 @@ namespace Microsoft.AspNet.CookiePolicy.Test public async Task HttpOnlyAlwaysSetsItAlways() { await RunTest("/httpOnlyAlways", - options => options.HttpOnly = HttpOnlyPolicy.Always, + new CookiePolicyOptions + { + HttpOnly = HttpOnlyPolicy.Always + }, HttpCookieAppends, new RequestTest("http://example.com/httpOnlyAlways", transaction => @@ -114,7 +126,10 @@ namespace Microsoft.AspNet.CookiePolicy.Test public async Task HttpOnlyNoneLeavesItAlone() { await RunTest("/httpOnlyNone", - options => options.HttpOnly = HttpOnlyPolicy.None, + new CookiePolicyOptions + { + HttpOnly = HttpOnlyPolicy.None + }, HttpCookieAppends, new RequestTest("http://example.com/httpOnlyNone", transaction => @@ -133,7 +148,10 @@ namespace Microsoft.AspNet.CookiePolicy.Test var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookiePolicy(options => options.OnAppendCookie = ctx => ctx.CookieName = ctx.CookieValue = "Hao"); + app.UseCookiePolicy(new CookiePolicyOptions + { + OnAppendCookie = ctx => ctx.CookieName = ctx.CookieValue = "Hao" + }); app.Run(context => { context.Response.Cookies.Append("A", "A"); @@ -160,7 +178,10 @@ namespace Microsoft.AspNet.CookiePolicy.Test var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookiePolicy(options => options.OnDeleteCookie = ctx => ctx.CookieName = "A"); + app.UseCookiePolicy(new CookiePolicyOptions + { + OnDeleteCookie = ctx => ctx.CookieName = "A" + }); app.Run(context => { context.Response.Cookies.Delete("A"); @@ -190,7 +211,10 @@ namespace Microsoft.AspNet.CookiePolicy.Test context.Features.Set(new TestCookieFeature()); return next(context); }); - app.UseCookiePolicy(options => options.OnDeleteCookie = ctx => ctx.CookieName = "A"); + app.UseCookiePolicy(new CookiePolicyOptions + { + OnDeleteCookie = ctx => ctx.CookieName = "A" + }); app.Run(context => { Assert.Throws(() => context.Response.Cookies.Delete("A")); @@ -254,7 +278,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test private async Task RunTest( string path, - Action configureCookiePolicy, + CookiePolicyOptions cookiePolicy, RequestDelegate configureSetup, params RequestTest[] tests) { @@ -263,7 +287,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test { app.Map(path, map => { - map.UseCookiePolicy(configureCookiePolicy); + map.UseCookiePolicy(cookiePolicy); map.Run(configureSetup); }); }); diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index 9ef81bc7f5..c7645a2874 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -38,7 +38,7 @@ namespace Microsoft.Owin.Security.Interop { app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - app.UseCookieAuthentication(new CookieAuthenticationOptions + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions { TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)) }); @@ -55,7 +55,10 @@ namespace Microsoft.Owin.Security.Interop var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => options.DataProtectionProvider = dataProtection); + app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions + { + DataProtectionProvider = dataProtection + }); app.Run(async context => { var result = await context.Authentication.AuthenticateAsync("Cookies"); @@ -88,7 +91,10 @@ namespace Microsoft.Owin.Security.Interop var builder = new WebApplicationBuilder() .Configure(app => { - app.UseCookieAuthentication(options => options.DataProtectionProvider = dataProtection); + app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions + { + DataProtectionProvider = dataProtection + }); app.Run(context => context.Authentication.SignInAsync("Cookies", user)); }) .ConfigureServices(services => services.AddAuthentication()); @@ -100,7 +106,7 @@ namespace Microsoft.Owin.Security.Interop { app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - app.UseCookieAuthentication(new CookieAuthenticationOptions + app.UseCookieAuthentication(new Owin.Security.Cookies.CookieAuthenticationOptions { TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)) }); From 197a2aa3fa14bf97f0b8e89ba85acf87dd08cd4b Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 12 Jan 2016 15:41:35 -0800 Subject: [PATCH 444/900] React to Hosting API change. --- samples/CookieSample/Startup.cs | 1 + samples/CookieSessionSample/Startup.cs | 1 + samples/JwtBearerSample/Startup.cs | 1 + samples/OpenIdConnectSample/Startup.cs | 1 + samples/SocialSample/Properties/launchSettings.json | 1 + samples/SocialSample/Startup.cs | 2 +- 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index b3327ac81c..64376e26e9 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -46,6 +46,7 @@ namespace CookieSample { var application = new WebApplicationBuilder() .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 6160f56b95..d9504d942a 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -56,6 +56,7 @@ namespace CookieSessionSample { var application = new WebApplicationBuilder() .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index db91629bcf..abfd83735f 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -116,6 +116,7 @@ namespace JwtBearerSample { var application = new WebApplicationBuilder() .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index bf4a4bc759..50452d1730 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -69,6 +69,7 @@ namespace OpenIdConnectSample { var application = new WebApplicationBuilder() .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/SocialSample/Properties/launchSettings.json b/samples/SocialSample/Properties/launchSettings.json index b10006b86c..15c91efdcb 100644 --- a/samples/SocialSample/Properties/launchSettings.json +++ b/samples/SocialSample/Properties/launchSettings.json @@ -10,6 +10,7 @@ "profiles": { "IIS Express": { "commandName": "IISExpress", + "launchBrowser": true, "environmentVariables": { "ASPNET_ENV": "Development" } diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 65067ada8e..e466c019d4 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -6,7 +6,6 @@ using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Authentication.Cookies; -using Microsoft.AspNet.Authentication.Facebook; using Microsoft.AspNet.Authentication.Google; using Microsoft.AspNet.Authentication.MicrosoftAccount; using Microsoft.AspNet.Authentication.OAuth; @@ -328,6 +327,7 @@ namespace CookieSample { var application = new WebApplicationBuilder() .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseIISPlatformHandlerUrl() .UseStartup() .Build(); From 2e1a8b31cd0c520ffd69ba7818313ae9a9f688a4 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 15 Jan 2016 14:47:33 -0800 Subject: [PATCH 445/900] Rename Delegate => AssertionRequirement And moar sugar... --- .../AuthorizationPolicyBuilder.cs | 13 +++++--- .../Infrastructure/AssertionRequirement.cs | 33 +++++++++++++++++++ .../Infrastructure/DelegateRequirement.cs | 22 ------------- .../DefaultAuthorizationServiceTests.cs | 4 +-- 4 files changed, 44 insertions(+), 28 deletions(-) create mode 100644 src/Microsoft.AspNet.Authorization/Infrastructure/AssertionRequirement.cs delete mode 100644 src/Microsoft.AspNet.Authorization/Infrastructure/DelegateRequirement.cs diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationPolicyBuilder.cs b/src/Microsoft.AspNet.Authorization/AuthorizationPolicyBuilder.cs index a0378f9c15..053ff49605 100644 --- a/src/Microsoft.AspNet.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNet.Authorization/AuthorizationPolicyBuilder.cs @@ -123,14 +123,19 @@ namespace Microsoft.AspNet.Authorization return this; } - public AuthorizationPolicyBuilder RequireDelegate(Action handler) + /// + /// Requires that this Function returns true + /// + /// Function that must return true + /// + public AuthorizationPolicyBuilder RequireAssertion(Func assert) { - if (handler == null) + if (assert == null) { - throw new ArgumentNullException(nameof(handler)); + throw new ArgumentNullException(nameof(assert)); } - Requirements.Add(new DelegateRequirement(handler)); + Requirements.Add(new AssertionRequirement(assert)); return this; } diff --git a/src/Microsoft.AspNet.Authorization/Infrastructure/AssertionRequirement.cs b/src/Microsoft.AspNet.Authorization/Infrastructure/AssertionRequirement.cs new file mode 100644 index 0000000000..b0eb44cf9b --- /dev/null +++ b/src/Microsoft.AspNet.Authorization/Infrastructure/AssertionRequirement.cs @@ -0,0 +1,33 @@ +// 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.Authorization.Infrastructure +{ + public class AssertionRequirement : AuthorizationHandler, IAuthorizationRequirement + { + /// + /// Function that is called to handle this requirement + /// + public Func Handler { get; } + + public AssertionRequirement(Func assert) + { + if (assert == null) + { + throw new ArgumentNullException(nameof(assert)); + } + + Handler = assert; + } + + protected override void Handle(AuthorizationContext context, AssertionRequirement requirement) + { + if (Handler(context)) + { + context.Succeed(requirement); + } + } + } +} diff --git a/src/Microsoft.AspNet.Authorization/Infrastructure/DelegateRequirement.cs b/src/Microsoft.AspNet.Authorization/Infrastructure/DelegateRequirement.cs deleted file mode 100644 index 834060bb64..0000000000 --- a/src/Microsoft.AspNet.Authorization/Infrastructure/DelegateRequirement.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 System; - -namespace Microsoft.AspNet.Authorization.Infrastructure -{ - public class DelegateRequirement : AuthorizationHandler, IAuthorizationRequirement - { - public Action Handler { get; } - - public DelegateRequirement(Action handleMe) - { - Handler = handleMe; - } - - protected override void Handle(AuthorizationContext context, DelegateRequirement requirement) - { - Handler(context, requirement); - } - } -} diff --git a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs index 902bf17cea..fc4377aebe 100644 --- a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -905,13 +905,13 @@ namespace Microsoft.AspNet.Authorization.Test } [Fact] - public async Task CanAuthorizeWithDelegateRequirement() + public async Task CanAuthorizeWithAssertionRequirement() { var authorizationService = BuildAuthorizationService(services => { services.AddAuthorization(options => { - options.AddPolicy("Basic", policy => policy.RequireDelegate((context, req) => context.Succeed(req))); + options.AddPolicy("Basic", policy => policy.RequireAssertion(context => true)); }); }); var user = new ClaimsPrincipal(); From 10fdfcc5c8b9703801cda59618e84c467bc5d30e Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Tue, 12 Jan 2016 11:05:17 -0800 Subject: [PATCH 446/900] Build with dotnet --- .gitattributes | 1 + .gitignore | 2 + .travis.yml | 8 ++- appveyor.yml | 2 +- build.cmd | 68 +++++++++---------- build.sh | 42 ++++++------ makefile.shade | 7 -- .../project.json | 25 +++++-- .../project.json | 22 ++++-- .../project.json | 27 ++++++-- .../project.json | 17 +++-- 11 files changed, 134 insertions(+), 87 deletions(-) delete mode 100644 makefile.shade diff --git a/.gitattributes b/.gitattributes index bdaa5ba982..97b827b758 100644 --- a/.gitattributes +++ b/.gitattributes @@ -48,3 +48,4 @@ *.fsproj text=auto *.dbproj text=auto *.sln text=auto eol=crlf +*.sh eol=lf diff --git a/.gitignore b/.gitignore index ac82da7568..a2eb01c895 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ nuget.exe *.ipch *.sln.ide project.lock.json +.build/ +.testPublish/ diff --git a/.travis.yml b/.travis.yml index c0befaffcf..bf811dc26a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,11 @@ addons: - libssl-dev - libunwind8 - zlib1g -env: - - KOREBUILD_DNU_RESTORE_CORECLR=true KOREBUILD_TEST_DNXCORE=true mono: - 4.0.5 +os: + - linux + - osx +osx_image: xcode7.1 script: - - ./build.sh --quiet verify + - ./build.sh verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 636a7618d3..3fab83e134 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ init: - git config --global core.autocrlf true build_script: - - build.cmd --quiet verify + - build.cmd verify clone_depth: 1 test: off deploy: off \ No newline at end of file diff --git a/build.cmd b/build.cmd index 553e3929a0..ebb619e737 100644 --- a/build.cmd +++ b/build.cmd @@ -1,40 +1,40 @@ -@echo off -cd %~dp0 - +@ECHO off SETLOCAL + +SET REPO_FOLDER=%~dp0 +CD %REPO_FOLDER% + +SET BUILD_FOLDER=.build +SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet +SET KOREBUILD_VERSION= + +SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe SET NUGET_VERSION=latest SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe -SET BUILDCMD_KOREBUILD_VERSION= -SET BUILDCMD_DNX_VERSION= -IF EXIST %CACHED_NUGET% goto copynuget -echo Downloading latest version of NuGet.exe... -IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet -@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" - -:copynuget -IF EXIST .nuget\nuget.exe goto restore -md .nuget -copy %CACHED_NUGET% .nuget\nuget.exe > nul - -:restore -IF EXIST packages\Sake goto getdnx -IF "%BUILDCMD_KOREBUILD_VERSION%"=="" ( - .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre -) ELSE ( - .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre -) -.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages - -:getdnx -IF "%BUILDCMD_DNX_VERSION%"=="" ( - SET BUILDCMD_DNX_VERSION=latest -) -IF "%SKIP_DNX_INSTALL%"=="" ( - CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default - CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default -) ELSE ( - CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 +IF NOT EXIST %BUILD_FOLDER% ( + md %BUILD_FOLDER% ) -packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* +IF NOT EXIST %NUGET_PATH% ( + IF NOT EXIST %CACHED_NUGET% ( + echo Downloading latest version of NuGet.exe... + IF NOT EXIST %LocalAppData%\NuGet ( + md %LocalAppData%\NuGet + ) + @powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" + ) + + copy %CACHED_NUGET% %NUGET_PATH% > nul +) + +IF NOT EXIST %KOREBUILD_FOLDER% ( + SET KOREBUILD_DOWNLOAD_ARGS= + IF NOT "%KOREBUILD_VERSION%"=="" ( + SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% + ) + + %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS% +) + +"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %* diff --git a/build.sh b/build.sh index da4e3fcd1c..263fb667a8 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +buildFolder=.build +koreBuildFolder=$buildFolder/KoreBuild-dotnet + +nugetPath=$buildFolder/nuget.exe + if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild else @@ -11,33 +16,30 @@ else fi mkdir -p $cachedir nugetVersion=latest -cachePath=$cachedir/nuget.$nugetVersion.exe +cacheNuget=$cachedir/nuget.$nugetVersion.exe -url=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe +nugetUrl=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe -if test ! -f $cachePath; then - wget -O $cachePath $url 2>/dev/null || curl -o $cachePath --location $url /dev/null +if test ! -d $buildFolder; then + mkdir $buildFolder fi -if test ! -e .nuget; then - mkdir .nuget - cp $cachePath .nuget/nuget.exe +if test ! -f $nugetPath; then + if test ! -f $cacheNuget; then + wget -O $cacheNuget $nugetUrl 2>/dev/null || curl -o $cacheNuget --location $nugetUrl /dev/null + fi + + cp $cacheNuget $nugetPath fi -if test ! -d packages/Sake; then - mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages +if test ! -d $koreBuildFolder; then + mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre + chmod +x $koreBuildFolder/build/KoreBuild.sh fi -if ! type dnvm > /dev/null 2>&1; then - source packages/KoreBuild/build/dnvm.sh +makeFile=makefile.shade +if [ ! -e $makeFile ]; then + makeFile=$koreBuildFolder/build/makefile.shade fi -if ! type dnx > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then - dnvm install latest -runtime coreclr -alias default - dnvm install default -runtime mono -alias default -else - dnvm use default -runtime mono -fi - -mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" +./$koreBuildFolder/build/KoreBuild.sh -n $nugetPath -m $makeFile "$@" diff --git a/makefile.shade b/makefile.shade deleted file mode 100644 index 562494d144..0000000000 --- a/makefile.shade +++ /dev/null @@ -1,7 +0,0 @@ - -var VERSION='0.1' -var FULL_VERSION='0.1' -var AUTHORS='Microsoft Open Technologies, Inc.' - -use-standard-lifecycle -k-standard-goals diff --git a/test/Microsoft.AspNet.Authentication.Test/project.json b/test/Microsoft.AspNet.Authentication.Test/project.json index af0759d42b..f9a5e1f3ee 100644 --- a/test/Microsoft.AspNet.Authentication.Test/project.json +++ b/test/Microsoft.AspNet.Authentication.Test/project.json @@ -12,13 +12,26 @@ "Microsoft.AspNet.Authentication.Twitter": "1.0.0-*", "Microsoft.AspNet.TestHost": "1.0.0-*", "Microsoft.AspNet.Testing": "1.0.0-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "commands": { - "test": "xunit.runner.aspnet" + "xunit": "2.1.0" }, "frameworks": { - "dnx451": { }, - "dnxcore50": { } + "dnx451": { + "frameworkAssemblies": { + "System.Runtime": "", + "System.Threading.Tasks": "" + }, + "dependencies": { + "xunit.runner.console": "2.1.0" + } + }, + "dnxcore50": { + "dependencies": { + "xunit.runner.aspnet": "2.0.0-aspnet-*" + } + } + }, + "testRunner": "xunit", + "commands": { + "test": "xunit.runner.aspnet" } } diff --git a/test/Microsoft.AspNet.Authorization.Test/project.json b/test/Microsoft.AspNet.Authorization.Test/project.json index 7bbe7ed75b..1fa1347e16 100644 --- a/test/Microsoft.AspNet.Authorization.Test/project.json +++ b/test/Microsoft.AspNet.Authorization.Test/project.json @@ -5,15 +5,27 @@ "dependencies": { "Microsoft.AspNet.Authorization": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "commands": { - "test": "xunit.runner.aspnet" + "Microsoft.Extensions.Logging": "1.0.0-*", + "xunit": "2.1.0" }, "frameworks": { "dnx451": { + "frameworkAssemblies": { + "System.Runtime": "", + "System.Threading.Tasks": "" + }, + "dependencies": { + "xunit.runner.console": "2.1.0" + } }, - "dnxcore50": { + "dnxcore50": { + "dependencies": { + "xunit.runner.aspnet": "2.0.0-aspnet-*" + } } + }, + "testRunner": "xunit", + "commands": { + "test": "xunit.runner.aspnet" } } diff --git a/test/Microsoft.AspNet.CookiePolicy.Test/project.json b/test/Microsoft.AspNet.CookiePolicy.Test/project.json index 509e749160..66d7c743f4 100644 --- a/test/Microsoft.AspNet.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNet.CookiePolicy.Test/project.json @@ -6,13 +6,28 @@ "Microsoft.AspNet.CookiePolicy": "1.0.0-*", "Microsoft.AspNet.TestHost": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "commands": { - "test": "xunit.runner.aspnet" + "xunit": "2.1.0" }, "frameworks": { - "dnx451": { }, - "dnxcore50": { } + "dnx451": { + "frameworkAssemblies": { + "System.Runtime": "", + "System.Threading.Tasks": "", + "System.Xml.Linq": "" + }, + "dependencies": { + "xunit.runner.console": "2.1.0" + } + }, + "dnxcore50": { + "dependencies": { + "xunit.runner.aspnet": "2.0.0-aspnet-*" + } + } + }, + "testRunner": "xunit", + "commands": { + "test": "xunit.runner.aspnet" } + } diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index 585c87aa16..e4af613d9e 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -8,12 +8,19 @@ "Microsoft.Owin.Security.Cookies": "3.0.1", "Microsoft.Owin.Security.Interop": "1.0.0-*", "Microsoft.Owin.Testing": "3.0.1", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "commands": { - "test": "xunit.runner.aspnet" + "xunit": "2.1.0", + "xunit.runner.console": "2.1.0" }, "frameworks": { - "dnx451": { } + "dnx451": { + "frameworkAssemblies": { + "System.Runtime": "", + "System.Threading.Tasks": "" + } + } + }, + "testRunner": "xunit", + "commands": { + "test": "xunit.runner.aspnet" } } From 0f9875df0a43f1a84fbf113341cac636d547c283 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sun, 17 Jan 2016 17:09:38 -0800 Subject: [PATCH 447/900] Reacting to hosting rename --- .gitignore | 1 + samples/CookieSample/Startup.cs | 6 ++--- samples/CookieSessionSample/Startup.cs | 6 ++--- samples/JwtBearerSample/Startup.cs | 6 ++--- samples/OpenIdConnectSample/Startup.cs | 6 ++--- samples/SocialSample/Startup.cs | 6 ++--- .../Cookies/CookieMiddlewareTests.cs | 26 +++++++++---------- .../Facebook/FacebookMiddlewareTests.cs | 2 +- .../Google/GoogleMiddlewareTests.cs | 2 +- .../JwtBearer/JwtBearerMiddlewareTests.cs | 2 +- .../MicrosoftAccountMiddlewareTests.cs | 2 +- .../OpenIdConnectHandlerTests.cs | 2 +- .../OpenIdConnectMiddlewareTests.cs | 2 +- .../Twitter/TwitterMiddlewareTests.cs | 2 +- .../CookiePolicyTests.cs | 8 +++--- .../CookieInteropTests.cs | 4 +-- 16 files changed, 42 insertions(+), 41 deletions(-) diff --git a/.gitignore b/.gitignore index a2eb01c895..0f91ad1208 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ nuget.exe project.lock.json .build/ .testPublish/ +/.vs/ diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 64376e26e9..a1a5d5bbc1 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -44,13 +44,13 @@ namespace CookieSample public static void Main(string[] args) { - var application = new WebApplicationBuilder() - .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + var host = new WebHostBuilder() + .UseDefaultConfiguration(args) .UseIISPlatformHandlerUrl() .UseStartup() .Build(); - application.Run(); + host.Run(); } } } \ No newline at end of file diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index d9504d942a..6c6c6f3606 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -54,13 +54,13 @@ namespace CookieSessionSample public static void Main(string[] args) { - var application = new WebApplicationBuilder() - .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + var host = new WebHostBuilder() + .UseDefaultConfiguration(args) .UseIISPlatformHandlerUrl() .UseStartup() .Build(); - application.Run(); + host.Run(); } } } \ No newline at end of file diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index abfd83735f..4ef2f6610e 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -114,13 +114,13 @@ namespace JwtBearerSample // Entry point for the application. public static void Main(string[] args) { - var application = new WebApplicationBuilder() - .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + var host = new WebHostBuilder() + .UseDefaultConfiguration(args) .UseIISPlatformHandlerUrl() .UseStartup() .Build(); - application.Run(); + host.Run(); } } } diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 50452d1730..1d40a0a92f 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -67,13 +67,13 @@ namespace OpenIdConnectSample public static void Main(string[] args) { - var application = new WebApplicationBuilder() - .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + var host = new WebHostBuilder() + .UseDefaultConfiguration(args) .UseIISPlatformHandlerUrl() .UseStartup() .Build(); - application.Run(); + host.Run(); } } } diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index e466c019d4..2641725df9 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -325,13 +325,13 @@ namespace CookieSample public static void Main(string[] args) { - var application = new WebApplicationBuilder() - .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + var host = new WebHostBuilder() + .UseDefaultConfiguration(args) .UseIISPlatformHandlerUrl() .UseStartup() .Build(); - application.Run(); + host.Run(); } } } diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 7827566a9f..e6fc0d709b 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -854,7 +854,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWillNotAffectChallenge() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -878,7 +878,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task ChallengeDoesNotSet401OnUnauthorized() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(); @@ -897,7 +897,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task UseCookieWithInstanceDoesntUseSharedOptions() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -919,7 +919,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -940,7 +940,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWillNotAffectSignInRedirectToReturnUrl() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -965,7 +965,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -985,7 +985,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWillNotAffectSignOutRedirectToReturnUrl() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -1009,7 +1009,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task MapWillNotAffectAccessDenied() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -1031,7 +1031,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task NestedMapWillNotAffectLogin() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => app.Map("/base", map => { @@ -1055,7 +1055,7 @@ namespace Microsoft.AspNet.Authentication.Cookies [Fact] public async Task NestedMapWillNotAffectAccessDenied() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => app.Map("/base", map => { @@ -1080,7 +1080,7 @@ namespace Microsoft.AspNet.Authentication.Cookies { var dp = new NoOpDataProtector(); - var builder1 = new WebApplicationBuilder() + var builder1 = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -1099,7 +1099,7 @@ namespace Microsoft.AspNet.Authentication.Cookies var transaction = await SendAsync(server1, "http://example.com/stuff"); Assert.NotNull(transaction.SetCookie); - var builder2 = new WebApplicationBuilder() + var builder2 = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -1162,7 +1162,7 @@ namespace Microsoft.AspNet.Authentication.Cookies private static TestServer CreateServer(CookieAuthenticationOptions options, Func testpath = null, Uri baseAddress = null, ClaimsTransformationOptions claimsTransform = null) { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(options); diff --git a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs index 95dcb2e5b7..764b63a15a 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -229,7 +229,7 @@ namespace Microsoft.AspNet.Authentication.Facebook private static TestServer CreateServer(Action configure, Action configureServices, Func handler) { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { if (configure != null) diff --git a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs index 6a6f028282..29cc78403c 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -757,7 +757,7 @@ namespace Microsoft.AspNet.Authentication.Google private static TestServer CreateServer(GoogleOptions options, Func testpath = null) { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions diff --git a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 2732d0caaa..6ff7751a93 100644 --- a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -535,7 +535,7 @@ namespace Microsoft.AspNet.Authentication.JwtBearer private static TestServer CreateServer(JwtBearerOptions options, Func handler = null) { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { if (options != null) diff --git a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index 29f6e0edcc..6d41f5a7a6 100644 --- a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -174,7 +174,7 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount private static TestServer CreateServer(MicrosoftAccountOptions options) { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs index 0166c13e48..fa49055391 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs @@ -98,7 +98,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect private static TestServer CreateServer(OpenIdConnectOptions options, UrlEncoder encoder, OpenIdConnectHandler handler = null) { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseMiddleware(Options.Create(options), encoder, handler); diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 992f7b9c90..6661eeb542 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -377,7 +377,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect private static TestServer CreateServer(OpenIdConnectOptions options, Func handler = null, AuthenticationProperties properties = null) { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions diff --git a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs index 2d00d617de..173de5a82b 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs @@ -152,7 +152,7 @@ namespace Microsoft.AspNet.Authentication.Twitter private static TestServer CreateServer(TwitterOptions options, Func handler = null) { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new CookieAuthenticationOptions diff --git a/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs index d0639e627d..f8529e0191 100644 --- a/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs @@ -145,7 +145,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test [Fact] public async Task CookiePolicyCanHijackAppend() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookiePolicy(new CookiePolicyOptions @@ -175,7 +175,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test [Fact] public async Task CookiePolicyCanHijackDelete() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookiePolicy(new CookiePolicyOptions @@ -203,7 +203,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test [Fact] public async Task CookiePolicyCallsCookieFeature() { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.Use(next => context => @@ -282,7 +282,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test RequestDelegate configureSetup, params RequestTest[] tests) { - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.Map(path, map => diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index c7645a2874..996e181607 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -52,7 +52,7 @@ namespace Microsoft.Owin.Security.Interop var transaction = await SendAsync(interopServer, "http://example.com"); - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions @@ -88,7 +88,7 @@ namespace Microsoft.Owin.Security.Interop "Microsoft.AspNet.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type CookieAuthenticationDefaults.AuthenticationType, "v2"); - var builder = new WebApplicationBuilder() + var builder = new WebHostBuilder() .Configure(app => { app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions From de2cb12f5c767a3f08c6081163732324876cd96c Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 21 Jan 2016 17:14:15 -0800 Subject: [PATCH 448/900] OIDC cleanup --- samples/OpenIdConnectSample/Startup.cs | 3 +- .../OpenIdConnectHandler.cs | 69 ++++++---- .../OpenIdConnectOptions.cs | 19 +-- .../RemoteAuthenticationOptions.cs | 4 +- ...nIdConnectHandlerForTestingAuthenticate.cs | 40 ------ .../OpenIdConnectHandlerTests.cs | 118 ------------------ ...ConnectMiddlewareForTestingAuthenticate.cs | 45 ------- .../OpenIdConnect/TestUtilities.cs | 6 +- 8 files changed, 65 insertions(+), 239 deletions(-) delete mode 100644 test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerForTestingAuthenticate.cs delete mode 100644 test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs delete mode 100644 test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 1d40a0a92f..7c469ef299 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -26,7 +26,8 @@ namespace OpenIdConnectSample public void ConfigureServices(IServiceCollection services) { - services.AddAuthentication(sharedOptions => sharedOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); + services.AddAuthentication(sharedOptions => + sharedOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 12d61e334b..e9f4d3ae00 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -84,21 +84,29 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect // 1. properties.Redirect // 2. Options.PostLogoutRedirectUri var properties = new AuthenticationProperties(signout.Properties); - if (!string.IsNullOrEmpty(properties.RedirectUri)) + var logoutRedirectUri = properties.RedirectUri; + if (!string.IsNullOrEmpty(logoutRedirectUri)) { - message.PostLogoutRedirectUri = properties.RedirectUri; + // Relative to PathBase + if (logoutRedirectUri.StartsWith("/", StringComparison.Ordinal)) + { + logoutRedirectUri = BuildRedirectUri(logoutRedirectUri); + } + message.PostLogoutRedirectUri = logoutRedirectUri; } else if (!string.IsNullOrEmpty(Options.PostLogoutRedirectUri)) { - message.PostLogoutRedirectUri = Options.PostLogoutRedirectUri; + logoutRedirectUri = Options.PostLogoutRedirectUri; + // Relative to PathBase + if (logoutRedirectUri.StartsWith("/", StringComparison.Ordinal)) + { + logoutRedirectUri = BuildRedirectUri(logoutRedirectUri); + } + message.PostLogoutRedirectUri = logoutRedirectUri; } - if (!string.IsNullOrEmpty(Options.SignInScheme)) - { - var principal = await Context.Authentication.AuthenticateAsync(Options.SignInScheme); - - message.IdTokenHint = principal?.FindFirst(OpenIdConnectParameterNames.IdToken)?.Value; - } + var principal = await Context.Authentication.AuthenticateAsync(Options.SignInScheme); + message.IdTokenHint = principal?.FindFirst(OpenIdConnectParameterNames.IdToken)?.Value; var redirectContext = new RedirectContext(Context, Options, properties) { @@ -308,6 +316,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect // See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#Security if (!string.IsNullOrEmpty(message.IdToken) || !string.IsNullOrEmpty(message.AccessToken)) { + if (Options.SkipUnrecognizedRequests) + { + // Not for us? + return AuthenticateResult.Skip(); + } return AuthenticateResult.Fail("An OpenID Connect response cannot contain an " + "identity token or an access token when using response_mode=query"); } @@ -325,6 +338,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect if (message == null) { + if (Options.SkipUnrecognizedRequests) + { + // Not for us? + return AuthenticateResult.Skip(); + } return AuthenticateResult.Fail("No message."); } @@ -344,7 +362,11 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect // Fail if state is missing, it's required for the correlation id. if (string.IsNullOrEmpty(message.State)) { - // This wasn't a valid ODIC message, it may not have been intended for us. + // This wasn't a valid OIDC message, it may not have been intended for us. + if (Options.SkipUnrecognizedRequests) + { + return AuthenticateResult.Skip(); + } Logger.LogDebug(11, "message.State is null or empty."); return AuthenticateResult.Fail(Resources.MessageStateIsNullOrEmpty); } @@ -353,7 +375,12 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect var properties = Options.StateDataFormat.Unprotect(Uri.UnescapeDataString(message.State)); if (properties == null) { - Logger.LogError(12, "Unable to unprotect the message.State."); + if (Options.SkipUnrecognizedRequests) + { + // Not for us? + return AuthenticateResult.Skip(); + } + Logger.LogError(12, "Unable to read the message.State."); return AuthenticateResult.Fail(Resources.MessageStateIsInvalid); } @@ -516,7 +543,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect if (Options.SaveTokensAsClaims) { // Persist the tokens extracted from the token response. - SaveTokens(ticket.Principal, tokenEndpointResponse, saveRefreshToken: true); + SaveTokens(ticket.Principal, tokenEndpointResponse, jwt.Issuer, saveRefreshToken: true); } if (Options.GetClaimsFromUserInfoEndpoint) @@ -582,7 +609,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { // TODO: call SaveTokens with the token response and set // saveRefreshToken to true when the hybrid flow is fully implemented. - SaveTokens(ticket.Principal, message, saveRefreshToken: false); + SaveTokens(ticket.Principal, message, jwt.Issuer, saveRefreshToken: false); } } // Implicit Flow @@ -594,7 +621,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect // response, since it's not a valid parameter when using the implicit flow. // See http://openid.net/specs/openid-connect-core-1_0.html#Authentication // and https://tools.ietf.org/html/rfc6749#section-4.2.2. - SaveTokens(ticket.Principal, message, saveRefreshToken: false); + SaveTokens(ticket.Principal, message, jwt.Issuer, saveRefreshToken: false); } } @@ -709,7 +736,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { JToken value; var claimValue = user.TryGetValue(pair.Key, out value) ? value.ToString() : null; - identity.AddClaim(new Claim(pair.Key, claimValue, ClaimValueTypes.String, Options.ClaimsIssuer)); + identity.AddClaim(new Claim(pair.Key, claimValue, ClaimValueTypes.String, jwt.Issuer)); } return ticket; @@ -721,38 +748,38 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect /// The principal in which tokens are saved. /// The OpenID Connect response. /// A indicating whether the refresh token should be stored. - private void SaveTokens(ClaimsPrincipal principal, OpenIdConnectMessage message, bool saveRefreshToken) + private void SaveTokens(ClaimsPrincipal principal, OpenIdConnectMessage message, string issuer, bool saveRefreshToken) { var identity = (ClaimsIdentity)principal.Identity; if (!string.IsNullOrEmpty(message.AccessToken)) { identity.AddClaim(new Claim(OpenIdConnectParameterNames.AccessToken, message.AccessToken, - ClaimValueTypes.String, Options.ClaimsIssuer)); + ClaimValueTypes.String, issuer)); } if (!string.IsNullOrEmpty(message.IdToken)) { identity.AddClaim(new Claim(OpenIdConnectParameterNames.IdToken, message.IdToken, - ClaimValueTypes.String, Options.ClaimsIssuer)); + ClaimValueTypes.String, issuer)); } if (saveRefreshToken && !string.IsNullOrEmpty(message.RefreshToken)) { identity.AddClaim(new Claim(OpenIdConnectParameterNames.RefreshToken, message.RefreshToken, - ClaimValueTypes.String, Options.ClaimsIssuer)); + ClaimValueTypes.String, issuer)); } if (!string.IsNullOrEmpty(message.TokenType)) { identity.AddClaim(new Claim(OpenIdConnectParameterNames.TokenType, message.TokenType, - ClaimValueTypes.String, Options.ClaimsIssuer)); + ClaimValueTypes.String, issuer)); } if (!string.IsNullOrEmpty(message.ExpiresIn)) { identity.AddClaim(new Claim(OpenIdConnectParameterNames.ExpiresIn, message.ExpiresIn, - ClaimValueTypes.String, Options.ClaimsIssuer)); + ClaimValueTypes.String, issuer)); } } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index af7a621de0..cd31e27d01 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -48,19 +48,12 @@ namespace Microsoft.AspNet.Builder public OpenIdConnectOptions(string authenticationScheme) { AuthenticationScheme = authenticationScheme; + AutomaticChallenge = true; DisplayName = OpenIdConnectDefaults.Caption; CallbackPath = new PathString("/signin-oidc"); Events = new OpenIdConnectEvents(); } - /// - /// Gets or sets the expected audience for any received JWT token. - /// - /// - /// The expected audience for any received JWT token. - /// - public string Audience { get; set; } - /// /// Gets or sets the Authority to use when making OpenIdConnect calls. /// @@ -141,7 +134,7 @@ namespace Microsoft.AspNet.Builder /// /// Gets or sets the method used to redirect the user agent to the identity provider. /// - public OpenIdConnectRedirectBehavior AuthenticationMethod { get; set; } + public OpenIdConnectRedirectBehavior AuthenticationMethod { get; set; } = OpenIdConnectRedirectBehavior.RedirectGet; /// /// Gets or sets the 'resource'. @@ -190,5 +183,13 @@ namespace Microsoft.AspNet.Builder /// This is disabled by default. /// public bool UseTokenLifetime { get; set; } + + /// + /// Indicates if requests to the CallbackPath may also be for other components. If enabled the middleware will pass + /// requests through that do not contain OpenIdConnect authentication responses. Disabling this and setting the + /// CallbackPath to a dedicated endpoint may provide better error handling. + /// This is disabled by default. + /// + public bool SkipUnrecognizedRequests { get; set; } = false; } } diff --git a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs index afaee6c7b1..9392379398 100644 --- a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Builder public class RemoteAuthenticationOptions : AuthenticationOptions { /// - /// Gets or sets timeout value in milliseconds for back channel communications with Twitter. + /// Gets or sets timeout value in milliseconds for back channel communications with the remote provider. /// /// /// The back channel timeout. @@ -50,7 +50,7 @@ namespace Microsoft.AspNet.Builder /// /// Defines whether access and refresh tokens should be stored in the - /// after a successful authentication. + /// after a successful authorization with the remote provider. /// This property is set to false by default to reduce /// the size of the final authentication cookie. /// diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerForTestingAuthenticate.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerForTestingAuthenticate.cs deleted file mode 100644 index c0333cb2f4..0000000000 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerForTestingAuthenticate.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.IdentityModel.Tokens.Jwt; -using System.Security.Claims; -using System.Threading.Tasks; -using Microsoft.AspNet.Authentication.OpenIdConnect; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; -using Newtonsoft.Json.Linq; - -namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect -{ - /// - /// Allows for custom processing of ApplyResponseChallenge, ApplyResponseGrant and AuthenticateCore - /// - public class OpenIdConnectHandlerForTestingAuthenticate : OpenIdConnectHandler - { - public OpenIdConnectHandlerForTestingAuthenticate() : base(null, null) - { - } - - protected override Task RedeemAuthorizationCodeAsync(string authorizationCode, string redirectUri) - { - var jsonResponse = new JObject(); - jsonResponse.Add(OpenIdConnectParameterNames.IdToken, "test token"); - return Task.FromResult(new OpenIdConnectMessage(jsonResponse)); - } - - protected override Task GetUserInformationAsync(OpenIdConnectMessage message, JwtSecurityToken jwt, AuthenticationTicket ticket) - { - var claimsIdentity = (ClaimsIdentity)ticket.Principal.Identity; - if (claimsIdentity == null) - { - claimsIdentity = new ClaimsIdentity(); - } - claimsIdentity.AddClaim(new Claim("test claim", "test value")); - return Task.FromResult(new AuthenticationTicket(new ClaimsPrincipal(claimsIdentity), ticket.Properties, ticket.AuthenticationScheme)); - } - } -} diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs deleted file mode 100644 index fa49055391..0000000000 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectHandlerTests.cs +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.IdentityModel.Tokens.Jwt; -using System.Linq; -using System.Net.Http; -using System.Security.Claims; -using System.Text.Encodings.Web; -using System.Threading.Tasks; -using Microsoft.AspNet.Authentication.OpenIdConnect; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.TestHost; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; -using Microsoft.IdentityModel.Tokens; -using Xunit; - -namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect -{ - /// - /// These tests are designed to test OpenIdConnectAuthenticationHandler. - /// - public class OpenIdConnectHandlerTests - { - private const string nonceForOpenIdConnect = "abc"; - private static SecurityToken specCompliantOpenIdConnect = new JwtSecurityToken("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"; - - [Theory, MemberData(nameof(AuthenticateCoreStateDataSet))] - public async Task AuthenticateCoreState(OpenIdConnectOptions option, OpenIdConnectMessage message) - { - var handler = new OpenIdConnectHandlerForTestingAuthenticate(); - var server = CreateServer(option, UrlEncoder.Default, handler); - await server.CreateClient().PostAsync("http://localhost", new FormUrlEncodedContent(message.Parameters.Where(pair => pair.Value != null))); - } - - public static TheoryData AuthenticateCoreStateDataSet - { - get - { - var formater = new AuthenticationPropertiesFormaterKeyValue(); - var properties = new AuthenticationProperties(); - var dataset = new TheoryData(); - - // expected user state is added to the message.Parameters.Items[ExpectedStateParameter] - // Userstate == null - var message = new OpenIdConnectMessage(); - message.State = UrlEncoder.Default.Encode(formater.Protect(properties)); - message.Code = Guid.NewGuid().ToString(); - message.Parameters.Add(ExpectedStateParameter, null); - dataset.Add(GetStateOptions(), message); - - // Userstate != null - message = new OpenIdConnectMessage(); - properties.Items.Clear(); - var userstate = Guid.NewGuid().ToString(); - message.Code = Guid.NewGuid().ToString(); - properties.Items.Add(OpenIdConnectDefaults.UserstatePropertiesKey, userstate); - message.State = UrlEncoder.Default.Encode(formater.Protect(properties)); - message.Parameters.Add(ExpectedStateParameter, userstate); - dataset.Add(GetStateOptions(), message); - return dataset; - } - } - - // Setup an event to check for expected state. - // The state gets set by the runtime after the 'MessageReceivedContext' - private static OpenIdConnectOptions GetStateOptions() - { - var options = new OpenIdConnectOptions(); - options.AuthenticationScheme = "OpenIdConnectHandlerTest"; - options.ConfigurationManager = TestUtilities.DefaultOpenIdConnectConfigurationManager; - options.ClientId = Guid.NewGuid().ToString(); - options.StateDataFormat = new AuthenticationPropertiesFormaterKeyValue(); - options.SignInScheme = "Cookies"; - options.Events = new OpenIdConnectEvents() - { - OnTokenResponseReceived = context => - { - context.HandleResponse(); - if (context.ProtocolMessage.State == null && !context.ProtocolMessage.Parameters.ContainsKey(ExpectedStateParameter)) - return Task.FromResult(null); - - if (context.ProtocolMessage.State == null || !context.ProtocolMessage.Parameters.ContainsKey(ExpectedStateParameter)) - Assert.True(false, "(context.ProtocolMessage.State=!= null || !context.ProtocolMessage.Parameters.ContainsKey(expectedState)"); - - Assert.Equal(context.ProtocolMessage.State, context.ProtocolMessage.Parameters[ExpectedStateParameter]); - return Task.FromResult(null); - } - }; - return options; - } - - private static TestServer CreateServer(OpenIdConnectOptions options, UrlEncoder encoder, OpenIdConnectHandler handler = null) - { - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseMiddleware(Options.Create(options), encoder, handler); - app.Use(async (context, next) => - { - await next(); - }); - }) - .ConfigureServices(services => - { - services.AddWebEncoders(); - services.AddDataProtection(); - }); - return new TestServer(builder); - } - } -} diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs deleted file mode 100644 index c73cf8f942..0000000000 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareForTestingAuthenticate.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. 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.Text.Encodings.Web; -using Microsoft.AspNet.Authentication.OpenIdConnect; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect -{ - - /// - /// pass a as the AuthenticationHandler - /// configured to handle certain messages. - /// - public class OpenIdConnectMiddlewareForTestingAuthenticate : OpenIdConnectMiddleware - { - OpenIdConnectHandler _handler; - - public OpenIdConnectMiddlewareForTestingAuthenticate( - RequestDelegate next, - IDataProtectionProvider dataProtectionProvider, - ILoggerFactory loggerFactory, - UrlEncoder encoder, - IServiceProvider services, - IOptions sharedOptions, - IOptions options, - HtmlEncoder htmlEncoder, - OpenIdConnectHandler handler = null - ) - : base(next, dataProtectionProvider, loggerFactory, encoder, services, sharedOptions, options, htmlEncoder) - { - _handler = handler; - } - - protected override AuthenticationHandler CreateHandler() - { - return _handler ?? base.CreateHandler(); - } - } -} diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/TestUtilities.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/TestUtilities.cs index b5371965ca..e48aa66043 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/TestUtilities.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/TestUtilities.cs @@ -27,9 +27,9 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect { return new OpenIdConnectConfiguration() { - AuthorizationEndpoint = @"https://login.windows.net/common/oauth2/authorize", - EndSessionEndpoint = @"https://login.windows.net/common/oauth2/endsessionendpoint", - TokenEndpoint = @"https://login.windows.net/common/oauth2/token", + AuthorizationEndpoint = @"https://login.microsoftonline.com/common/oauth2/authorize", + EndSessionEndpoint = @"https://login.microsoftonline.com/common/oauth2/endsessionendpoint", + TokenEndpoint = @"https://login.microsoftonline.com/common/oauth2/token", }; } } From ba757d7a458398d3c2a7874b6556e86648f094be Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 22 Jan 2016 12:16:26 -0800 Subject: [PATCH 449/900] Rename AspNet 5 folders and files. See https://github.com/aspnet/Announcements/issues/144 for more information. --- .../ChunkingCookieManager.cs | 0 .../Constants.cs | 0 .../CookieAppBuilderExtensions.cs | 0 .../CookieAuthenticationDefaults.cs | 0 .../CookieAuthenticationHandler.cs | 0 .../CookieAuthenticationMiddleware.cs | 0 .../CookieAuthenticationOptions.cs | 0 .../CookieSecureOption.cs | 0 .../Events/BaseCookieContext.cs | 0 .../Events/CookieAuthenticationEvents.cs | 0 .../Events/CookieRedirectContext.cs | 0 .../Events/CookieSignedInContext.cs | 0 .../Events/CookieSigningInContext.cs | 0 .../Events/CookieSigningOutContext.cs | 0 .../Events/CookieValidatePrincipalContext.cs | 0 .../Events/ICookieAuthenticationEvents.cs | 0 .../ICookieManager.cs | 0 .../ITicketStore.cs | 0 ...crosoft.AspNetCore.Authentication.Cookies.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../project.json | 0 .../FacebookAppBuilderExtensions.cs | 0 .../FacebookDefaults.cs | 0 .../FacebookHandler.cs | 0 .../FacebookHelper.cs | 0 .../FacebookMiddleware.cs | 0 .../FacebookOptions.cs | 0 ...rosoft.AspNetCore.Authentication.Facebook.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../project.json | 0 .../GoogleAppBuilderExtensions.cs | 0 .../GoogleDefaults.cs | 0 .../GoogleHandler.cs | 0 .../GoogleHelper.cs | 0 .../GoogleMiddleware.cs | 0 .../GoogleOptions.cs | 0 ...icrosoft.AspNetCore.Authentication.Google.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../project.json | 0 .../Events/AuthenticationFailedContext.cs | 0 .../Events/BaseJwtBearerContext.cs | 0 .../Events/IJwtBearerEvents.cs | 0 .../Events/JwtBearerChallengeContext.cs | 0 .../Events/JwtBearerEvents.cs | 0 .../Events/ReceivedTokenContext.cs | 0 .../Events/ReceivingTokenContext.cs | 0 .../Events/TokenValidatedContext.cs | 0 .../JwtBearerAppBuilderExtensions.cs | 0 .../JwtBearerDefaults.cs | 0 .../JwtBearerHandler.cs | 0 .../JwtBearerMiddleware.cs | 0 .../JwtBearerOptions.cs | 0 ...osoft.AspNetCore.Authentication.JwtBearer.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../project.json | 0 ...spNetCore.Authentication.MicrosoftAccount.xproj} | 0 .../MicrosoftAccountAppBuilderExtensions.cs | 0 .../MicrosoftAccountDefaults.cs | 0 .../MicrosoftAccountHandler.cs | 0 .../MicrosoftAccountHelper.cs | 0 .../MicrosoftAccountMiddleware.cs | 0 .../MicrosoftAccountOptions.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../project.json | 0 .../Constants.cs | 0 .../Events/IOAuthEvents.cs | 0 .../Events/OAuthCreatingTicketContext.cs | 0 .../Events/OAuthEvents.cs | 0 .../Events/OAuthRedirectToAuthorizationContext.cs | 0 ...Microsoft.AspNetCore.Authentication.OAuth.xproj} | 0 .../OAuthAppBuilderExtensions.cs | 0 .../OAuthHandler.cs | 0 .../OAuthMiddleware.cs | 0 .../OAuthOptions.cs | 0 .../OAuthTokenResponse.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../project.json | 0 .../Events/AuthenticationFailedContext.cs | 0 .../Events/AuthenticationValidatedContext.cs | 0 .../Events/AuthorizationCodeReceivedContext.cs | 0 .../Events/AuthorizationResponseReceivedContext.cs | 0 .../Events/BaseOpenIdConnectContext.cs | 0 .../Events/IOpenIdConnectEvents.cs | 0 .../Events/MessageReceivedContext.cs | 0 .../Events/OpenIdConnectEvents.cs | 0 .../Events/RedirectContext.cs | 0 .../Events/TokenResponseReceivedContext.cs | 0 .../Events/UserInformationReceivedContext.cs | 0 ...t.AspNetCore.Authentication.OpenIdConnect.xproj} | 0 .../OpenIdConnectAppBuilderExtensions.cs | 0 .../OpenIdConnectDefaults.cs | 0 .../OpenIdConnectHandler.cs | 0 .../OpenIdConnectMiddleware.cs | 0 .../OpenIdConnectOptions.cs | 0 .../OpenIdConnectRedirectBehavior .cs | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../project.json | 0 .../Events/BaseTwitterContext.cs | 0 .../Events/ITwitterEvents.cs | 0 .../Events/TwitterCreatingTicketContext.cs | 0 .../Events/TwitterEvents.cs | 0 ...TwitterRedirectToAuthorizationEndpointContext.cs | 0 .../Messages/AccessToken.cs | 0 .../Messages/RequestToken.cs | 0 .../Messages/RequestTokenSerializer.cs | 0 ...crosoft.AspNetCore.Authentication.Twitter.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../TwitterAppBuilderExtensions.cs | 0 .../TwitterDefaults.cs | 0 .../TwitterHandler.cs | 0 .../TwitterMiddleware.cs | 0 .../TwitterOptions.cs | 0 .../project.json | 0 .../AuthenticateResult.cs | 0 .../AuthenticationHandler.cs | 0 .../AuthenticationMiddleware.cs | 0 .../AuthenticationOptions.cs | 0 .../AuthenticationServiceCollectionExtensions.cs | 0 .../AuthenticationTicket.cs | 0 .../ClaimsTransformationAppBuilderExtensions.cs | 0 .../ClaimsTransformationHandler.cs | 0 .../ClaimsTransformationMiddleware.cs | 0 .../ClaimsTransformationOptions.cs | 0 .../ClaimsTransformer.cs | 0 .../DataHandler/IDataSerializer.cs | 0 .../DataHandler/ISecureDataFormat.cs | 0 .../DataHandler/PropertiesDataFormat.cs | 0 .../DataHandler/PropertiesSerializer.cs | 0 .../DataHandler/SecureDataFormat.cs | 0 .../DataHandler/TextEncoder.cs | 0 .../DataHandler/TicketDataFormat.cs | 0 .../DataHandler/TicketSerializer.cs | 0 .../Events/BaseContext.cs | 0 .../Events/BaseControlContext.cs | 0 .../Events/EventResultState.cs | 0 .../Events/FailureContext.cs | 0 .../Events/IRemoteAuthenticationEvents.cs | 0 .../Events/RemoteAuthenticationEvents.cs | 0 .../Events/TicketReceivedContext.cs | 0 .../HttpContextExtensions.cs | 0 .../IClaimsTransformer.cs | 0 .../ISystemClock.cs | 0 .../Microsoft.AspNetCore.Authentication.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/Resources.Designer.cs | 0 .../RemoteAuthenticationHandler.cs | 0 .../RemoteAuthenticationOptions.cs | 0 .../Resources.resx | 0 .../SharedAuthenticationOptions.cs | 0 .../SystemClock.cs | 0 .../Win32.cs | 0 .../project.json | 0 .../AllowAnonymousAttribute.cs | 0 .../AuthorizationContext.cs | 0 .../AuthorizationHandler.cs | 0 .../AuthorizationOptions.cs | 0 .../AuthorizationPolicy.cs | 0 .../AuthorizationPolicyBuilder.cs | 0 .../AuthorizationServiceCollectionExtensions.cs | 0 .../AuthorizationServiceExtensions.cs | 0 .../AuthorizeAttribute.cs | 0 .../DefaultAuthorizationService.cs | 0 .../IAllowAnonymous.cs | 0 .../IAuthorizationHandler.cs | 0 .../IAuthorizationRequirement.cs | 0 .../IAuthorizationService.cs | 0 .../IAuthorizeData.cs | 0 .../Infrastructure/AssertionRequirement.cs | 0 .../ClaimsAuthorizationRequirement.cs | 0 .../DenyAnonymousAuthorizationRequirement.cs | 0 .../Infrastructure/NameAuthorizationRequirement.cs | 0 .../OperationAuthorizationRequirement.cs | 0 .../PassThroughAuthorizationHandler.cs | 0 .../Infrastructure/RolesAuthorizationRequirement.cs | 0 .../Microsoft.AspNetCore.Authorization.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../project.json | 0 .../AppendCookieContext.cs | 0 .../CookiePolicyAppBuilderExtensions.cs | 0 .../CookiePolicyMiddleware.cs | 0 .../CookiePolicyOptions.cs | 0 .../DeleteCookieContext.cs | 0 .../HttpOnlyPolicy.cs | 0 .../Microsoft.AspNetCore.CookiePolicy.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../SecurePolicy.cs | 0 .../project.json | 0 .../AuthenticationHandlerFacts.cs | 0 .../Cookies/CookieMiddlewareTests.cs | 0 .../Cookies/Infrastructure/CookieChunkingTests.cs | 0 .../DataHandler/Base64UrlTextEncoderTests.cs | 0 .../DataHandler/SecureDataFormatTests.cs | 0 .../DataHandler/TicketSerializerTests.cs | 0 .../Facebook/FacebookMiddlewareTests.cs | 0 .../Google/GoogleMiddlewareTests.cs | 0 .../JwtBearer/JwtBearerMiddlewareTests.cs | 0 .../Microsoft.AspNetCore.Authentication.Test.xproj} | 0 .../MicrosoftAccountMiddlewareTests.cs | 0 .../AuthenticationPropertiesFormaterKeyValue.cs | 0 .../OpenIdConnect/ExpectedQueryValues.cs | 0 .../OpenIdConnect/OpenIdConnectMiddlewareTests.cs | 0 .../OpenIdConnect/TestUtilities.cs | 0 .../TestClock.cs | 0 .../TestExtensions.cs | 0 .../TestHttpMessageHandler.cs | 0 .../Transaction.cs | 0 .../Twitter/TwitterMiddlewareTests.cs | 0 .../katanatest.redmond.corp.microsoft.com.cer | Bin .../project.json | 0 .../selfSigned.cer | Bin .../AuthorizationPolicyFacts.cs | 0 .../DefaultAuthorizationServiceTests.cs | 0 .../Microsoft.AspNetCore.Authorization.Test.xproj} | 0 .../project.json | 0 .../CookiePolicyTests.cs | 0 .../Microsoft.AspNetCore.CookiePolicy.Test.xproj} | 0 .../TestExtensions.cs | 0 .../Transaction.cs | 0 .../project.json | 0 237 files changed, 0 insertions(+), 0 deletions(-) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/ChunkingCookieManager.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Constants.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/CookieAppBuilderExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/CookieAuthenticationDefaults.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/CookieAuthenticationHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/CookieAuthenticationMiddleware.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/CookieAuthenticationOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/CookieSecureOption.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Events/BaseCookieContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Events/CookieAuthenticationEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Events/CookieRedirectContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Events/CookieSignedInContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Events/CookieSigningInContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Events/CookieSigningOutContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Events/CookieValidatePrincipalContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Events/ICookieAuthenticationEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/ICookieManager.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/ITicketStore.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies/Microsoft.AspNet.Authentication.Cookies.xproj => Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj} (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Properties/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authentication.Cookies => Microsoft.AspNetCore.Authentication.Cookies}/project.json (100%) rename src/{Microsoft.AspNet.Authentication.Facebook => Microsoft.AspNetCore.Authentication.Facebook}/FacebookAppBuilderExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication.Facebook => Microsoft.AspNetCore.Authentication.Facebook}/FacebookDefaults.cs (100%) rename src/{Microsoft.AspNet.Authentication.Facebook => Microsoft.AspNetCore.Authentication.Facebook}/FacebookHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication.Facebook => Microsoft.AspNetCore.Authentication.Facebook}/FacebookHelper.cs (100%) rename src/{Microsoft.AspNet.Authentication.Facebook => Microsoft.AspNetCore.Authentication.Facebook}/FacebookMiddleware.cs (100%) rename src/{Microsoft.AspNet.Authentication.Facebook => Microsoft.AspNetCore.Authentication.Facebook}/FacebookOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication.Facebook/Microsoft.AspNet.Authentication.Facebook.xproj => Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj} (100%) rename src/{Microsoft.AspNet.Authentication.Facebook => Microsoft.AspNetCore.Authentication.Facebook}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authentication.Facebook => Microsoft.AspNetCore.Authentication.Facebook}/Properties/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Authentication.Facebook => Microsoft.AspNetCore.Authentication.Facebook}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authentication.Facebook => Microsoft.AspNetCore.Authentication.Facebook}/project.json (100%) rename src/{Microsoft.AspNet.Authentication.Google => Microsoft.AspNetCore.Authentication.Google}/GoogleAppBuilderExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication.Google => Microsoft.AspNetCore.Authentication.Google}/GoogleDefaults.cs (100%) rename src/{Microsoft.AspNet.Authentication.Google => Microsoft.AspNetCore.Authentication.Google}/GoogleHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication.Google => Microsoft.AspNetCore.Authentication.Google}/GoogleHelper.cs (100%) rename src/{Microsoft.AspNet.Authentication.Google => Microsoft.AspNetCore.Authentication.Google}/GoogleMiddleware.cs (100%) rename src/{Microsoft.AspNet.Authentication.Google => Microsoft.AspNetCore.Authentication.Google}/GoogleOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication.Google/Microsoft.AspNet.Authentication.Google.xproj => Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj} (100%) rename src/{Microsoft.AspNet.Authentication.Google => Microsoft.AspNetCore.Authentication.Google}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authentication.Google => Microsoft.AspNetCore.Authentication.Google}/Properties/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Authentication.Google => Microsoft.AspNetCore.Authentication.Google}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authentication.Google => Microsoft.AspNetCore.Authentication.Google}/project.json (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Events/AuthenticationFailedContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Events/BaseJwtBearerContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Events/IJwtBearerEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Events/JwtBearerChallengeContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Events/JwtBearerEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Events/ReceivedTokenContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Events/ReceivingTokenContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Events/TokenValidatedContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/JwtBearerAppBuilderExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/JwtBearerDefaults.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/JwtBearerHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/JwtBearerMiddleware.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/JwtBearerOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.JwtBearer.xproj => Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj} (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Properties/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authentication.JwtBearer => Microsoft.AspNetCore.Authentication.JwtBearer}/project.json (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount/Microsoft.AspNet.Authentication.MicrosoftAccount.xproj => Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj} (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount => Microsoft.AspNetCore.Authentication.MicrosoftAccount}/MicrosoftAccountAppBuilderExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount => Microsoft.AspNetCore.Authentication.MicrosoftAccount}/MicrosoftAccountDefaults.cs (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount => Microsoft.AspNetCore.Authentication.MicrosoftAccount}/MicrosoftAccountHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount => Microsoft.AspNetCore.Authentication.MicrosoftAccount}/MicrosoftAccountHelper.cs (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount => Microsoft.AspNetCore.Authentication.MicrosoftAccount}/MicrosoftAccountMiddleware.cs (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount => Microsoft.AspNetCore.Authentication.MicrosoftAccount}/MicrosoftAccountOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount => Microsoft.AspNetCore.Authentication.MicrosoftAccount}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount => Microsoft.AspNetCore.Authentication.MicrosoftAccount}/Properties/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount => Microsoft.AspNetCore.Authentication.MicrosoftAccount}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authentication.MicrosoftAccount => Microsoft.AspNetCore.Authentication.MicrosoftAccount}/project.json (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/Constants.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/Events/IOAuthEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/Events/OAuthCreatingTicketContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/Events/OAuthEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/Events/OAuthRedirectToAuthorizationContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth/Microsoft.AspNet.Authentication.OAuth.xproj => Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj} (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/OAuthAppBuilderExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/OAuthHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/OAuthMiddleware.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/OAuthOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/OAuthTokenResponse.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/Properties/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authentication.OAuth => Microsoft.AspNetCore.Authentication.OAuth}/project.json (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/AuthenticationFailedContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/AuthenticationValidatedContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/AuthorizationCodeReceivedContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/AuthorizationResponseReceivedContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/BaseOpenIdConnectContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/IOpenIdConnectEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/MessageReceivedContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/OpenIdConnectEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/RedirectContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/TokenResponseReceivedContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Events/UserInformationReceivedContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect/Microsoft.AspNet.Authentication.OpenIdConnect.xproj => Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj} (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/OpenIdConnectAppBuilderExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/OpenIdConnectDefaults.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/OpenIdConnectHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/OpenIdConnectMiddleware.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/OpenIdConnectOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/OpenIdConnectRedirectBehavior .cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Properties/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authentication.OpenIdConnect => Microsoft.AspNetCore.Authentication.OpenIdConnect}/project.json (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Events/BaseTwitterContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Events/ITwitterEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Events/TwitterCreatingTicketContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Events/TwitterEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Events/TwitterRedirectToAuthorizationEndpointContext.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Messages/AccessToken.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Messages/RequestToken.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Messages/RequestTokenSerializer.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter/Microsoft.AspNet.Authentication.Twitter.xproj => Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj} (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Properties/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/TwitterAppBuilderExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/TwitterDefaults.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/TwitterHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/TwitterMiddleware.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/TwitterOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication.Twitter => Microsoft.AspNetCore.Authentication.Twitter}/project.json (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/AuthenticateResult.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/AuthenticationHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/AuthenticationMiddleware.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/AuthenticationOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/AuthenticationServiceCollectionExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/AuthenticationTicket.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/ClaimsTransformationAppBuilderExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/ClaimsTransformationHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/ClaimsTransformationMiddleware.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/ClaimsTransformationOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/ClaimsTransformer.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/DataHandler/IDataSerializer.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/DataHandler/ISecureDataFormat.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/DataHandler/PropertiesDataFormat.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/DataHandler/PropertiesSerializer.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/DataHandler/SecureDataFormat.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/DataHandler/TextEncoder.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/DataHandler/TicketDataFormat.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/DataHandler/TicketSerializer.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Events/BaseContext.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Events/BaseControlContext.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Events/EventResultState.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Events/FailureContext.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Events/IRemoteAuthenticationEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Events/RemoteAuthenticationEvents.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Events/TicketReceivedContext.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/HttpContextExtensions.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/IClaimsTransformer.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/ISystemClock.cs (100%) rename src/{Microsoft.AspNet.Authentication/Microsoft.AspNet.Authentication.xproj => Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj} (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Properties/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/RemoteAuthenticationHandler.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/RemoteAuthenticationOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/SharedAuthenticationOptions.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/SystemClock.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/Win32.cs (100%) rename src/{Microsoft.AspNet.Authentication => Microsoft.AspNetCore.Authentication}/project.json (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/AllowAnonymousAttribute.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/AuthorizationContext.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/AuthorizationHandler.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/AuthorizationOptions.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/AuthorizationPolicy.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/AuthorizationPolicyBuilder.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/AuthorizationServiceCollectionExtensions.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/AuthorizationServiceExtensions.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/AuthorizeAttribute.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/DefaultAuthorizationService.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/IAllowAnonymous.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/IAuthorizationHandler.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/IAuthorizationRequirement.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/IAuthorizationService.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/IAuthorizeData.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/Infrastructure/AssertionRequirement.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/Infrastructure/ClaimsAuthorizationRequirement.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/Infrastructure/DenyAnonymousAuthorizationRequirement.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/Infrastructure/NameAuthorizationRequirement.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/Infrastructure/OperationAuthorizationRequirement.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/Infrastructure/PassThroughAuthorizationHandler.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/Infrastructure/RolesAuthorizationRequirement.cs (100%) rename src/{Microsoft.AspNet.Authorization/Microsoft.AspNet.Authorization.xproj => Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj} (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/Properties/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/Resources.resx (100%) rename src/{Microsoft.AspNet.Authorization => Microsoft.AspNetCore.Authorization}/project.json (100%) rename src/{Microsoft.AspNet.CookiePolicy => Microsoft.AspNetCore.CookiePolicy}/AppendCookieContext.cs (100%) rename src/{Microsoft.AspNet.CookiePolicy => Microsoft.AspNetCore.CookiePolicy}/CookiePolicyAppBuilderExtensions.cs (100%) rename src/{Microsoft.AspNet.CookiePolicy => Microsoft.AspNetCore.CookiePolicy}/CookiePolicyMiddleware.cs (100%) rename src/{Microsoft.AspNet.CookiePolicy => Microsoft.AspNetCore.CookiePolicy}/CookiePolicyOptions.cs (100%) rename src/{Microsoft.AspNet.CookiePolicy => Microsoft.AspNetCore.CookiePolicy}/DeleteCookieContext.cs (100%) rename src/{Microsoft.AspNet.CookiePolicy => Microsoft.AspNetCore.CookiePolicy}/HttpOnlyPolicy.cs (100%) rename src/{Microsoft.AspNet.CookiePolicy/Microsoft.AspNet.CookiePolicy.xproj => Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj} (100%) rename src/{Microsoft.AspNet.CookiePolicy => Microsoft.AspNetCore.CookiePolicy}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.CookiePolicy => Microsoft.AspNetCore.CookiePolicy}/SecurePolicy.cs (100%) rename src/{Microsoft.AspNet.CookiePolicy => Microsoft.AspNetCore.CookiePolicy}/project.json (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/AuthenticationHandlerFacts.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/Cookies/CookieMiddlewareTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/Cookies/Infrastructure/CookieChunkingTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/DataHandler/Base64UrlTextEncoderTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/DataHandler/SecureDataFormatTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/DataHandler/TicketSerializerTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/Facebook/FacebookMiddlewareTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/Google/GoogleMiddlewareTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/JwtBearer/JwtBearerMiddlewareTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test/Microsoft.AspNet.Authentication.Test.xproj => Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj} (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/OpenIdConnect/ExpectedQueryValues.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/OpenIdConnect/OpenIdConnectMiddlewareTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/OpenIdConnect/TestUtilities.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/TestClock.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/TestExtensions.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/TestHttpMessageHandler.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/Transaction.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/Twitter/TwitterMiddlewareTests.cs (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/katanatest.redmond.corp.microsoft.com.cer (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/project.json (100%) rename test/{Microsoft.AspNet.Authentication.Test => Microsoft.AspNetCore.Authentication.Test}/selfSigned.cer (100%) rename test/{Microsoft.AspNet.Authorization.Test => Microsoft.AspNetCore.Authorization.Test}/AuthorizationPolicyFacts.cs (100%) rename test/{Microsoft.AspNet.Authorization.Test => Microsoft.AspNetCore.Authorization.Test}/DefaultAuthorizationServiceTests.cs (100%) rename test/{Microsoft.AspNet.Authorization.Test/Microsoft.AspNet.Authorization.Test.xproj => Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj} (100%) rename test/{Microsoft.AspNet.Authorization.Test => Microsoft.AspNetCore.Authorization.Test}/project.json (100%) rename test/{Microsoft.AspNet.CookiePolicy.Test => Microsoft.AspNetCore.CookiePolicy.Test}/CookiePolicyTests.cs (100%) rename test/{Microsoft.AspNet.CookiePolicy.Test/Microsoft.AspNet.CookiePolicy.Test.xproj => Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj} (100%) rename test/{Microsoft.AspNet.CookiePolicy.Test => Microsoft.AspNetCore.CookiePolicy.Test}/TestExtensions.cs (100%) rename test/{Microsoft.AspNet.CookiePolicy.Test => Microsoft.AspNetCore.CookiePolicy.Test}/Transaction.cs (100%) rename test/{Microsoft.AspNet.CookiePolicy.Test => Microsoft.AspNetCore.CookiePolicy.Test}/project.json (100%) diff --git a/src/Microsoft.AspNet.Authentication.Cookies/ChunkingCookieManager.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/ChunkingCookieManager.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Constants.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Constants.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationDefaults.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationMiddleware.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieSecureOption.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieSecureOption.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/CookieSecureOption.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/CookieSecureOption.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/BaseCookieContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Events/BaseCookieContext.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Events/CookieAuthenticationEvents.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieRedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Events/CookieRedirectContext.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSignedInContext.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningInContext.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Events/CookieSigningOutContext.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/ICookieManager.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/ICookieManager.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/ITicketStore.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/ITicketStore.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Microsoft.AspNet.Authentication.Cookies.xproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Microsoft.AspNet.Authentication.Cookies.xproj rename to src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Properties/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Authentication.Cookies/Resources.resx b/src/Microsoft.AspNetCore.Authentication.Cookies/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/Resources.resx rename to src/Microsoft.AspNetCore.Authentication.Cookies/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json similarity index 100% rename from src/Microsoft.AspNet.Authentication.Cookies/project.json rename to src/Microsoft.AspNetCore.Authentication.Cookies/project.json diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/FacebookDefaults.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/FacebookHandler.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookHelper.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/FacebookHelper.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/FacebookMiddleware.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/FacebookOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs diff --git a/src/Microsoft.AspNet.Authentication.Facebook/Microsoft.AspNet.Authentication.Facebook.xproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/Microsoft.AspNet.Authentication.Facebook.xproj rename to src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj diff --git a/src/Microsoft.AspNet.Authentication.Facebook/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication.Facebook/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/Properties/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Authentication.Facebook/Resources.resx b/src/Microsoft.AspNetCore.Authentication.Facebook/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/Resources.resx rename to src/Microsoft.AspNetCore.Authentication.Facebook/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json similarity index 100% rename from src/Microsoft.AspNet.Authentication.Facebook/project.json rename to src/Microsoft.AspNetCore.Authentication.Facebook/project.json diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs rename to src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/GoogleDefaults.cs rename to src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/GoogleHandler.cs rename to src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleHelper.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/GoogleHelper.cs rename to src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/GoogleMiddleware.cs rename to src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/GoogleOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs diff --git a/src/Microsoft.AspNet.Authentication.Google/Microsoft.AspNet.Authentication.Google.xproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/Microsoft.AspNet.Authentication.Google.xproj rename to src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj diff --git a/src/Microsoft.AspNet.Authentication.Google/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Google/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Authentication.Google/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication.Google/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/Properties/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Authentication.Google/Resources.resx b/src/Microsoft.AspNetCore.Authentication.Google/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/Resources.resx rename to src/Microsoft.AspNetCore.Authentication.Google/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json similarity index 100% rename from src/Microsoft.AspNet.Authentication.Google/project.json rename to src/Microsoft.AspNetCore.Authentication.Google/project.json diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/IJwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Events/IJwtBearerEvents.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Events/JwtBearerEvents.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivedTokenContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivedTokenContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivedTokenContext.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivedTokenContext.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivingTokenContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivingTokenContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Events/ReceivingTokenContext.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivingTokenContext.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Events/TokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Events/TokenValidatedContext.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerDefaults.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerDefaults.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerHandler.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerMiddleware.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerMiddleware.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerOptions.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.JwtBearer.xproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Microsoft.AspNet.Authentication.JwtBearer.xproj rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Properties/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/Resources.resx b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/Resources.resx rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json similarity index 100% rename from src/Microsoft.AspNet.Authentication.JwtBearer/project.json rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/Microsoft.AspNet.Authentication.MicrosoftAccount.xproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/Microsoft.AspNet.Authentication.MicrosoftAccount.xproj rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/Resources.resx b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/Resources.resx rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json similarity index 100% rename from src/Microsoft.AspNet.Authentication.MicrosoftAccount/project.json rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Constants.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Constants.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/Constants.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/Constants.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/IOAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/Events/IOAuthEvents.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthEvents.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Microsoft.AspNet.Authentication.OAuth.xproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/Microsoft.AspNet.Authentication.OAuth.xproj rename to src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/OAuthMiddleware.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/OAuthOptions.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthTokenResponse.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/OAuthTokenResponse.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/Properties/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Authentication.OAuth/Resources.resx b/src/Microsoft.AspNetCore.Authentication.OAuth/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/Resources.resx rename to src/Microsoft.AspNetCore.Authentication.OAuth/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json similarity index 100% rename from src/Microsoft.AspNet.Authentication.OAuth/project.json rename to src/Microsoft.AspNetCore.Authentication.OAuth/project.json diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/RedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/RedirectContext.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Microsoft.AspNet.Authentication.OpenIdConnect.xproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Microsoft.AspNet.Authentication.OpenIdConnect.xproj rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectHandler.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectOptions.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior .cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior .cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior .cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior .cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Properties/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/Resources.resx b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/Resources.resx rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json similarity index 100% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/project.json rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/BaseTwitterContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Events/BaseTwitterContext.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/ITwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Events/ITwitterEvents.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterEvents.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Messages/AccessToken.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Messages/AccessToken.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Messages/RequestToken.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Messages/RequestToken.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Messages/RequestTokenSerializer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Messages/RequestTokenSerializer.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Microsoft.AspNet.Authentication.Twitter.xproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Microsoft.AspNet.Authentication.Twitter.xproj rename to src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Properties/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/Resources.resx b/src/Microsoft.AspNetCore.Authentication.Twitter/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/Resources.resx rename to src/Microsoft.AspNetCore.Authentication.Twitter/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/TwitterDefaults.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/TwitterHandler.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/TwitterMiddleware.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/TwitterOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs diff --git a/src/Microsoft.AspNet.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json similarity index 100% rename from src/Microsoft.AspNet.Authentication.Twitter/project.json rename to src/Microsoft.AspNetCore.Authentication.Twitter/project.json diff --git a/src/Microsoft.AspNet.Authentication/AuthenticateResult.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/AuthenticateResult.cs rename to src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs rename to src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/AuthenticationMiddleware.cs rename to src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/AuthenticationOptions.cs rename to src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/AuthenticationServiceCollectionExtensions.cs rename to src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationTicket.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationTicket.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/AuthenticationTicket.cs rename to src/Microsoft.AspNetCore.Authentication/AuthenticationTicket.cs diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs rename to src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationHandler.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/ClaimsTransformationHandler.cs rename to src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/ClaimsTransformationMiddleware.cs rename to src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationOptions.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/ClaimsTransformationOptions.cs rename to src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformer.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/ClaimsTransformer.cs rename to src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/IDataSerializer.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/IDataSerializer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/DataHandler/IDataSerializer.cs rename to src/Microsoft.AspNetCore.Authentication/DataHandler/IDataSerializer.cs diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/ISecureDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/ISecureDataFormat.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/DataHandler/ISecureDataFormat.cs rename to src/Microsoft.AspNetCore.Authentication/DataHandler/ISecureDataFormat.cs diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/PropertiesDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesDataFormat.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/DataHandler/PropertiesDataFormat.cs rename to src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesDataFormat.cs diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/PropertiesSerializer.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/DataHandler/PropertiesSerializer.cs rename to src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/SecureDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/SecureDataFormat.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/DataHandler/SecureDataFormat.cs rename to src/Microsoft.AspNetCore.Authentication/DataHandler/SecureDataFormat.cs diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/TextEncoder.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/DataHandler/TextEncoder.cs rename to src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/TicketDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketDataFormat.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/DataHandler/TicketDataFormat.cs rename to src/Microsoft.AspNetCore.Authentication/DataHandler/TicketDataFormat.cs diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/TicketSerializer.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketSerializer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/DataHandler/TicketSerializer.cs rename to src/Microsoft.AspNetCore.Authentication/DataHandler/TicketSerializer.cs diff --git a/src/Microsoft.AspNet.Authentication/Events/BaseContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/Events/BaseContext.cs rename to src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs diff --git a/src/Microsoft.AspNet.Authentication/Events/BaseControlContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/Events/BaseControlContext.cs rename to src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs diff --git a/src/Microsoft.AspNet.Authentication/Events/EventResultState.cs b/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/Events/EventResultState.cs rename to src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs diff --git a/src/Microsoft.AspNet.Authentication/Events/FailureContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/Events/FailureContext.cs rename to src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs diff --git a/src/Microsoft.AspNet.Authentication/Events/IRemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/IRemoteAuthenticationEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/Events/IRemoteAuthenticationEvents.cs rename to src/Microsoft.AspNetCore.Authentication/Events/IRemoteAuthenticationEvents.cs diff --git a/src/Microsoft.AspNet.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/Events/RemoteAuthenticationEvents.cs rename to src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs diff --git a/src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/Events/TicketReceivedContext.cs rename to src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs diff --git a/src/Microsoft.AspNet.Authentication/HttpContextExtensions.cs b/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/HttpContextExtensions.cs rename to src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs diff --git a/src/Microsoft.AspNet.Authentication/IClaimsTransformer.cs b/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/IClaimsTransformer.cs rename to src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs diff --git a/src/Microsoft.AspNet.Authentication/ISystemClock.cs b/src/Microsoft.AspNetCore.Authentication/ISystemClock.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/ISystemClock.cs rename to src/Microsoft.AspNetCore.Authentication/ISystemClock.cs diff --git a/src/Microsoft.AspNet.Authentication/Microsoft.AspNet.Authentication.xproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj similarity index 100% rename from src/Microsoft.AspNet.Authentication/Microsoft.AspNet.Authentication.xproj rename to src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj diff --git a/src/Microsoft.AspNet.Authentication/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authentication/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/Properties/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/RemoteAuthenticationHandler.cs rename to src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs diff --git a/src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/RemoteAuthenticationOptions.cs rename to src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs diff --git a/src/Microsoft.AspNet.Authentication/Resources.resx b/src/Microsoft.AspNetCore.Authentication/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authentication/Resources.resx rename to src/Microsoft.AspNetCore.Authentication/Resources.resx diff --git a/src/Microsoft.AspNet.Authentication/SharedAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/SharedAuthenticationOptions.cs rename to src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs diff --git a/src/Microsoft.AspNet.Authentication/SystemClock.cs b/src/Microsoft.AspNetCore.Authentication/SystemClock.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/SystemClock.cs rename to src/Microsoft.AspNetCore.Authentication/SystemClock.cs diff --git a/src/Microsoft.AspNet.Authentication/Win32.cs b/src/Microsoft.AspNetCore.Authentication/Win32.cs similarity index 100% rename from src/Microsoft.AspNet.Authentication/Win32.cs rename to src/Microsoft.AspNetCore.Authentication/Win32.cs diff --git a/src/Microsoft.AspNet.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json similarity index 100% rename from src/Microsoft.AspNet.Authentication/project.json rename to src/Microsoft.AspNetCore.Authentication/project.json diff --git a/src/Microsoft.AspNet.Authorization/AllowAnonymousAttribute.cs b/src/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/AllowAnonymousAttribute.cs rename to src/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationContext.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/AuthorizationContext.cs rename to src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/AuthorizationHandler.cs rename to src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationOptions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/AuthorizationOptions.cs rename to src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/AuthorizationPolicy.cs rename to src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationPolicyBuilder.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/AuthorizationPolicyBuilder.cs rename to src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/AuthorizationServiceCollectionExtensions.cs rename to src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationServiceExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/AuthorizationServiceExtensions.cs rename to src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs diff --git a/src/Microsoft.AspNet.Authorization/AuthorizeAttribute.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/AuthorizeAttribute.cs rename to src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs diff --git a/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs rename to src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs diff --git a/src/Microsoft.AspNet.Authorization/IAllowAnonymous.cs b/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/IAllowAnonymous.cs rename to src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs diff --git a/src/Microsoft.AspNet.Authorization/IAuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/IAuthorizationHandler.cs rename to src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs diff --git a/src/Microsoft.AspNet.Authorization/IAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/IAuthorizationRequirement.cs rename to src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNet.Authorization/IAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/IAuthorizationService.cs rename to src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs diff --git a/src/Microsoft.AspNet.Authorization/IAuthorizeData.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/IAuthorizeData.cs rename to src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs diff --git a/src/Microsoft.AspNet.Authorization/Infrastructure/AssertionRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/Infrastructure/AssertionRequirement.cs rename to src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs diff --git a/src/Microsoft.AspNet.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs rename to src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNet.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs rename to src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNet.Authorization/Infrastructure/NameAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/Infrastructure/NameAuthorizationRequirement.cs rename to src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNet.Authorization/Infrastructure/OperationAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/Infrastructure/OperationAuthorizationRequirement.cs rename to src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNet.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs rename to src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs diff --git a/src/Microsoft.AspNet.Authorization/Infrastructure/RolesAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/Infrastructure/RolesAuthorizationRequirement.cs rename to src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNet.Authorization/Microsoft.AspNet.Authorization.xproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj similarity index 100% rename from src/Microsoft.AspNet.Authorization/Microsoft.AspNet.Authorization.xproj rename to src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj diff --git a/src/Microsoft.AspNet.Authorization/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Authorization/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Authorization/Properties/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Authorization/Resources.resx b/src/Microsoft.AspNetCore.Authorization/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Authorization/Resources.resx rename to src/Microsoft.AspNetCore.Authorization/Resources.resx diff --git a/src/Microsoft.AspNet.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json similarity index 100% rename from src/Microsoft.AspNet.Authorization/project.json rename to src/Microsoft.AspNetCore.Authorization/project.json diff --git a/src/Microsoft.AspNet.CookiePolicy/AppendCookieContext.cs b/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs similarity index 100% rename from src/Microsoft.AspNet.CookiePolicy/AppendCookieContext.cs rename to src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs diff --git a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs rename to src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.CookiePolicy/CookiePolicyMiddleware.cs rename to src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs diff --git a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs similarity index 100% rename from src/Microsoft.AspNet.CookiePolicy/CookiePolicyOptions.cs rename to src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs diff --git a/src/Microsoft.AspNet.CookiePolicy/DeleteCookieContext.cs b/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs similarity index 100% rename from src/Microsoft.AspNet.CookiePolicy/DeleteCookieContext.cs rename to src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs diff --git a/src/Microsoft.AspNet.CookiePolicy/HttpOnlyPolicy.cs b/src/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs similarity index 100% rename from src/Microsoft.AspNet.CookiePolicy/HttpOnlyPolicy.cs rename to src/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs diff --git a/src/Microsoft.AspNet.CookiePolicy/Microsoft.AspNet.CookiePolicy.xproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj similarity index 100% rename from src/Microsoft.AspNet.CookiePolicy/Microsoft.AspNet.CookiePolicy.xproj rename to src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj diff --git a/src/Microsoft.AspNet.CookiePolicy/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.CookiePolicy/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.CookiePolicy/SecurePolicy.cs b/src/Microsoft.AspNetCore.CookiePolicy/SecurePolicy.cs similarity index 100% rename from src/Microsoft.AspNet.CookiePolicy/SecurePolicy.cs rename to src/Microsoft.AspNetCore.CookiePolicy/SecurePolicy.cs diff --git a/src/Microsoft.AspNet.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json similarity index 100% rename from src/Microsoft.AspNet.CookiePolicy/project.json rename to src/Microsoft.AspNetCore.CookiePolicy/project.json diff --git a/test/Microsoft.AspNet.Authentication.Test/AuthenticationHandlerFacts.cs b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/AuthenticationHandlerFacts.cs rename to test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/DataHandler/SecureDataFormatTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/SecureDataFormatTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/DataHandler/SecureDataFormatTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/DataHandler/SecureDataFormatTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/DataHandler/TicketSerializerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/TicketSerializerTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/DataHandler/TicketSerializerTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/DataHandler/TicketSerializerTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/Microsoft.AspNet.Authentication.Test.xproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/Microsoft.AspNet.Authentication.Test.xproj rename to test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj diff --git a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs rename to test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs rename to test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/TestUtilities.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestUtilities.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/TestUtilities.cs rename to test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestUtilities.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/TestClock.cs b/test/Microsoft.AspNetCore.Authentication.Test/TestClock.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/TestClock.cs rename to test/Microsoft.AspNetCore.Authentication.Test/TestClock.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/TestExtensions.cs b/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/TestExtensions.cs rename to test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/TestHttpMessageHandler.cs b/test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/TestHttpMessageHandler.cs rename to test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/Transaction.cs b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/Transaction.cs rename to test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Twitter/TwitterMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/Twitter/TwitterMiddlewareTests.cs diff --git a/test/Microsoft.AspNet.Authentication.Test/katanatest.redmond.corp.microsoft.com.cer b/test/Microsoft.AspNetCore.Authentication.Test/katanatest.redmond.corp.microsoft.com.cer similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/katanatest.redmond.corp.microsoft.com.cer rename to test/Microsoft.AspNetCore.Authentication.Test/katanatest.redmond.corp.microsoft.com.cer diff --git a/test/Microsoft.AspNet.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/project.json rename to test/Microsoft.AspNetCore.Authentication.Test/project.json diff --git a/test/Microsoft.AspNet.Authentication.Test/selfSigned.cer b/test/Microsoft.AspNetCore.Authentication.Test/selfSigned.cer similarity index 100% rename from test/Microsoft.AspNet.Authentication.Test/selfSigned.cer rename to test/Microsoft.AspNetCore.Authentication.Test/selfSigned.cer diff --git a/test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs similarity index 100% rename from test/Microsoft.AspNet.Authorization.Test/AuthorizationPolicyFacts.cs rename to test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs diff --git a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs similarity index 100% rename from test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs rename to test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs diff --git a/test/Microsoft.AspNet.Authorization.Test/Microsoft.AspNet.Authorization.Test.xproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj similarity index 100% rename from test/Microsoft.AspNet.Authorization.Test/Microsoft.AspNet.Authorization.Test.xproj rename to test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj diff --git a/test/Microsoft.AspNet.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json similarity index 100% rename from test/Microsoft.AspNet.Authorization.Test/project.json rename to test/Microsoft.AspNetCore.Authorization.Test/project.json diff --git a/test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs similarity index 100% rename from test/Microsoft.AspNet.CookiePolicy.Test/CookiePolicyTests.cs rename to test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs diff --git a/test/Microsoft.AspNet.CookiePolicy.Test/Microsoft.AspNet.CookiePolicy.Test.xproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj similarity index 100% rename from test/Microsoft.AspNet.CookiePolicy.Test/Microsoft.AspNet.CookiePolicy.Test.xproj rename to test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj diff --git a/test/Microsoft.AspNet.CookiePolicy.Test/TestExtensions.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs similarity index 100% rename from test/Microsoft.AspNet.CookiePolicy.Test/TestExtensions.cs rename to test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs diff --git a/test/Microsoft.AspNet.CookiePolicy.Test/Transaction.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs similarity index 100% rename from test/Microsoft.AspNet.CookiePolicy.Test/Transaction.cs rename to test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs diff --git a/test/Microsoft.AspNet.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json similarity index 100% rename from test/Microsoft.AspNet.CookiePolicy.Test/project.json rename to test/Microsoft.AspNetCore.CookiePolicy.Test/project.json From c0d587e7c2246f208e2c82e9deafd19058c1c2f2 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 22 Jan 2016 12:16:38 -0800 Subject: [PATCH 450/900] Rename AspNet 5 file contents. See https://github.com/aspnet/Announcements/issues/144 for more information. --- NuGetPackageVerifier.json | 22 +++++++------- Security.sln | 30 +++++++++---------- samples/CookieSample/Startup.cs | 8 ++--- samples/CookieSample/hosting.json | 4 +-- samples/CookieSample/project.json | 8 ++--- .../MemoryCacheTicketStore.cs | 4 +-- samples/CookieSessionSample/Startup.cs | 8 ++--- samples/CookieSessionSample/hosting.json | 4 +-- samples/CookieSessionSample/project.json | 8 ++--- samples/JwtBearerSample/Startup.cs | 8 ++--- samples/JwtBearerSample/hosting.json | 4 +-- samples/JwtBearerSample/project.json | 10 +++---- samples/OpenIdConnectSample/Startup.cs | 12 ++++---- samples/OpenIdConnectSample/hosting.json | 4 +-- samples/OpenIdConnectSample/project.json | 8 ++--- samples/SocialSample/Startup.cs | 18 +++++------ samples/SocialSample/hosting.json | 4 +-- samples/SocialSample/project.json | 16 +++++----- .../ChunkingCookieManager.cs | 4 +-- .../Constants.cs | 2 +- .../CookieAppBuilderExtensions.cs | 4 +-- .../CookieAuthenticationDefaults.cs | 6 ++-- .../CookieAuthenticationHandler.cs | 14 ++++----- .../CookieAuthenticationMiddleware.cs | 8 ++--- .../CookieAuthenticationOptions.cs | 12 ++++---- .../CookieSecureOption.cs | 2 +- .../Events/BaseCookieContext.cs | 6 ++-- .../Events/CookieAuthenticationEvents.cs | 4 +-- .../Events/CookieRedirectContext.cs | 8 ++--- .../Events/CookieSignedInContext.cs | 8 ++--- .../Events/CookieSigningInContext.cs | 8 ++--- .../Events/CookieSigningOutContext.cs | 8 ++--- .../Events/CookieValidatePrincipalContext.cs | 8 ++--- .../Events/ICookieAuthenticationEvents.cs | 2 +- .../ICookieManager.cs | 4 +-- .../ITicketStore.cs | 2 +- .../Properties/Resources.Designer.cs | 4 +-- .../project.json | 2 +- .../FacebookAppBuilderExtensions.cs | 4 +-- .../FacebookDefaults.cs | 2 +- .../FacebookHandler.cs | 10 +++---- .../FacebookHelper.cs | 2 +- .../FacebookMiddleware.cs | 10 +++---- .../FacebookOptions.cs | 6 ++-- .../Properties/Resources.Designer.cs | 4 +-- .../project.json | 2 +- .../GoogleAppBuilderExtensions.cs | 4 +-- .../GoogleDefaults.cs | 2 +- .../GoogleHandler.cs | 10 +++---- .../GoogleHelper.cs | 2 +- .../GoogleMiddleware.cs | 10 +++---- .../GoogleOptions.cs | 6 ++-- .../Properties/Resources.Designer.cs | 4 +-- .../project.json | 2 +- .../Events/AuthenticationFailedContext.cs | 6 ++-- .../Events/BaseJwtBearerContext.cs | 6 ++-- .../Events/IJwtBearerEvents.cs | 2 +- .../Events/JwtBearerChallengeContext.cs | 8 ++--- .../Events/JwtBearerEvents.cs | 4 +-- .../Events/ReceivedTokenContext.cs | 6 ++-- .../Events/ReceivingTokenContext.cs | 6 ++-- .../Events/TokenValidatedContext.cs | 6 ++-- .../JwtBearerAppBuilderExtensions.cs | 4 +-- .../JwtBearerDefaults.cs | 2 +- .../JwtBearerHandler.cs | 10 +++---- .../JwtBearerMiddleware.cs | 6 ++-- .../JwtBearerOptions.cs | 6 ++-- .../Properties/Resources.Designer.cs | 4 +-- .../project.json | 2 +- .../MicrosoftAccountAppBuilderExtensions.cs | 4 +-- .../MicrosoftAccountDefaults.cs | 2 +- .../MicrosoftAccountHandler.cs | 8 ++--- .../MicrosoftAccountHelper.cs | 2 +- .../MicrosoftAccountMiddleware.cs | 10 +++---- .../MicrosoftAccountOptions.cs | 6 ++-- .../Properties/Resources.Designer.cs | 4 +-- .../project.json | 2 +- .../Constants.cs | 4 +-- .../Events/IOAuthEvents.cs | 2 +- .../Events/OAuthCreatingTicketContext.cs | 6 ++-- .../Events/OAuthEvents.cs | 2 +- .../OAuthRedirectToAuthorizationContext.cs | 8 ++--- .../OAuthAppBuilderExtensions.cs | 4 +-- .../OAuthHandler.cs | 12 ++++---- .../OAuthMiddleware.cs | 8 ++--- .../OAuthOptions.cs | 8 ++--- .../OAuthTokenResponse.cs | 2 +- .../Properties/Resources.Designer.cs | 4 +-- .../project.json | 2 +- .../Events/AuthenticationFailedContext.cs | 6 ++-- .../Events/AuthenticationValidatedContext.cs | 8 ++--- .../AuthorizationCodeReceivedContext.cs | 8 ++--- .../AuthorizationResponseReceivedContext.cs | 8 ++--- .../Events/BaseOpenIdConnectContext.cs | 6 ++-- .../Events/IOpenIdConnectEvents.cs | 2 +- .../Events/MessageReceivedContext.cs | 6 ++-- .../Events/OpenIdConnectEvents.cs | 2 +- .../Events/RedirectContext.cs | 8 ++--- .../Events/TokenResponseReceivedContext.cs | 10 +++---- .../Events/UserInformationReceivedContext.cs | 8 ++--- .../OpenIdConnectAppBuilderExtensions.cs | 4 +-- .../OpenIdConnectDefaults.cs | 6 ++-- .../OpenIdConnectHandler.cs | 10 +++---- .../OpenIdConnectMiddleware.cs | 8 ++--- .../OpenIdConnectOptions.cs | 10 +++---- .../OpenIdConnectRedirectBehavior .cs | 2 +- .../Properties/Resources.Designer.cs | 4 +-- .../project.json | 2 +- .../Events/BaseTwitterContext.cs | 6 ++-- .../Events/ITwitterEvents.cs | 2 +- .../Events/TwitterCreatingTicketContext.cs | 8 ++--- .../Events/TwitterEvents.cs | 2 +- ...rRedirectToAuthorizationEndpointContext.cs | 8 ++--- .../Messages/AccessToken.cs | 2 +- .../Messages/RequestToken.cs | 4 +-- .../Messages/RequestTokenSerializer.cs | 4 +-- .../Properties/Resources.Designer.cs | 4 +-- .../TwitterAppBuilderExtensions.cs | 4 +-- .../TwitterDefaults.cs | 2 +- .../TwitterHandler.cs | 14 ++++----- .../TwitterMiddleware.cs | 8 ++--- .../TwitterOptions.cs | 8 ++--- .../project.json | 2 +- .../AuthenticateResult.cs | 2 +- .../AuthenticationHandler.cs | 10 +++---- .../AuthenticationMiddleware.cs | 6 ++-- .../AuthenticationOptions.cs | 4 +-- ...thenticationServiceCollectionExtensions.cs | 2 +- .../AuthenticationTicket.cs | 4 +-- ...laimsTransformationAppBuilderExtensions.cs | 4 +-- .../ClaimsTransformationHandler.cs | 4 +-- .../ClaimsTransformationMiddleware.cs | 6 ++-- .../ClaimsTransformationOptions.cs | 4 +-- .../ClaimsTransformer.cs | 2 +- .../DataHandler/IDataSerializer.cs | 2 +- .../DataHandler/ISecureDataFormat.cs | 2 +- .../DataHandler/PropertiesDataFormat.cs | 6 ++-- .../DataHandler/PropertiesSerializer.cs | 4 +-- .../DataHandler/SecureDataFormat.cs | 4 +-- .../DataHandler/TextEncoder.cs | 2 +- .../DataHandler/TicketDataFormat.cs | 4 +-- .../DataHandler/TicketSerializer.cs | 2 +- .../Events/BaseContext.cs | 4 +-- .../Events/BaseControlContext.cs | 4 +-- .../Events/EventResultState.cs | 2 +- .../Events/FailureContext.cs | 4 +-- .../Events/IRemoteAuthenticationEvents.cs | 2 +- .../Events/RemoteAuthenticationEvents.cs | 2 +- .../Events/TicketReceivedContext.cs | 8 ++--- .../HttpContextExtensions.cs | 10 +++---- .../IClaimsTransformer.cs | 2 +- .../ISystemClock.cs | 2 +- .../Properties/Resources.Designer.cs | 4 +-- .../RemoteAuthenticationHandler.cs | 6 ++-- .../RemoteAuthenticationOptions.cs | 6 ++-- .../SharedAuthenticationOptions.cs | 2 +- .../SystemClock.cs | 2 +- .../project.json | 6 ++-- .../AllowAnonymousAttribute.cs | 2 +- .../AuthorizationContext.cs | 2 +- .../AuthorizationHandler.cs | 2 +- .../AuthorizationOptions.cs | 2 +- .../AuthorizationPolicy.cs | 2 +- .../AuthorizationPolicyBuilder.cs | 4 +-- ...uthorizationServiceCollectionExtensions.cs | 4 +-- .../AuthorizationServiceExtensions.cs | 2 +- .../AuthorizeAttribute.cs | 2 +- .../DefaultAuthorizationService.cs | 2 +- .../IAllowAnonymous.cs | 2 +- .../IAuthorizationHandler.cs | 2 +- .../IAuthorizationRequirement.cs | 2 +- .../IAuthorizationService.cs | 2 +- .../IAuthorizeData.cs | 2 +- .../Infrastructure/AssertionRequirement.cs | 2 +- .../ClaimsAuthorizationRequirement.cs | 2 +- .../DenyAnonymousAuthorizationRequirement.cs | 2 +- .../NameAuthorizationRequirement.cs | 2 +- .../OperationAuthorizationRequirement.cs | 2 +- .../PassThroughAuthorizationHandler.cs | 2 +- .../RolesAuthorizationRequirement.cs | 2 +- .../Properties/Resources.Designer.cs | 4 +-- .../project.json | 2 +- .../AppendCookieContext.cs | 4 +-- .../CookiePolicyAppBuilderExtensions.cs | 4 +-- .../CookiePolicyMiddleware.cs | 8 ++--- .../CookiePolicyOptions.cs | 4 +-- .../DeleteCookieContext.cs | 4 +-- .../HttpOnlyPolicy.cs | 2 +- .../Microsoft.AspNetCore.CookiePolicy.xproj | 4 +-- .../SecurePolicy.cs | 2 +- .../project.json | 2 +- .../AspNetTicketSerializer.cs | 2 +- .../DataProtectorShim.cs | 2 +- .../project.json | 6 ++-- .../AuthenticationHandlerFacts.cs | 14 ++++----- .../Cookies/CookieMiddlewareTests.cs | 16 +++++----- .../Infrastructure/CookieChunkingTests.cs | 6 ++-- .../DataHandler/Base64UrlTextEncoderTests.cs | 2 +- .../DataHandler/SecureDataFormatTests.cs | 6 ++-- .../DataHandler/TicketSerializerTests.cs | 6 ++-- .../Facebook/FacebookMiddlewareTests.cs | 18 +++++------ .../Google/GoogleMiddlewareTests.cs | 18 +++++------ .../JwtBearer/JwtBearerMiddlewareTests.cs | 16 +++++----- .../MicrosoftAccountMiddlewareTests.cs | 16 +++++----- ...uthenticationPropertiesFormaterKeyValue.cs | 4 +-- .../OpenIdConnect/ExpectedQueryValues.cs | 2 +- .../OpenIdConnectMiddlewareTests.cs | 16 +++++----- .../OpenIdConnect/TestUtilities.cs | 2 +- .../TestClock.cs | 4 +-- .../TestExtensions.cs | 6 ++-- .../TestHttpMessageHandler.cs | 2 +- .../Transaction.cs | 2 +- .../Twitter/TwitterMiddlewareTests.cs | 10 +++---- .../project.json | 18 +++++------ .../AuthorizationPolicyFacts.cs | 6 ++-- .../DefaultAuthorizationServiceTests.cs | 4 +-- .../project.json | 2 +- .../CookiePolicyTests.cs | 14 ++++----- ...crosoft.AspNetCore.CookiePolicy.Test.xproj | 4 +-- .../TestExtensions.cs | 6 ++-- .../Transaction.cs | 2 +- .../project.json | 4 +-- .../CookieInteropTests.cs | 14 ++++----- .../TicketInteropTests.cs | 2 +- .../project.json | 6 ++-- 225 files changed, 618 insertions(+), 618 deletions(-) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index c3d5401e6b..4c7cf6982f 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -9,17 +9,17 @@ "StrictSemanticVersionValidationRule" ], "packages": { - "Microsoft.AspNet.Authentication": { }, - "Microsoft.AspNet.Authentication.Cookies": { }, - "Microsoft.AspNet.Authentication.Facebook": { }, - "Microsoft.AspNet.Authentication.Google": { }, - "Microsoft.AspNet.Authentication.JwtBearer": { }, - "Microsoft.AspNet.Authentication.MicrosoftAccount": { }, - "Microsoft.AspNet.Authentication.OAuth": { }, - "Microsoft.AspNet.Authentication.OpenIdConnect": { }, - "Microsoft.AspNet.Authentication.Twitter": { }, - "Microsoft.AspNet.Authorization": { }, - "Microsoft.AspNet.CookiePolicy": { } + "Microsoft.AspNetCore.Authentication": { }, + "Microsoft.AspNetCore.Authentication.Cookies": { }, + "Microsoft.AspNetCore.Authentication.Facebook": { }, + "Microsoft.AspNetCore.Authentication.Google": { }, + "Microsoft.AspNetCore.Authentication.JwtBearer": { }, + "Microsoft.AspNetCore.Authentication.MicrosoftAccount": { }, + "Microsoft.AspNetCore.Authentication.OAuth": { }, + "Microsoft.AspNetCore.Authentication.OpenIdConnect": { }, + "Microsoft.AspNetCore.Authentication.Twitter": { }, + "Microsoft.AspNetCore.Authorization": { }, + "Microsoft.AspNetCore.CookiePolicy": { } } }, "Default": { // Rules to run for packages not listed in any other set. diff --git a/Security.sln b/Security.sln index 28ecb032ed..4c24c1d22f 100644 --- a/Security.sln +++ b/Security.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.23107.0 @@ -22,33 +22,33 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CookieSessionSample", "samp EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "OpenIdConnectSample", "samples\OpenIdConnectSample\OpenIdConnectSample.xproj", "{BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.Cookies", "src\Microsoft.AspNet.Authentication.Cookies\Microsoft.AspNet.Authentication.Cookies.xproj", "{FC152CC4-054B-457E-8D91-389C5DE3C561}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Cookies", "src\Microsoft.AspNetCore.Authentication.Cookies\Microsoft.AspNetCore.Authentication.Cookies.xproj", "{FC152CC4-054B-457E-8D91-389C5DE3C561}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication", "src\Microsoft.AspNet.Authentication\Microsoft.AspNet.Authentication.xproj", "{2286250A-52C8-4126-9F93-B1E45F0AD078}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication", "src\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.xproj", "{2286250A-52C8-4126-9F93-B1E45F0AD078}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.Facebook", "src\Microsoft.AspNet.Authentication.Facebook\Microsoft.AspNet.Authentication.Facebook.xproj", "{EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Facebook", "src\Microsoft.AspNetCore.Authentication.Facebook\Microsoft.AspNetCore.Authentication.Facebook.xproj", "{EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.Google", "src\Microsoft.AspNet.Authentication.Google\Microsoft.AspNet.Authentication.Google.xproj", "{76579C39-B829-490D-B8BE-1BD35FE8412E}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Google", "src\Microsoft.AspNetCore.Authentication.Google\Microsoft.AspNetCore.Authentication.Google.xproj", "{76579C39-B829-490D-B8BE-1BD35FE8412E}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.OpenIdConnect", "src\Microsoft.AspNet.Authentication.OpenIdConnect\Microsoft.AspNet.Authentication.OpenIdConnect.xproj", "{35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.OpenIdConnect", "src\Microsoft.AspNetCore.Authentication.OpenIdConnect\Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj", "{35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.MicrosoftAccount", "src\Microsoft.AspNet.Authentication.MicrosoftAccount\Microsoft.AspNet.Authentication.MicrosoftAccount.xproj", "{ACB45E19-F520-4D0C-8916-B0CEB9C017FE}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.MicrosoftAccount", "src\Microsoft.AspNetCore.Authentication.MicrosoftAccount\Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj", "{ACB45E19-F520-4D0C-8916-B0CEB9C017FE}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.Twitter", "src\Microsoft.AspNet.Authentication.Twitter\Microsoft.AspNet.Authentication.Twitter.xproj", "{0330FFF6-B4B5-42DD-8C99-26A789569000}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Twitter", "src\Microsoft.AspNetCore.Authentication.Twitter\Microsoft.AspNetCore.Authentication.Twitter.xproj", "{0330FFF6-B4B5-42DD-8C99-26A789569000}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authentication.OAuth", "src\Microsoft.AspNet.Authentication.OAuth\Microsoft.AspNet.Authentication.OAuth.xproj", "{1657C79E-7755-4AEE-9D61-571295B69A30}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.OAuth", "src\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.xproj", "{1657C79E-7755-4AEE-9D61-571295B69A30}" 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}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Test", "test\Microsoft.AspNetCore.Authentication.Test\Microsoft.AspNetCore.Authentication.Test.xproj", "{8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}" 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}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authorization.Test", "test\Microsoft.AspNetCore.Authorization.Test\Microsoft.AspNetCore.Authorization.Test.xproj", "{7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Authorization", "src\Microsoft.AspNet.Authorization\Microsoft.AspNet.Authorization.xproj", "{6AB3E514-5894-4131-9399-DC7D5284ADDB}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authorization", "src\Microsoft.AspNetCore.Authorization\Microsoft.AspNetCore.Authorization.xproj", "{6AB3E514-5894-4131-9399-DC7D5284ADDB}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.CookiePolicy", "src\Microsoft.AspNet.CookiePolicy\Microsoft.AspNet.CookiePolicy.xproj", "{86183DC3-02A8-4A68-8B60-71ECEC066E79}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.CookiePolicy", "src\Microsoft.AspNetCore.CookiePolicy\Microsoft.AspNetCore.CookiePolicy.xproj", "{86183DC3-02A8-4A68-8B60-71ECEC066E79}" 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.AspNetCore.CookiePolicy.Test", "test\Microsoft.AspNetCore.CookiePolicy.Test\Microsoft.AspNetCore.CookiePolicy.Test.xproj", "{1790E052-646F-4529-B90E-6FEA95520D69}" 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.AspNetCore.Authentication.JwtBearer", "src\Microsoft.AspNetCore.Authentication.JwtBearer\Microsoft.AspNetCore.Authentication.JwtBearer.xproj", "{2755BFE5-7421-4A31-A644-F817DF5CAA98}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JwtBearerSample", "samples\JwtBearerSample\JwtBearerSample.xproj", "{D399B84F-591B-4E98-92BA-B0F63E7B6957}" EndProject diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index a1a5d5bbc1..1f8b494c41 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -1,9 +1,9 @@ using System.Linq; using System.Security.Claims; -using Microsoft.AspNet.Authentication.Cookies; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/samples/CookieSample/hosting.json b/samples/CookieSample/hosting.json index f8ef14574d..6a93dbafa8 100644 --- a/samples/CookieSample/hosting.json +++ b/samples/CookieSample/hosting.json @@ -1,3 +1,3 @@ -{ - "server": "Microsoft.AspNet.Server.Kestrel" +{ + "server": "Microsoft.AspNetCore.Server.Kestrel" } diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 20c5e0249d..22d51833b2 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -1,9 +1,9 @@ { "dependencies": { - "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNet.DataProtection": "1.0.0-*", - "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", + "Microsoft.AspNetCore.DataProtection": "1.0.0-*", + "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "compilationOptions": { diff --git a/samples/CookieSessionSample/MemoryCacheTicketStore.cs b/samples/CookieSessionSample/MemoryCacheTicketStore.cs index 833ad35ac8..ebb660361b 100644 --- a/samples/CookieSessionSample/MemoryCacheTicketStore.cs +++ b/samples/CookieSessionSample/MemoryCacheTicketStore.cs @@ -1,7 +1,7 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Authentication; -using Microsoft.AspNet.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.Extensions.Caching.Memory; namespace CookieSessionSample diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 6c6c6f3606..57593d8789 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Authentication.Cookies; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/samples/CookieSessionSample/hosting.json b/samples/CookieSessionSample/hosting.json index f8ef14574d..6a93dbafa8 100644 --- a/samples/CookieSessionSample/hosting.json +++ b/samples/CookieSessionSample/hosting.json @@ -1,3 +1,3 @@ -{ - "server": "Microsoft.AspNet.Server.Kestrel" +{ + "server": "Microsoft.AspNetCore.Server.Kestrel" } diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index cddabac495..dd58262480 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -1,9 +1,9 @@ { "dependencies": { - "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNet.DataProtection": "1.0.0-*", - "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", + "Microsoft.AspNetCore.DataProtection": "1.0.0-*", + "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Caching.Memory": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 4ef2f6610e..34ee646c77 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.IO; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Net.Http.Headers; diff --git a/samples/JwtBearerSample/hosting.json b/samples/JwtBearerSample/hosting.json index f8ef14574d..6a93dbafa8 100644 --- a/samples/JwtBearerSample/hosting.json +++ b/samples/JwtBearerSample/hosting.json @@ -1,3 +1,3 @@ -{ - "server": "Microsoft.AspNet.Server.Kestrel" +{ + "server": "Microsoft.AspNetCore.Server.Kestrel" } diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index bfb35107ef..9ba387d674 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -1,13 +1,13 @@ -{ +{ "version": "1.0.0-*", "compilationOptions": { "emitEntryPoint": true }, "dependencies": { - "Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-*", - "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.StaticFiles": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*", + "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*" }, "commands": { diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 7c469ef299..11a95a5717 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -1,10 +1,10 @@ using System.Linq; -using Microsoft.AspNet.Authentication.Cookies; -using Microsoft.AspNet.Authentication.OpenIdConnect; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/samples/OpenIdConnectSample/hosting.json b/samples/OpenIdConnectSample/hosting.json index f8ef14574d..6a93dbafa8 100644 --- a/samples/OpenIdConnectSample/hosting.json +++ b/samples/OpenIdConnectSample/hosting.json @@ -1,3 +1,3 @@ -{ - "server": "Microsoft.AspNet.Server.Kestrel" +{ + "server": "Microsoft.AspNetCore.Server.Kestrel" } diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 9a204e1425..3b2caff5e2 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -1,9 +1,9 @@ { "dependencies": { - "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*", - "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", + "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 2641725df9..e959943798 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -5,15 +5,15 @@ using System.Net.Http.Headers; using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Authentication.Cookies; -using Microsoft.AspNet.Authentication.Google; -using Microsoft.AspNet.Authentication.MicrosoftAccount; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Authentication.Twitter; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.Google; +using Microsoft.AspNetCore.Authentication.MicrosoftAccount; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Authentication.Twitter; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/samples/SocialSample/hosting.json b/samples/SocialSample/hosting.json index f8ef14574d..6a93dbafa8 100644 --- a/samples/SocialSample/hosting.json +++ b/samples/SocialSample/hosting.json @@ -1,3 +1,3 @@ -{ - "server": "Microsoft.AspNet.Server.Kestrel" +{ + "server": "Microsoft.AspNetCore.Server.Kestrel" } diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 53ade790cd..a8eb114c99 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -1,13 +1,13 @@ { "dependencies": { - "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNet.Authentication.Facebook": "1.0.0-*", - "Microsoft.AspNet.Authentication.Google": "1.0.0-*", - "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-*", - "Microsoft.AspNet.Authentication.Twitter": "1.0.0-*", - "Microsoft.AspNet.DataProtection": "1.0.0-*", - "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-*", + "Microsoft.AspNetCore.DataProtection": "1.0.0-*", + "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs index 70d7096cbf..380e6f9374 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs @@ -6,11 +6,11 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text.Encodings.Web; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// This handles cookies that are limited by per cookie length. It breaks down long cookies for responses, and reassembles them diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs index c9d6194ba5..3aabf94c15 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { internal static class Constants { diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs index 8582648877..765d1f51cd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Extension methods to add cookie authentication capabilities to an HTTP application pipeline. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs index 715c251008..2baa9e45cd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Diagnostics.CodeAnalysis; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// Default values related to cookie-based authentication middleware @@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Authentication.Cookies /// /// The prefix used to provide a default CookieAuthenticationOptions.CookieName /// - public static readonly string CookiePrefix = ".AspNet."; + public static readonly string CookiePrefix = ".AspNetCore."; /// /// The default value used by CookieAuthenticationMiddleware for the diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 040539d4d9..b056d0787b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -6,21 +6,21 @@ using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Features; -using Microsoft.AspNet.Http.Features.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { internal class CookieAuthenticationHandler : AuthenticationHandler { private const string HeaderValueNoCache = "no-cache"; private const string HeaderValueMinusOne = "-1"; - private const string SessionIdClaim = "Microsoft.AspNet.Authentication.Cookies-SessionId"; + private const string SessionIdClaim = "Microsoft.AspNetCore.Authentication.Cookies-SessionId"; private bool _shouldRefresh; private DateTimeOffset? _refreshIssuedUtc; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs index c15b10d345..ff54957cfe 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs @@ -3,13 +3,13 @@ using System; using System.Text.Encodings.Web; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { public class CookieAuthenticationMiddleware : AuthenticationMiddleware { diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 075353887f..dc1a63bbf3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -4,13 +4,13 @@ using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; -using Microsoft.AspNet.Authentication; -using Microsoft.AspNet.Authentication.Cookies; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Contains the options used by the CookiesAuthenticationMiddleware @@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Builder } /// - /// Determines the cookie name used to persist the identity. The default value is ".AspNet.Cookies". + /// Determines the cookie name used to persist the identity. The default value is ".AspNetCore.Cookies". /// This value should be changed if you change the name of the AuthenticationScheme, especially if your /// system uses the cookie authentication middleware multiple times. /// diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieSecureOption.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieSecureOption.cs index 83d34d0aec..5a35415d1b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieSecureOption.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieSecureOption.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// Determines how the identity cookie's security property is set. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs index d3e9127eed..e5423fed23 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { public class BaseCookieContext : BaseContext { diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs index e78db2a87d..ffe687e5f2 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs @@ -3,9 +3,9 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// This default implementation of the ICookieAuthenticationEvents may be used if the diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs index 4f0266b855..e946548f49 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Diagnostics.CodeAnalysis; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// Context passed when a Challenge, SignIn, or SignOut causes a redirect in the cookie middleware diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs index 2412722c08..cfb7c5f1d8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// Context object passed to the ICookieAuthenticationEvents method SignedIn. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs index 709549d0aa..d8b2307f32 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// Context object passed to the ICookieAuthenticationEvents method SigningIn. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs index 2de962ef4e..ab5858e369 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs @@ -1,11 +1,11 @@ // 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.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// Context object passed to the ICookieAuthenticationEvents method SigningOut diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs index 435499bf57..d2c1fd42f6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs @@ -3,11 +3,11 @@ using System; using System.Security.Claims; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// Context object passed to the ICookieAuthenticationProvider method ValidatePrincipal. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs index 9c3cc912dd..1406d872dc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// Specifies callback methods which the invokes to enable developer control over the authentication process. /> diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs index 0aa9855ee3..4514fefa97 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs @@ -1,9 +1,9 @@ // 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; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// This is used by the CookieAuthenticationMiddleware to process request and response cookies. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs index 418dec45e4..cff11a8929 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { /// /// This provides an abstract storage mechanic to preserve identity information on the server diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs index ede713df8c..e2719f39d2 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.Cookies internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Authentication.Cookies.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.AspNetCore.Authentication.Cookies.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// The cookie key and options are larger than ChunksSize, leaving no room for data. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index 8a6fdac7be..de5c6c09dc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Authentication": "1.0.0-*", + "Microsoft.AspNetCore.Authentication": "1.0.0-*", "Microsoft.Extensions.Options": "1.0.0-*", "Microsoft.Extensions.WebEncoders": "1.0.0-*", "Newtonsoft.Json": "6.0.6" diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs index 19ff8fa67e..0435db794f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication.Facebook; +using Microsoft.AspNetCore.Authentication.Facebook; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Extension methods to add Facebook authentication capabilities to an HTTP application pipeline. diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs index d2896a5ce5..da65e246ba 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authentication.Facebook +namespace Microsoft.AspNetCore.Authentication.Facebook { public static class FacebookDefaults { diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 7c74b253f3..126f48d66d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -7,13 +7,13 @@ using System.Security.Claims; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.WebUtilities; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.WebUtilities; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.Facebook +namespace Microsoft.AspNetCore.Authentication.Facebook { internal class FacebookHandler : OAuthHandler { diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs index bb950f32a3..af68a7c32a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs @@ -4,7 +4,7 @@ using System; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.Facebook +namespace Microsoft.AspNetCore.Authentication.Facebook { /// /// Contains static methods that allow to extract user's information from a diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs index f6d04171a9..4ceda639cc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs @@ -4,14 +4,14 @@ using System; using System.Globalization; using System.Text.Encodings.Web; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Authentication.Facebook +namespace Microsoft.AspNetCore.Authentication.Facebook { /// /// An ASP.NET middleware for authenticating users using Facebook. diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs index 25e02cf778..af82c6f9a7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; -using Microsoft.AspNet.Authentication.Facebook; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Authentication.Facebook; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Configuration options for . diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs index 69c6675755..a3a2f28745 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authentication.Facebook +namespace Microsoft.AspNetCore.Authentication.Facebook { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.Facebook internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Authentication.Facebook.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.AspNetCore.Authentication.Facebook.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// The '{0}' option must be provided. diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 0c64cafa91..2a11e8fd5c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Authentication.OAuth": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*", "Newtonsoft.Json": "6.0.6" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs index e380ebf475..fe693a61b7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication.Google; +using Microsoft.AspNetCore.Authentication.Google; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Extension methods to add Google authentication capabilities to an HTTP application pipeline. diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs index ebd05602ab..06fd12eb1f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authentication.Google +namespace Microsoft.AspNetCore.Authentication.Google { public static class GoogleDefaults { diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 675e424422..affde917aa 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -7,13 +7,13 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; using System.Threading.Tasks; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.WebUtilities; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.WebUtilities; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.Google +namespace Microsoft.AspNetCore.Authentication.Google { internal class GoogleHandler : OAuthHandler { diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs index 5327ddcb2e..0a763d5696 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs @@ -5,7 +5,7 @@ using System; using Microsoft.Extensions.Internal; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.Google +namespace Microsoft.AspNetCore.Authentication.Google { /// /// Contains static methods that allow to extract user's information from a diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs index 72ec3dee98..565d89b0cf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs @@ -4,14 +4,14 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Text.Encodings.Web; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Authentication.Google +namespace Microsoft.AspNetCore.Authentication.Google { /// /// An ASP.NET middleware for authenticating users using Google OAuth 2.0. diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs index eb1f0c3f1b..208d710650 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs @@ -1,10 +1,10 @@ // 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.Authentication.Google; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Authentication.Google; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Configuration options for . diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs index 5003d937b4..690c5a2803 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authentication.Google +namespace Microsoft.AspNetCore.Authentication.Google { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.Google internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Authentication.Google.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.AspNetCore.Authentication.Google.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// The '{0}' option must be provided. diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index 47736748c5..10862c3180 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Authentication.OAuth": "1.0.0-*" + "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs index 02898af9c9..b3e0f0bdc8 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class AuthenticationFailedContext : BaseJwtBearerContext { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs index 50ed9ffc5f..5c28f2976e 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class BaseJwtBearerContext : BaseControlContext { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs index cf47ab47ea..4ad6f7c21b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; /// /// Specifies events which the invokes to enable developer control over the authentication process. /> /// -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { /// /// OpenIdConnect bearer token middleware events. diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs index 403e8ab7fd..b3a4d21ba6 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs @@ -1,11 +1,11 @@ // 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.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class JwtBearerChallengeContext : BaseJwtBearerContext { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs index 7fcf922e57..5fc8a6b6c9 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -3,12 +3,12 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; /// /// Specifies events which the invokes to enable developer control over the authentication process. /> /// -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { /// /// OpenIdConnect bearer token middleware events. diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivedTokenContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivedTokenContext.cs index a0c7a98c29..e38c49cf15 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivedTokenContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivedTokenContext.cs @@ -1,10 +1,10 @@ // 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.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class ReceivedTokenContext : BaseJwtBearerContext { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivingTokenContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivingTokenContext.cs index 16ee6c1cee..e93ad824ad 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivingTokenContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivingTokenContext.cs @@ -1,10 +1,10 @@ // 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.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class ReceivingTokenContext : BaseJwtBearerContext { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs index 1f6e24e922..3a1dad812f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs @@ -1,10 +1,10 @@ // 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.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class ValidatedTokenContext : BaseJwtBearerContext { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index bea74d7412..13c06ca382 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -2,10 +2,10 @@ // 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.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Extension methods to add OpenIdConnect Bearer authentication capabilities to an HTTP application pipeline. diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs index 5b73bf1569..649edf94bb 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { /// /// Default values used by bearer authentication. diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index be6e83c036..67889d51db 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -6,16 +6,16 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Features.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { internal class JwtBearerHandler : AuthenticationHandler { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerMiddleware.cs index 7102cb61af..bfb38793f3 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerMiddleware.cs @@ -4,14 +4,14 @@ using System; using System.Net.Http; using System.Text.Encodings.Web; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { /// /// Bearer authentication middleware component which is added to an HTTP pipeline. This class is not diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs index b028d0b5e8..0a08ff3e44 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -6,13 +6,13 @@ using System.Collections.Generic; using System.ComponentModel; using System.IdentityModel.Tokens.Jwt; using System.Net.Http; -using Microsoft.AspNet.Authentication; -using Microsoft.AspNet.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Options class provides information needed to control Bearer Authentication middleware behavior diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs index 79bbbe4497..ef1d784f22 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { 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.AspNetCore.Authentication.JwtBearer.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// The '{0}' option must be provided. diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 16b169298b..0ff2727364 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Authentication": "1.0.0-*", + "Microsoft.AspNetCore.Authentication": "1.0.0-*", "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs index 1986227da3..660dd2e818 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication.MicrosoftAccount; +using Microsoft.AspNetCore.Authentication.MicrosoftAccount; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Extension methods to add Microsoft Account authentication capabilities to an HTTP application pipeline. diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs index be0732ae6d..d853794779 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authentication.MicrosoftAccount +namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { public static class MicrosoftAccountDefaults { diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index f28c7ffc7f..245fbed87d 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -5,12 +5,12 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; using System.Threading.Tasks; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http.Authentication; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.MicrosoftAccount +namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { internal class MicrosoftAccountHandler : OAuthHandler { diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs index b0573688e9..8b88cbc44c 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs @@ -4,7 +4,7 @@ using System; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.MicrosoftAccount +namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { /// /// Contains static methods that allow to extract user's information from a diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs index 5f0e36bb45..8daa9b2add 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs @@ -3,14 +3,14 @@ using System; using System.Text.Encodings.Web; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Authentication.MicrosoftAccount +namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { /// /// An ASP.NET middleware for authenticating users using the Microsoft Account service. diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs index 392df69bf7..7adfa57057 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -1,10 +1,10 @@ // 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; -using Microsoft.AspNet.Authentication.MicrosoftAccount; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Authentication.MicrosoftAccount; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Configuration options for . diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs index 6a20332bd6..618d143eed 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authentication.MicrosoftAccount +namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Authentication.MicrosoftAccount.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.AspNetCore.Authentication.MicrosoftAccount.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// The user does not have an id. diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index b1528b9352..db03dbd5c7 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Authentication.OAuth": "1.0.0-*" + "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Constants.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Constants.cs index 53114e2443..fb4d8b76d8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Constants.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Constants.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Authentication.OAuth +namespace Microsoft.AspNetCore.Authentication.OAuth { internal static class Constants { internal const string SecurityAuthenticate = "security.Authenticate"; - internal const string CorrelationPrefix = ".AspNet.Correlation."; + internal const string CorrelationPrefix = ".AspNetCore.Correlation."; } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs index 4c800c9844..76a238e07d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication.OAuth +namespace Microsoft.AspNetCore.Authentication.OAuth { /// /// Specifies callback methods which the invokes to enable developer control over the authentication process. diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs index c2b35349ee..15f9c91c74 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -5,11 +5,11 @@ using System; using System.Globalization; using System.Net.Http; using System.Security.Claims; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.OAuth +namespace Microsoft.AspNetCore.Authentication.OAuth { /// /// Contains information about the login session as well as the user . diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs index 07de38640c..cf1528e280 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -4,7 +4,7 @@ using System; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication.OAuth +namespace Microsoft.AspNetCore.Authentication.OAuth { /// /// Default implementation. diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs index 8e3599605f..5dcbd568cb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs @@ -1,11 +1,11 @@ // 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.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.OAuth +namespace Microsoft.AspNetCore.Authentication.OAuth { /// /// Context passed when a Challenge causes a redirect to authorize endpoint in the middleware. diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs index 8d71400bae..eebeaf7a37 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication.OAuth; +using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Extension methods to add OAuth 2.0 authentication capabilities to an HTTP application pipeline. diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 632932a3fb..7f59443bf3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -9,16 +9,16 @@ using System.Security.Claims; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Extensions; -using Microsoft.AspNet.Http.Features.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Extensions; +using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.OAuth +namespace Microsoft.AspNetCore.Authentication.OAuth { public class OAuthHandler : RemoteAuthenticationHandler where TOptions : OAuthOptions { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs index 72d34cbf78..401537e831 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs @@ -6,13 +6,13 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Net.Http; using System.Text.Encodings.Web; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Authentication.OAuth +namespace Microsoft.AspNetCore.Authentication.OAuth { /// /// An ASP.NET middleware for authenticating users using OAuth services. diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs index d53e0a8bcd..230c7362ad 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; -using Microsoft.AspNet.Authentication; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Configuration options for . diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs index 7a45120b4a..aa4026b009 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs @@ -4,7 +4,7 @@ using System; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.OAuth +namespace Microsoft.AspNetCore.Authentication.OAuth { public class OAuthTokenResponse { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs index d17513cbaa..00c7b848b5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authentication.OAuth +namespace Microsoft.AspNetCore.Authentication.OAuth { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.OAuth internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Authentication.OAuth.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.AspNetCore.Authentication.OAuth.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// The '{0}' option must be provided. diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index 1d6833e3ef..352ccfe905 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Authentication": "1.0.0-*", + "Microsoft.AspNetCore.Authentication": "1.0.0-*", "Newtonsoft.Json": "6.0.6" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs index a120c24026..776f78d6e7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class AuthenticationFailedContext : BaseOpenIdConnectContext { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs index 2469ef5c86..4e19796457 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs @@ -1,12 +1,12 @@ // 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.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class AuthenticationValidatedContext : BaseOpenIdConnectContext { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs index f43be81981..d1737cd259 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs @@ -3,11 +3,11 @@ using System.Diagnostics.CodeAnalysis; using System.IdentityModel.Tokens.Jwt; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// /// This Context can be used to be informed when an 'AuthorizationCode' is received over the OpenIdConnect protocol. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs index e0c74c8db5..7d17d3cf80 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs @@ -1,11 +1,11 @@ // 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.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class AuthorizationResponseReceivedContext : BaseOpenIdConnectContext { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs index e207c836a5..d2f56a4ce2 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class BaseOpenIdConnectContext : BaseControlContext { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs index b6bcfd57dc..da956acf82 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// /// Specifies events which the invokes to enable developer control over the authentication process. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs index cb42c0f9bc..d535f35f92 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs @@ -1,10 +1,10 @@ // 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.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class MessageReceivedContext : BaseOpenIdConnectContext { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index c84e5546a1..249342eecf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -4,7 +4,7 @@ using System; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// /// Specifies events which the invokes to enable developer control over the authentication process. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs index a87c3398ed..59b1c0efd1 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs @@ -1,11 +1,11 @@ // 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.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// /// When a user configures the to be notified prior to redirecting to an IdentityProvider diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs index 0e12bc2914..b4a9ad6d11 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs @@ -1,12 +1,12 @@ -// 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. -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// /// This Context can be used to be informed when an 'AuthorizationCode' is redeemed for tokens at the token endpoint. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs index 80935354af..c0a53db447 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs @@ -1,11 +1,11 @@ -// 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. -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class UserInformationReceivedContext : BaseOpenIdConnectContext { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs index 63cfe5009a..07aefec424 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Extension methods to add OpenID Connect authentication capabilities to an HTTP application pipeline. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs index e280a6afb1..378c594479 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// /// Default values related to OpenIdConnect authentication middleware @@ -26,12 +26,12 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect /// /// The prefix used to for the nonce in the cookie. /// - public static readonly string CookieNoncePrefix = ".AspNet.OpenIdConnect.Nonce."; + public static readonly string CookieNoncePrefix = ".AspNetCore.OpenIdConnect.Nonce."; /// /// The prefix used for the state in the cookie. /// - public static readonly string CookieStatePrefix = ".AspNet.OpenIdConnect.State."; + public static readonly string CookieStatePrefix = ".AspNetCore.OpenIdConnect.State."; /// /// The property for the RedirectUri that was used when asking for a 'authorizationCode'. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index e9f4d3ae00..8ade6ee631 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -13,17 +13,17 @@ using System.Security.Cryptography; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Features.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// /// A per-request authentication handler for the OpenIdConnectAuthenticationMiddleware. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs index 5dcd74d3c1..09901cf372 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -6,15 +6,15 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text; using System.Text.Encodings.Web; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// /// ASP.NET middleware for obtaining identities using OpenIdConnect protocol. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index cd31e27d01..4ae05a2bba 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -5,15 +5,15 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IdentityModel.Tokens.Jwt; -using Microsoft.AspNet.Authentication; -using Microsoft.AspNet.Authentication.OpenIdConnect; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Configuration options for diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior .cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior .cs index 5c0176627f..2f419df18a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior .cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior .cs @@ -1,4 +1,4 @@ -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// /// Lists the different authentication methods used to diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs index 64b345f959..65a9273a0d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Authentication.OpenIdConnect.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.AspNetCore.Authentication.OpenIdConnect.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// OpenIdConnectAuthenticationHandler: message.State is null or empty. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 58d9d5a407..04354e3512 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Authentication": "1.0.0-*", + "Microsoft.AspNetCore.Authentication": "1.0.0-*", "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs index d928fdcc71..5f00cb18bc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs @@ -1,10 +1,10 @@ // 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.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { /// /// Base class for other Twitter contexts. diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs index cea4a99bf6..76b487b966 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { /// /// Specifies callback methods which the invokes to enable developer control over the authentication process. /> diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs index d5537ef95c..97d1d176a9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { /// /// Contains information about the login session as well as the user . diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs index 1941e7990f..99122e8553 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -4,7 +4,7 @@ using System; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { /// /// Default implementation. diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs index 5569e82735..aa1da43edb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs @@ -1,11 +1,11 @@ // 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.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { /// /// The Context passed when a Challenge causes a redirect to authorize endpoint in the Twitter middleware. diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs index 880cf69d93..550163bec8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { /// /// The Twitter access token retrieved from the access token endpoint. diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs index 94a766e020..04c334e3d3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs @@ -1,9 +1,9 @@ // 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; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { /// /// The Twitter request token obtained from the request token endpoint. diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs index 6d3adeb1c9..a96a379c18 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs @@ -4,9 +4,9 @@ using System; using System.Diagnostics.CodeAnalysis; using System.IO; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { /// /// Serializes and deserializes Twitter request and access tokens so that they can be used by other application components. diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs index 9a385b546d..d60c2fc734 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication.Twitter internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Authentication.Twitter.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.AspNetCore.Authentication.Twitter.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// The '{0}' option must be provided. diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs index 6303707521..df6ca1d024 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication.Twitter; +using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Extension methods to add Twitter authentication capabilities to an HTTP application pipeline. diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs index a546dba9cd..0610ccfc9d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { public static class TwitterDefaults { diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 3de3b37fdf..a4a1a08020 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -9,16 +9,16 @@ using System.Security.Claims; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Features.Authentication; -using Microsoft.AspNet.Http.Internal; -using Microsoft.AspNet.WebUtilities; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.Http.Internal; +using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { internal class TwitterHandler : RemoteAuthenticationHandler { diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs index 6b708a3a73..1a1e199cc1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs @@ -6,13 +6,13 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Net.Http; using System.Text.Encodings.Web; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { /// /// ASP.NET middleware for authenticating users using Twitter diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 19a3ca78aa..cd13d1798f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication; -using Microsoft.AspNet.Authentication.Twitter; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Twitter; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Options for the Twitter authentication middleware. diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 6c4124a1b5..67ebf2c0db 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Authentication": "1.0.0-*" + "Microsoft.AspNetCore.Authentication": "1.0.0-*" }, "frameworks": { "net451": { diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs index 25d87a4633..fb97931cbb 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { /// /// Contains the result of an Authenticate call diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index f68bddaf89..ff98a10318 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -4,14 +4,14 @@ using System; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Features.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { /// /// Base class for the per-request work performed by most authentication middleware. diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs index 08e325bc0b..ad63b17614 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs @@ -4,12 +4,12 @@ using System; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public abstract class AuthenticationMiddleware where TOptions : AuthenticationOptions, new() { diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs index 5f8e562935..8f1fb06912 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs @@ -1,9 +1,9 @@ // 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; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Base Options for all authentication middleware diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 72032f53b0..9ce76d7e62 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication; +using Microsoft.AspNetCore.Authentication; namespace Microsoft.Extensions.DependencyInjection { diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationTicket.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationTicket.cs index dffcebc08e..1d56a8fb34 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationTicket.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationTicket.cs @@ -3,9 +3,9 @@ using System; using System.Security.Claims; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { /// /// Contains user identity information as well as additional authentication state. diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs index 7dfa482174..1cc76b946e 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs @@ -4,10 +4,10 @@ using System; using System.Security.Claims; using System.Threading.Tasks; -using Microsoft.AspNet.Authentication; +using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Extension methods to add claims transformation capabilities to an HTTP application pipeline. diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs index 954f26032f..78d9a0845b 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNet.Http.Features.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { /// /// Handler that applies ClaimsTransformation to authentication diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs index f490af4a4f..2e2216bc25 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs @@ -3,11 +3,11 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class ClaimsTransformationMiddleware { diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs index e1ca6b9004..7772457a02 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs @@ -1,9 +1,9 @@ // 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.Authentication; +using Microsoft.AspNetCore.Authentication; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { public class ClaimsTransformationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs index e824689d1c..b8e7ea3e1c 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs @@ -5,7 +5,7 @@ using System; using System.Security.Claims; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class ClaimsTransformer : IClaimsTransformer { diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/IDataSerializer.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/IDataSerializer.cs index 4fc7b49bec..ad9c523005 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/IDataSerializer.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/IDataSerializer.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public interface IDataSerializer { diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/ISecureDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/ISecureDataFormat.cs index c44729e125..73b1b882b5 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/ISecureDataFormat.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/ISecureDataFormat.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public interface ISecureDataFormat { diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesDataFormat.cs index 956794815e..3d31e4bd2d 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesDataFormat.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesDataFormat.cs @@ -1,10 +1,10 @@ // 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.DataProtection; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class PropertiesDataFormat : SecureDataFormat { diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs index e6d6bc1d81..542553cf2b 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs @@ -5,9 +5,9 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class PropertiesSerializer : IDataSerializer { diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/SecureDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/SecureDataFormat.cs index 339d3ed221..f35025d8bb 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/SecureDataFormat.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/SecureDataFormat.cs @@ -1,9 +1,9 @@ // 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.DataProtection; +using Microsoft.AspNetCore.DataProtection; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class SecureDataFormat : ISecureDataFormat { diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs index 009413ed0a..c07a314b05 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public static class Base64UrlTextEncoder { diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketDataFormat.cs index 63f97cc9e4..e43943cfc8 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketDataFormat.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketDataFormat.cs @@ -1,9 +1,9 @@ // 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.DataProtection; +using Microsoft.AspNetCore.DataProtection; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class TicketDataFormat : SecureDataFormat { diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketSerializer.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketSerializer.cs index 36b2695923..e33ec71725 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketSerializer.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketSerializer.cs @@ -6,7 +6,7 @@ using System.IO; using System.Linq; using System.Security.Claims; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { // This MUST be kept in sync with Microsoft.Owin.Security.Interop.AspNetTicketSerializer public class TicketSerializer : IDataSerializer diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs index 0286871e98..10b3325d4f 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs @@ -1,9 +1,9 @@ // 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; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public abstract class BaseContext { diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs index 4e986c808e..db81ad704c 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs @@ -1,9 +1,9 @@ // 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; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class BaseControlContext : BaseContext { diff --git a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs b/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs index c3437ddff6..80a6f949ab 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public enum EventResultState { diff --git a/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs index e0475d7363..35af9cee30 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { /// /// Provides failure context information to middleware providers. diff --git a/src/Microsoft.AspNetCore.Authentication/Events/IRemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/IRemoteAuthenticationEvents.cs index 666783fd9c..e2109a0651 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/IRemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/IRemoteAuthenticationEvents.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public interface IRemoteAuthenticationEvents { diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs index d1c90be2f0..ee45b8afd9 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs @@ -4,7 +4,7 @@ using System; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class RemoteAuthenticationEvents : IRemoteAuthenticationEvents { diff --git a/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs index 0663248cf1..5d5fd4883c 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { /// /// Provides context information to middleware providers. diff --git a/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs b/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs index 0234f22cdb..eea17bcc3c 100644 --- a/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs @@ -1,12 +1,12 @@ // 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; -using Microsoft.AspNet.Http.Features; -using Microsoft.AspNet.Http.Features.Authentication; -using Microsoft.AspNet.Http.Features.Authentication.Internal; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication.Internal; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { internal static class HttpContextExtensions { diff --git a/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs b/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs index a4e4e2f25e..03eece9318 100644 --- a/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs +++ b/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs @@ -4,7 +4,7 @@ using System.Security.Claims; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public interface IClaimsTransformer { diff --git a/src/Microsoft.AspNetCore.Authentication/ISystemClock.cs b/src/Microsoft.AspNetCore.Authentication/ISystemClock.cs index dedb6d36af..5582669861 100644 --- a/src/Microsoft.AspNetCore.Authentication/ISystemClock.cs +++ b/src/Microsoft.AspNetCore.Authentication/ISystemClock.cs @@ -4,7 +4,7 @@ using System; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { /// /// Abstracts the system clock to facilitate testing. diff --git a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs index b1dc46b068..29dd7c67e2 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authentication internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Authentication.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.AspNetCore.Authentication.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// The default data protection provider may only be used when the IApplicationBuilder.Properties contains an appropriate 'host.AppName' key. diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index cc1487d55d..ef4a1db52d 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -3,11 +3,11 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http.Features.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Logging; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public abstract class RemoteAuthenticationHandler : AuthenticationHandler where TOptions : RemoteAuthenticationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 9392379398..86fcdcc97b 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -3,10 +3,10 @@ using System; using System.Net.Http; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Authentication; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { public class RemoteAuthenticationOptions : AuthenticationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs index 5a03a279fa..bf30cae9e3 100644 --- a/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs @@ -4,7 +4,7 @@ using System; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class SharedAuthenticationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication/SystemClock.cs b/src/Microsoft.AspNetCore.Authentication/SystemClock.cs index 405b8afa26..0f9c2a30a0 100644 --- a/src/Microsoft.AspNetCore.Authentication/SystemClock.cs +++ b/src/Microsoft.AspNetCore.Authentication/SystemClock.cs @@ -4,7 +4,7 @@ using System; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { /// /// Provides access to the normal system clock. diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index ef36e17f03..c7a58a242c 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -10,9 +10,9 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.DataProtection": "1.0.0-*", - "Microsoft.AspNet.Http": "1.0.0-*", - "Microsoft.AspNet.Http.Extensions": "1.0.0-*", + "Microsoft.AspNetCore.DataProtection": "1.0.0-*", + "Microsoft.AspNetCore.Http": "1.0.0-*", + "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", "Microsoft.Extensions.Logging.Abstractions": "1.0.0-*", "Microsoft.Extensions.SecurityHelper.Sources": { "type": "build", diff --git a/src/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs b/src/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs index b61a01446b..cb3f1b1728 100644 --- a/src/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs +++ b/src/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { /// /// Specifies that the class or method that this attribute is applied to does not require authorization. diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs index 93f4da651d..455adb0dda 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { /// /// Contains authorization information used by . diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs index bdfe8b1c13..2bd90aad42 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { public abstract class AuthorizationHandler : IAuthorizationHandler where TRequirement : IAuthorizationRequirement diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs index 66627b458c..c3019c907f 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { public class AuthorizationOptions { diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs index befcb3c277..97aa5b381b 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { public class AuthorizationPolicy { diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs index 053ff49605..0cc0195e60 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs @@ -4,9 +4,9 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.AspNet.Authorization.Infrastructure; +using Microsoft.AspNetCore.Authorization.Infrastructure; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { public class AuthorizationPolicyBuilder { diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs index 599a8fb27c..120dffda57 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authorization; -using Microsoft.AspNet.Authorization.Infrastructure; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization.Infrastructure; using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs index 5ab5b03e73..a2b0a755cf 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Security.Claims; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { public static class AuthorizationServiceExtensions { diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs index a20436ce99..cdfab44f17 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { /// /// Specifies that the class or method that this attribute is applied to requires the specified authorization. diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 2c1fcd20d1..d501f1b20e 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { public class DefaultAuthorizationService : IAuthorizationService { diff --git a/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs b/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs index 3ba290a989..7593e0ad3c 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { public interface IAllowAnonymous { diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs index 84ebbc9a3e..fc8ba6e7ff 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { public interface IAuthorizationHandler { diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs index 19857b618e..800789a8ca 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { public interface IAuthorizationRequirement { diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs index a9dbe06cdd..e3b9fec91e 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Security.Claims; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { /// /// Checks policy based permissions for a user diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs index a49b4892a1..3371134b48 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { /// /// Defines the set of data required to apply authorization rules to a resource. diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs index b0eb44cf9b..0d3ab2bf28 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNet.Authorization.Infrastructure +namespace Microsoft.AspNetCore.Authorization.Infrastructure { public class AssertionRequirement : AuthorizationHandler, IAuthorizationRequirement { diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs index 82e3ac5b69..bff54954d9 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace Microsoft.AspNet.Authorization.Infrastructure +namespace Microsoft.AspNetCore.Authorization.Infrastructure { // Must contain a claim with the specified name, and at least one of the required values // If AllowedValues is null or empty, that means any claim is valid diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs index 1011baef3e..44ab475de0 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs @@ -3,7 +3,7 @@ using System.Linq; -namespace Microsoft.AspNet.Authorization.Infrastructure +namespace Microsoft.AspNetCore.Authorization.Infrastructure { public class DenyAnonymousAuthorizationRequirement : AuthorizationHandler, IAuthorizationRequirement { diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs index dc9ea9eda2..a4f2455a69 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs @@ -4,7 +4,7 @@ using System; using System.Linq; -namespace Microsoft.AspNet.Authorization.Infrastructure +namespace Microsoft.AspNetCore.Authorization.Infrastructure { /// /// Requirement that ensures a specific Name diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs index 0beaaa2448..455d66ff24 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs @@ -1,7 +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. -namespace Microsoft.AspNet.Authorization.Infrastructure +namespace Microsoft.AspNetCore.Authorization.Infrastructure { public class OperationAuthorizationRequirement : IAuthorizationRequirement { diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs index 1ea353f934..480e2de0cb 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authorization.Infrastructure +namespace Microsoft.AspNetCore.Authorization.Infrastructure { public class PassThroughAuthorizationHandler : IAuthorizationHandler { diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs index 21b3729de1..217e3ea0c1 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace Microsoft.AspNet.Authorization.Infrastructure +namespace Microsoft.AspNetCore.Authorization.Infrastructure { // Must belong to with one of specified roles // If AllowedRoles is null or empty, that means any role is valid diff --git a/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs index 9242639ffa..116001e659 100644 --- a/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.AspNet.Authorization +namespace Microsoft.AspNetCore.Authorization { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Authorization internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Authorization.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.AspNetCore.Authorization.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// AuthorizationPolicy must have at least one requirement. diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 14245e4d2f..79691d0a48 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Http.Features": "1.0.0-*", + "Microsoft.AspNetCore.Http.Features": "1.0.0-*", "Microsoft.Extensions.Logging.Abstractions": "1.0.0-*", "Microsoft.Extensions.Options": "1.0.0-*" }, diff --git a/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs b/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs index f9d8166612..1b13251f73 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs @@ -1,9 +1,9 @@ // 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; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.CookiePolicy +namespace Microsoft.AspNetCore.CookiePolicy { public class AppendCookieContext { diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs index 02cbd22f96..bb5700fc62 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.CookiePolicy; +using Microsoft.AspNetCore.CookiePolicy; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// Extension methods to add cookie policy capabilities to an HTTP application pipeline. diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs index 2fb299d165..d9a65028c7 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -3,12 +3,12 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Features.Internal; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features.Internal; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.CookiePolicy +namespace Microsoft.AspNetCore.CookiePolicy { public class CookiePolicyMiddleware { diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index ffc2fa7b74..812c714288 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.CookiePolicy; +using Microsoft.AspNetCore.CookiePolicy; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { public class CookiePolicyOptions { diff --git a/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs b/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs index c8cd208fbf..f0693bf71f 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs @@ -1,9 +1,9 @@ // 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; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.CookiePolicy +namespace Microsoft.AspNetCore.CookiePolicy { public class DeleteCookieContext { diff --git a/src/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs b/src/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs index 276e3ed3ee..82305f4754 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs @@ -1,7 +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. -namespace Microsoft.AspNet.CookiePolicy +namespace Microsoft.AspNetCore.CookiePolicy { public enum HttpOnlyPolicy { diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj index 7790eac278..4b5fbfe3b9 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -7,7 +7,7 @@ 86183dc3-02a8-4a68-8b60-71ecec066e79 - Microsoft.AspNet.CookiePolicy + Microsoft.AspNetCore.CookiePolicy ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ diff --git a/src/Microsoft.AspNetCore.CookiePolicy/SecurePolicy.cs b/src/Microsoft.AspNetCore.CookiePolicy/SecurePolicy.cs index 962ecddff7..c0dd639f1c 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/SecurePolicy.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/SecurePolicy.cs @@ -1,7 +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. -namespace Microsoft.AspNet.CookiePolicy +namespace Microsoft.AspNetCore.CookiePolicy { public enum SecurePolicy { diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json index 79ccda4a15..a2c04f1455 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/project.json @@ -10,7 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Http": "1.0.0-*", + "Microsoft.AspNetCore.Http": "1.0.0-*", "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs index 2bfc44fde9..6a1019fbc8 100644 --- a/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs +++ b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs @@ -9,7 +9,7 @@ using Microsoft.Owin.Security.DataHandler.Serializer; namespace Microsoft.Owin.Security.Interop { - // This MUST be kept in sync with Microsoft.AspNet.Authentication.DataHandler.TicketSerializer + // This MUST be kept in sync with Microsoft.AspNetCore.Authentication.DataHandler.TicketSerializer public class AspNetTicketSerializer : IDataSerializer { private const string DefaultStringPlaceholder = "\0"; diff --git a/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs b/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs index 9dc7eedda9..7313588948 100644 --- a/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs +++ b/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNet.DataProtection; +using Microsoft.AspNetCore.DataProtection; namespace Microsoft.Owin.Security.Interop { diff --git a/src/Microsoft.Owin.Security.Interop/project.json b/src/Microsoft.Owin.Security.Interop/project.json index b3c352a874..953428b7b4 100644 --- a/src/Microsoft.Owin.Security.Interop/project.json +++ b/src/Microsoft.Owin.Security.Interop/project.json @@ -1,12 +1,12 @@ -{ +{ "version": "1.0.0-*", "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk" }, - "description": "A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNet.Authentication.", + "description": "A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication.", "dependencies": { - "Microsoft.AspNet.DataProtection.Extensions": "1.0.0-*", + "Microsoft.AspNetCore.DataProtection.Extensions": "1.0.0-*", "Microsoft.Owin.Security": "3.0.1" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs index b5935938ae..431c35bdb5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs @@ -6,16 +6,16 @@ using System.IO; using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Features; -using Microsoft.AspNet.Http.Features.Authentication; -using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.Http.Internal; using Microsoft.Extensions.Logging; using Xunit; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class AuthenticationHandlerFacts { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index e6fc0d709b..158c480516 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -10,17 +10,17 @@ using System.Security.Principal; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Features.Authentication; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Xunit; -namespace Microsoft.AspNet.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication.Cookies { public class CookieMiddlewareTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs index 84d496918a..71590727cb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs @@ -3,11 +3,11 @@ using System; using System.Collections.Generic; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Internal; using Xunit; -namespace Microsoft.AspNet.Authentication.Cookies.Infrastructure +namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure { public class CookieChunkingTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs index 8e62684303..3195298c0d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs @@ -3,7 +3,7 @@ using Xunit; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class Base64UrlTextEncoderTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/SecureDataFormatTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/SecureDataFormatTests.cs index 2cfdd4e793..bda4b09fa7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/SecureDataFormatTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/SecureDataFormatTests.cs @@ -1,13 +1,13 @@ -// 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. using System; using System.Text; -using Microsoft.AspNet.DataProtection; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; using Xunit; -namespace Microsoft.AspNet.Authentication.DataHandler +namespace Microsoft.AspNetCore.Authentication.DataHandler { public class SecureDataFormatTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/TicketSerializerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/TicketSerializerTests.cs index 0ab8bce417..8eeedde0da 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/TicketSerializerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/TicketSerializerTests.cs @@ -5,11 +5,11 @@ using System; using System.IO; using System.Linq; using System.Security.Claims; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Testing.xunit; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Testing.xunit; using Xunit; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class TicketSerializerTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs index 764b63a15a..fa2bed53fd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -8,19 +8,19 @@ using System.Net.Http; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Authentication.Cookies; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using Xunit; -namespace Microsoft.AspNet.Authentication.Facebook +namespace Microsoft.AspNetCore.Authentication.Facebook { public class FacebookMiddlewareTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 29cc78403c..7daec9863b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -9,19 +9,19 @@ using System.Security.Claims; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Features.Authentication; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using Xunit; -namespace Microsoft.AspNet.Authentication.Google +namespace Microsoft.AspNetCore.Authentication.Google { public class GoogleMiddlewareTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 6ff7751a93..72d13a4c9e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -8,18 +8,18 @@ using System.Net.Http; using System.Security.Claims; using System.Threading.Tasks; using System.Xml.Linq; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Features.Authentication; -using Microsoft.AspNet.TestHost; -using Microsoft.AspNet.Testing.xunit; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.TestHost; +using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Tokens; using Xunit; -namespace Microsoft.AspNet.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class JwtBearerMiddlewareTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index 6d41f5a7a6..f80ee21229 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -8,18 +8,18 @@ using System.Security.Claims; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Authentication.OAuth; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using Xunit; -namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount +namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { public class MicrosoftAccountMiddlewareTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs index 66cc84621b..494e2d92a7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs @@ -4,9 +4,9 @@ using System; using System.Text; using System.Text.Encodings.Web; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { /// /// This formatter creates an easy to read string of the format: "'key1' 'value1' ..." diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs index d1f65aed2a..66fc2f4bab 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs @@ -9,7 +9,7 @@ using System.Text.Encodings.Web; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; -namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { /// /// This helper class is used to check that query string parameters are as expected. diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 6661eeb542..4c95083d57 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -11,18 +11,18 @@ using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; using System.Xml.Linq; -using Microsoft.AspNet.Authentication.Cookies; -using Microsoft.AspNet.Authentication.OpenIdConnect; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; -namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { public class OpenIdConnectMiddlewareTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestUtilities.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestUtilities.cs index e48aa66043..6247c85b43 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestUtilities.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestUtilities.cs @@ -4,7 +4,7 @@ using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { /// /// These utilities are designed to test openidconnect related flows diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TestClock.cs b/test/Microsoft.AspNetCore.Authentication.Test/TestClock.cs index 20495125d4..c34e4fd2da 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TestClock.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TestClock.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Authentication; +using Microsoft.AspNetCore.Authentication; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class TestClock : ISystemClock { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs b/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs index 8d3cdb7e29..2e9001dd8c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs @@ -9,10 +9,10 @@ using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public static class TestExtensions { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs b/test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs index 1a93b16df5..5289e38809 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs @@ -5,7 +5,7 @@ using System; using System.Net.Http; using System.Threading.Tasks; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class TestHttpMessageHandler : HttpMessageHandler { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs index e32c3b9261..56058b850f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Net.Http; using System.Xml.Linq; -namespace Microsoft.AspNet.Authentication +namespace Microsoft.AspNetCore.Authentication { public class Transaction { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Twitter/TwitterMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Twitter/TwitterMiddlewareTests.cs index 173de5a82b..2ca2223b97 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Twitter/TwitterMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Twitter/TwitterMiddlewareTests.cs @@ -6,14 +6,14 @@ using System.Net.Http; using System.Security.Claims; using System.Text; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Xunit; -namespace Microsoft.AspNet.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter { public class TwitterMiddlewareTests { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index f9a5e1f3ee..5f6dcb9aeb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -3,15 +3,15 @@ "warningsAsErrors": true }, "dependencies": { - "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNet.Authentication.Facebook": "1.0.0-*", - "Microsoft.AspNet.Authentication.Google": "1.0.0-*", - "Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-*", - "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-*", - "Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*", - "Microsoft.AspNet.Authentication.Twitter": "1.0.0-*", - "Microsoft.AspNet.TestHost": "1.0.0-*", - "Microsoft.AspNet.Testing": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-*", + "Microsoft.AspNetCore.TestHost": "1.0.0-*", + "Microsoft.AspNetCore.Testing": "1.0.0-*", "xunit": "2.1.0" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs index 97430a1215..f74e461523 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -3,11 +3,11 @@ using System; using System.Linq; -using Microsoft.AspNet.Authorization; -using Microsoft.AspNet.Authorization.Infrastructure; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization.Infrastructure; using Xunit; -namespace Microsoft.AspNet.Authroization.Test +namespace Microsoft.AspNetCore.Authroization.Test { public class AuthorizationPolicyFacts { diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index fc4377aebe..89b7d779a5 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -6,11 +6,11 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; -using Microsoft.AspNet.Authorization.Infrastructure; +using Microsoft.AspNetCore.Authorization.Infrastructure; using Microsoft.Extensions.DependencyInjection; using Xunit; -namespace Microsoft.AspNet.Authorization.Test +namespace Microsoft.AspNetCore.Authorization.Test { public class DefaultAuthorizationServiceTests { diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 1fa1347e16..b271d43eb8 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -3,7 +3,7 @@ "warningsAsErrors": true }, "dependencies": { - "Microsoft.AspNet.Authorization": "1.0.0-*", + "Microsoft.AspNetCore.Authorization": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", "Microsoft.Extensions.Logging": "1.0.0-*", "xunit": "2.1.0" diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index f8529e0191..fde6034974 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -3,15 +3,15 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Features; -using Microsoft.AspNet.Http.Features.Internal; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Http.Features.Internal; +using Microsoft.AspNetCore.TestHost; using Xunit; -namespace Microsoft.AspNet.CookiePolicy.Test +namespace Microsoft.AspNetCore.CookiePolicy.Test { public class CookiePolicyTests { diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj index b0a49fdddf..b04b3cd612 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -7,7 +7,7 @@ 1790e052-646f-4529-b90e-6fea95520d69 - Microsoft.AspNet.CookiePolicy.Test + Microsoft.AspNetCore.CookiePolicy.Test ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs index 9cd07cb362..9456094d41 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs @@ -9,10 +9,10 @@ using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; -namespace Microsoft.AspNet.CookiePolicy +namespace Microsoft.AspNetCore.CookiePolicy { // REVIEW: Should find a shared home for these potentially (Copied from Auth tests) public static class TestExtensions diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs index afa9c0c99f..25457e991d 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Net.Http; using System.Xml.Linq; -namespace Microsoft.AspNet.CookiePolicy +namespace Microsoft.AspNetCore.CookiePolicy { // REVIEW: Should find a shared home for these potentially (Copied from Auth tests) public class Transaction diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 66d7c743f4..4ee196a260 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -3,8 +3,8 @@ "warningsAsErrors": true }, "dependencies": { - "Microsoft.AspNet.CookiePolicy": "1.0.0-*", - "Microsoft.AspNet.TestHost": "1.0.0-*", + "Microsoft.AspNetCore.CookiePolicy": "1.0.0-*", + "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", "xunit": "2.1.0" }, diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index 996e181607..08df190117 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -1,4 +1,4 @@ -// 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. using System.IO; @@ -9,10 +9,10 @@ using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Owin.Security.Cookies; using Microsoft.Owin.Testing; @@ -31,7 +31,7 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = new DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNet.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type CookieAuthenticationDefaults.AuthenticationType, "v2"); var interopServer = TestServer.Create(app => @@ -85,7 +85,7 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = new DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNet.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type CookieAuthenticationDefaults.AuthenticationType, "v2"); var builder = new WebHostBuilder() diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs index 7810805523..06073e8b72 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -4,7 +4,7 @@ using System; using System.Linq; using System.Security.Claims; -using Microsoft.AspNet.Authentication; +using Microsoft.AspNetCore.Authentication; using Xunit; namespace Microsoft.Owin.Security.Interop.Test diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index e4af613d9e..660f338685 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -1,10 +1,10 @@ -{ +{ "compilationOptions": { "warningsAsErrors": true }, "dependencies": { - "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNet.TestHost": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", + "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Owin.Security.Cookies": "3.0.1", "Microsoft.Owin.Security.Interop": "1.0.0-*", "Microsoft.Owin.Testing": "3.0.1", From a5b288897d2981c241133b8d37aa22136b653e3a Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 22 Jan 2016 12:39:16 -0800 Subject: [PATCH 451/900] Update ASP.NET 5 versions for ASP.NET Core. See https://github.com/aspnet/Announcements/issues/144 for more information. --- samples/OpenIdConnectSample/project.json | 8 ++++---- .../project.json | 8 ++++---- .../Microsoft.AspNetCore.Authentication.Test/project.json | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 3b2caff5e2..b0befb5403 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -1,15 +1,15 @@ { "dependencies": { "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "frameworks": { - "dnx451": { }, - "dnxcore50": { } + "dnx451": {}, + "dnxcore50": {} }, "compilationOptions": { "emitEntryPoint": true @@ -18,4 +18,4 @@ "web": "OpenIdConnectSample" }, "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 04354e3512..40825201c6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "0.1.0-*", "description": "ASP.NET 5 middleware that enables an application to support the OpenID Connect authentication workflow.", "repository": { "type": "git", @@ -14,7 +14,7 @@ "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { - "net451": { }, - "dotnet54": { } + "net451": {}, + "dotnet54": {} } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 5f6dcb9aeb..dcaa71f520 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -8,7 +8,7 @@ "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*", "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*", "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.AspNetCore.Testing": "1.0.0-*", @@ -16,7 +16,7 @@ }, "frameworks": { "dnx451": { - "frameworkAssemblies": { + "frameworkAssemblies": { "System.Runtime": "", "System.Threading.Tasks": "" }, @@ -24,7 +24,7 @@ "xunit.runner.console": "2.1.0" } }, - "dnxcore50": { + "dnxcore50": { "dependencies": { "xunit.runner.aspnet": "2.0.0-aspnet-*" } @@ -34,4 +34,4 @@ "commands": { "test": "xunit.runner.aspnet" } -} +} \ No newline at end of file From 38de3d6013fd40329b7972c3249cdf76086258c2 Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 22 Jan 2016 16:03:21 -0800 Subject: [PATCH 452/900] #526 Change from storing expires_in to calculating expires_at. --- .../OAuthHandler.cs | 12 ++++++++++-- .../OAuthOptions.cs | 7 +++++++ .../OpenIdConnectHandler.cs | 11 +++++++++-- .../OpenIdConnectOptions.cs | 7 +++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 7f59443bf3..c31f6e29ed 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; @@ -108,8 +109,15 @@ namespace Microsoft.AspNetCore.Authentication.OAuth if (!string.IsNullOrEmpty(tokens.ExpiresIn)) { - identity.AddClaim(new Claim("expires_in", tokens.ExpiresIn, - ClaimValueTypes.String, Options.ClaimsIssuer)); + int value; + if (int.TryParse(tokens.ExpiresIn, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) + { + var expiresAt = Options.SystemClock.UtcNow + TimeSpan.FromSeconds(value); + // https://www.w3.org/TR/xmlschema-2/#dateTime + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx + identity.AddClaim(new Claim("expires_at", expiresAt.ToString("o", CultureInfo.InvariantCulture), + ClaimValueTypes.DateTime, Options.ClaimsIssuer)); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs index 230c7362ad..a094e681ba 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using System.ComponentModel; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.AspNetCore.Http.Authentication; @@ -63,5 +64,11 @@ namespace Microsoft.AspNetCore.Builder /// Gets or sets the type used to secure data handled by the middleware. /// public ISecureDataFormat StateDataFormat { get; set; } + + /// + /// For testing purposes only. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ISystemClock SystemClock { get; set; } = new SystemClock(); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 8ade6ee631..379beba2de 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -778,8 +778,15 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (!string.IsNullOrEmpty(message.ExpiresIn)) { - identity.AddClaim(new Claim(OpenIdConnectParameterNames.ExpiresIn, message.ExpiresIn, - ClaimValueTypes.String, issuer)); + int value; + if (int.TryParse(message.ExpiresIn, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) + { + var expiresAt = Options.SystemClock.UtcNow + TimeSpan.FromSeconds(value); + // https://www.w3.org/TR/xmlschema-2/#dateTime + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx + identity.AddClaim(new Claim("expires_at", expiresAt.ToString("o", CultureInfo.InvariantCulture), + ClaimValueTypes.DateTime, issuer)); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 4ae05a2bba..9e8eef1e19 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.IdentityModel.Tokens.Jwt; using Microsoft.AspNetCore.Authentication; @@ -191,5 +192,11 @@ namespace Microsoft.AspNetCore.Builder /// This is disabled by default. /// public bool SkipUnrecognizedRequests { get; set; } = false; + + /// + /// For testing purposes only. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ISystemClock SystemClock { get; set; } = new SystemClock(); } } From 0c6a805405f8d572b61f9bdc489a86d8825483ff Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 22 Jan 2016 16:11:47 -0800 Subject: [PATCH 453/900] #632 Save twitters access token secret as a claim. --- .../TwitterHandler.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index a4a1a08020..3b66f3128f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -91,6 +91,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter if (Options.SaveTokensAsClaims) { identity.AddClaim(new Claim("access_token", accessToken.Token, ClaimValueTypes.String, Options.ClaimsIssuer)); + identity.AddClaim(new Claim("access_token_secret", accessToken.TokenSecret, ClaimValueTypes.String, Options.ClaimsIssuer)); } return AuthenticateResult.Success(await CreateTicketAsync(identity, properties, accessToken)); From 3780a475283c45c79fd0d4363312e59d482fb09a Mon Sep 17 00:00:00 2001 From: Chris R Date: Sun, 24 Jan 2016 19:21:40 -0800 Subject: [PATCH 454/900] Fix tests broken by renames. --- .../Cookies/CookieMiddlewareTests.cs | 8 +++---- .../Facebook/FacebookMiddlewareTests.cs | 2 +- .../Google/GoogleMiddlewareTests.cs | 22 +++++++++---------- .../MicrosoftAccountMiddlewareTests.cs | 4 ++-- .../OpenIdConnectMiddlewareTests.cs | 2 +- .../Transaction.cs | 2 +- .../Transaction.cs | 2 +- .../CookieInteropTests.cs | 20 ++++++++++------- .../TicketInteropTests.cs | 4 ++-- 9 files changed, 35 insertions(+), 31 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 158c480516..785d5bfa62 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -438,7 +438,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction1 = await SendAsync(server, "http://example.com/testpath"); var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); - Assert.Contains(".AspNet.Cookies=; expires=", transaction2.SetCookie); + Assert.Contains(".AspNetCore.Cookies=; expires=", transaction2.SetCookie); Assert.Null(FindClaimValue(transaction2, ClaimTypes.Name)); } @@ -913,7 +913,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await server.SendAsync("http://example.com"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.True(transaction.SetCookie[0].StartsWith(".AspNet.Cookies=")); + Assert.True(transaction.SetCookie[0].StartsWith(".AspNetCore.Cookies=")); } [Fact] @@ -979,7 +979,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await server.SendAsync("http://example.com/notlogout?ReturnUrl=%2Fpage"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.Contains(".AspNet.Cookies=; expires=", transaction.SetCookie[0]); + Assert.Contains(".AspNetCore.Cookies=; expires=", transaction.SetCookie[0]); } [Fact] @@ -1000,7 +1000,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await server.SendAsync("http://example.com/logout?ReturnUrl=%2Fpage"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Contains(".AspNet.Cookies=; expires=", transaction.SetCookie[0]); + Assert.Contains(".AspNetCore.Cookies=; expires=", transaction.SetCookie[0]); var location = transaction.Response.Headers.Location; Assert.Equal("/page", location.OriginalString); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs index fa2bed53fd..aadb62f51b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -212,7 +212,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook }, handler: null); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Facebook"; + var correlationKey = ".AspNetCore.Correlation.Facebook"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 7daec9863b..854c49ce97 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.Authentication.Google ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/challenge"); - Assert.Contains(".AspNet.Correlation.Google=", transaction.SetCookie.Single()); + Assert.Contains(".AspNetCore.Correlation.Google=", transaction.SetCookie.Single()); } [Fact] @@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Authentication.Google AutomaticChallenge = true }); var transaction = await server.SendAsync("https://example.com/401"); - Assert.Contains(".AspNet.Correlation.Google=", transaction.SetCookie.Single()); + Assert.Contains(".AspNetCore.Correlation.Google=", transaction.SetCookie.Single()); } [Fact] @@ -335,7 +335,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -347,7 +347,7 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); Assert.Contains(correlationKey, transaction.SetCookie[0]); - Assert.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); var authCookie = transaction.AuthenticationCookieValue; transaction = await server.SendAsync("https://example.com/me", authCookie); @@ -394,7 +394,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } : new OAuthEvents() }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -446,7 +446,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } : new OAuthEvents() }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -528,7 +528,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -540,7 +540,7 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); Assert.Contains(correlationKey, transaction.SetCookie[0]); - Assert.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); var authCookie = transaction.AuthenticationCookieValue; transaction = await server.SendAsync("https://example.com/me", authCookie); @@ -607,7 +607,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); var state = stateFormat.Protect(properties); @@ -618,7 +618,7 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal("/", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); Assert.Contains(correlationKey, transaction.SetCookie[0]); - Assert.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); } [Fact] @@ -690,7 +690,7 @@ namespace Microsoft.AspNetCore.Authentication.Google }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/foo"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index f80ee21229..2aad3cfef7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Microsoft"; + var correlationKey = ".AspNetCore.Correlation.Microsoft"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -164,7 +164,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); Assert.Contains(correlationKey, transaction.SetCookie[0]); - Assert.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); var authCookie = transaction.AuthenticationCookieValue; transaction = await server.SendAsync("https://example.com/me", authCookie); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 4c95083d57..040812d88b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -486,7 +486,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { if (SetCookie != null && SetCookie.Count > 0) { - var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNet.Cookie=")); + var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNetCore.Cookie=")); if (authCookie != null) { return authCookie.Substring(0, authCookie.IndexOf(';')); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs index 56058b850f..63f8af1bb2 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs @@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Authentication { if (SetCookie != null && SetCookie.Count > 0) { - var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme + "=")); + var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme + "=")); if (authCookie != null) { return authCookie.Substring(0, authCookie.IndexOf(';')); diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs index 25457e991d..040e0b3391 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.CookiePolicy { if (SetCookie != null && SetCookie.Count > 0) { - var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme + "=")); + var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme + "=")); if (authCookie != null) { return authCookie.Substring(0, authCookie.IndexOf(';')); diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index 08df190117..ef80b78e6e 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -24,7 +24,7 @@ namespace Microsoft.Owin.Security.Interop public class CookiesInteropTests { [Fact] - public async Task AspNet5WithInteropCookieContainsIdentity() + public async Task AspNetCoreWithInteropCookieContainsIdentity() { var identity = new ClaimsIdentity("Cookies"); identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); @@ -40,7 +40,9 @@ namespace Microsoft.Owin.Security.Interop app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)) + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, }); app.Run(context => @@ -55,7 +57,7 @@ namespace Microsoft.Owin.Security.Interop var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions + app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions { DataProtectionProvider = dataProtection }); @@ -66,7 +68,7 @@ namespace Microsoft.Owin.Security.Interop }); }) .ConfigureServices(services => services.AddAuthentication()); - var newServer = new AspNet.TestHost.TestServer(builder); + var newServer = new AspNetCore.TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); request.Headers.Add("Cookie", transaction.SetCookie.Split(new[] { ';' }, 2).First()); @@ -91,14 +93,14 @@ namespace Microsoft.Owin.Security.Interop var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions + app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions { DataProtectionProvider = dataProtection }); app.Run(context => context.Authentication.SignInAsync("Cookies", user)); }) .ConfigureServices(services => services.AddAuthentication()); - var newServer = new AspNet.TestHost.TestServer(builder); + var newServer = new AspNetCore.TestHost.TestServer(builder); var cookie = await SendAndGetCookie(newServer, "http://example.com/login"); @@ -108,7 +110,9 @@ namespace Microsoft.Owin.Security.Interop app.UseCookieAuthentication(new Owin.Security.Cookies.CookieAuthenticationOptions { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)) + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, }); app.Run(async context => @@ -123,7 +127,7 @@ namespace Microsoft.Owin.Security.Interop Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); } - private static async Task SendAndGetCookie(AspNet.TestHost.TestServer server, string uri) + private static async Task SendAndGetCookie(AspNetCore.TestHost.TestServer server, string uri) { var request = new HttpRequestMessage(HttpMethod.Get, uri); var response = await server.CreateClient().SendAsync(request); diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs index 06073e8b72..7b2d261bbf 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -58,14 +58,14 @@ namespace Microsoft.Owin.Security.Interop.Test var expires = DateTime.Today; var issued = new DateTime(1979, 11, 11); - var properties = new AspNet.Http.Authentication.AuthenticationProperties(); + var properties = new AspNetCore.Http.Authentication.AuthenticationProperties(); properties.IsPersistent = true; properties.RedirectUri = "/redirect"; properties.Items["key"] = "value"; properties.ExpiresUtc = expires; properties.IssuedUtc = issued; - var newTicket = new AspNet.Authentication.AuthenticationTicket(user, properties, "scheme"); + var newTicket = new AspNetCore.Authentication.AuthenticationTicket(user, properties, "scheme"); var newSerializer = new TicketSerializer(); var bytes = newSerializer.Serialize(newTicket); From a1aeb4313e420712f519f2df8aab6056c0deb2c0 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 24 Jan 2016 23:57:17 -0800 Subject: [PATCH 455/900] Remove unused dependency - The authorization stack doesn't depend on AspNetCore at all really --- src/Microsoft.AspNetCore.Authorization/project.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 79691d0a48..688fd84037 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -10,12 +10,15 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNetCore.Http.Features": "1.0.0-*", "Microsoft.Extensions.Logging.Abstractions": "1.0.0-*", "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { - "net451": {}, - "dotnet5.4": {} + "net451": { }, + "dotnet5.4": { + "dependencies": { + "System.Security.Claims": "4.0.1-*" + } + } } } \ No newline at end of file From 9c41eb958e1725be1331d8cc64ae49539088a0c3 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 26 Jan 2016 14:28:49 -0800 Subject: [PATCH 456/900] React to IdentityModel breaking change. --- .../OpenIdConnectHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 379beba2de..3650101472 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -511,7 +511,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // no need to validate signature when token is received using "code flow" as per spec [http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation]. var validationParameters = Options.TokenValidationParameters.Clone(); - validationParameters.ValidateSignature = false; + validationParameters.RequireSignedTokens = false; ticket = ValidateToken(tokenEndpointResponse.IdToken, message, properties, validationParameters, out jwt); From 00ceeb026262bc848404d056416709dc306a57df Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 27 Jan 2016 13:36:53 -0800 Subject: [PATCH 457/900] Add IAuthorizationPolicyProvider support --- ...uthorizationServiceCollectionExtensions.cs | 1 + .../DefaultAuthorizationPolicyProvider.cs | 37 ++++++++++++ .../DefaultAuthorizationService.cs | 17 +++--- .../IAuthorizationPolicyProvider.cs | 20 +++++++ .../DefaultAuthorizationServiceTests.cs | 59 +++++++++++++++++++ .../project.json | 1 + 6 files changed, 126 insertions(+), 9 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs index 120dffda57..d03f9ed746 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -26,6 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection } services.TryAdd(ServiceDescriptor.Transient()); + services.TryAdd(ServiceDescriptor.Transient()); services.TryAddEnumerable(ServiceDescriptor.Transient()); return services; } diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs new file mode 100644 index 0000000000..97b806e87d --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -0,0 +1,37 @@ +// 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.Threading.Tasks; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// A type which can provide a for a particular name. + /// + public class DefaultAuthorizationPolicyProvider : IAuthorizationPolicyProvider + { + private readonly AuthorizationOptions _options; + + public DefaultAuthorizationPolicyProvider(IOptions options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + _options = options.Value; + } + + /// + /// Gets a from the given + /// + /// + /// + public virtual Task GetPolicyAsync(string policyName) + { + return Task.FromResult(_options.GetPolicy(policyName)); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index d501f1b20e..c5bdcc7a76 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -7,21 +7,20 @@ using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authorization { public class DefaultAuthorizationService : IAuthorizationService { + private readonly IAuthorizationPolicyProvider _policyProvider; private readonly IList _handlers; - private readonly AuthorizationOptions _options; private readonly ILogger _logger; - public DefaultAuthorizationService(IOptions options, IEnumerable handlers, ILogger logger) + public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) { - if (options == null) + if (policyProvider == null) { - throw new ArgumentNullException(nameof(options)); + throw new ArgumentNullException(nameof(policyProvider)); } if (handlers == null) { @@ -33,7 +32,7 @@ namespace Microsoft.AspNetCore.Authorization } _handlers = handlers.ToArray(); - _options = options.Value; + _policyProvider = policyProvider; _logger = logger; } @@ -62,19 +61,19 @@ namespace Microsoft.AspNetCore.Authorization } } - public Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) + public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) { if (policyName == null) { throw new ArgumentNullException(nameof(policyName)); } - var policy = _options.GetPolicy(policyName); + var policy = await _policyProvider.GetPolicyAsync(policyName); if (policy == null) { throw new InvalidOperationException($"No policy found: {policyName}."); } - return this.AuthorizeAsync(user, resource, policy); + return await this.AuthorizeAsync(user, resource, policy); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs new file mode 100644 index 0000000000..1a0dbace60 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs @@ -0,0 +1,20 @@ +// 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.Threading.Tasks; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// A type which can provide a for a particular name. + /// + public interface IAuthorizationPolicyProvider + { + /// + /// Gets a from the given + /// + /// + /// + Task GetPolicyAsync(string policyName); + } +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 89b7d779a5..60988448ba 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -922,5 +922,64 @@ namespace Microsoft.AspNetCore.Authorization.Test // Assert Assert.True(allowed); } + + public class StaticPolicyProvider : IAuthorizationPolicyProvider + { + public Task GetPolicyAsync(string policyName) + { + return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); + } + } + + [Fact] + public async Task CanReplaceDefaultPolicyProvider() + { + var authorizationService = BuildAuthorizationService(services => + { + // This will ignore the policy options + services.AddSingleton(); + services.AddAuthorization(options => + { + options.AddPolicy("Basic", policy => policy.RequireAssertion(context => true)); + }); + }); + var user = new ClaimsPrincipal(); + + // Act + var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); + + // Assert + Assert.False(allowed); + } + + public class DynamicPolicyProvider : IAuthorizationPolicyProvider + { + public Task GetPolicyAsync(string policyName) + { + return Task.FromResult(new AuthorizationPolicyBuilder().RequireClaim(policyName).Build()); + } + } + + [Fact] + public async Task CanUseDynamicPolicyProvider() + { + var authorizationService = BuildAuthorizationService(services => + { + // This will ignore the policy options + services.AddSingleton(); + services.AddAuthorization(options => { }); + }); + var id = new ClaimsIdentity(); + id.AddClaim(new Claim("1", "1")); + id.AddClaim(new Claim("2", "2")); + var user = new ClaimsPrincipal(id); + + // Act + // Assert + Assert.False(await authorizationService.AuthorizeAsync(user, "0")); + Assert.True(await authorizationService.AuthorizeAsync(user, "1")); + Assert.True(await authorizationService.AuthorizeAsync(user, "2")); + Assert.False(await authorizationService.AuthorizeAsync(user, "3")); + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index b271d43eb8..a2b212276f 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -4,6 +4,7 @@ }, "dependencies": { "Microsoft.AspNetCore.Authorization": "1.0.0-*", + "Microsoft.AspNetCore.Testing": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", "Microsoft.Extensions.Logging": "1.0.0-*", "xunit": "2.1.0" From 297c72aa2176265d680b0d102ac1932220919053 Mon Sep 17 00:00:00 2001 From: Brennan Date: Thu, 21 Jan 2016 10:02:03 -0800 Subject: [PATCH 458/900] React to Logging API changes --- .../JwtBearerHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 67889d51db..00ecae0fb2 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } catch (Exception ex) { - Logger.LogInformation("Failed to validate the token: " + token, ex); + Logger.LogInformation(0, ex, "Failed to validate the token: " + token); // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the event. if (Options.RefreshOnIssuerKeyNotFound && ex.GetType().Equals(typeof(SecurityTokenSignatureKeyNotFoundException))) @@ -181,7 +181,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } catch (Exception ex) { - Logger.LogError("Exception occurred while processing message", ex); + Logger.LogError(0, ex, "Exception occurred while processing message"); var authenticationFailedContext = new AuthenticationFailedContext(Context, Options) { From a80c5e6d85a4a5f9c1a18c97c8b01f82306516ef Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 27 Jan 2016 14:44:18 -0800 Subject: [PATCH 459/900] #614 Standardize the pattern for scope defaults. --- samples/SocialSample/Startup.cs | 6 +++--- .../GoogleMiddleware.cs | 10 ---------- .../GoogleOptions.cs | 3 +++ .../MicrosoftAccountMiddleware.cs | 7 ------- .../MicrosoftAccountOptions.cs | 1 + 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index e959943798..8e6cd1768f 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -133,18 +133,18 @@ namespace CookieSample The MicrosoftAccount service has restrictions that prevent the use of http://localhost:54540/ for test applications. As such, here is how to change this sample to uses http://mssecsample.localhost.this:54540/ instead. - Edit the Project.json file and replace http://localhost:54540/ with http://mssecsample.localhost.this:54540/. + Edit the hosting.json file and add "server.urls": "http://mssecsample.localhost.this:54540/". From an admin command console first enter: notepad C:\Windows\System32\drivers\etc\hosts and add this to the file, save, and exit (and reboot?): 127.0.0.1 MsSecSample.localhost.this - Then you can choose to run the app as admin (see below) or add the following ACL as admin: + [WebListener] Then you can choose to run the app as admin (see below) or add the following ACL as admin: netsh http add urlacl url=http://mssecsample.localhost.this:54540/ user=[domain\user] The sample app can then be run via: - dnx . web + dnx web */ app.UseOAuthAuthentication(new OAuthOptions { diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs index 565d89b0cf..f81497f26a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs @@ -67,16 +67,6 @@ namespace Microsoft.AspNetCore.Authentication.Google { throw new ArgumentNullException(nameof(options)); } - - if (Options.Scope.Count == 0) - { - // Google OAuth 2.0 asks for non-empty scope. If user didn't set it, set default scope to - // "openid profile email" to get basic user information. - // TODO: Should we just add these by default when we create the Options? - Options.Scope.Add("openid"); - Options.Scope.Add("profile"); - Options.Scope.Add("email"); - } } /// diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs index 208d710650..3d93b96ea8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs @@ -22,6 +22,9 @@ namespace Microsoft.AspNetCore.Builder AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint; TokenEndpoint = GoogleDefaults.TokenEndpoint; UserInformationEndpoint = GoogleDefaults.UserInformationEndpoint; + Scope.Add("openid"); + Scope.Add("profile"); + Scope.Add("email"); } /// diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs index 8daa9b2add..e7ba9f8117 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs @@ -65,13 +65,6 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { throw new ArgumentNullException(nameof(options)); } - - if (Options.Scope.Count == 0) - { - // LiveID requires a scope string, so if the user didn't set one we go for the least possible. - // TODO: Should we just add these by default when we create the Options? - Options.Scope.Add("wl.basic"); - } } /// diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs index 7adfa57057..2783bcef1f 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -22,6 +22,7 @@ namespace Microsoft.AspNetCore.Builder AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint; TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; UserInformationEndpoint = MicrosoftAccountDefaults.UserInformationEndpoint; + Scope.Add("wl.basic"); } } } From 80dc5759cc1f9cd447724ff068cc8253fe7b2b1c Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 27 Jan 2016 16:35:43 -0800 Subject: [PATCH 460/900] Async overloads for AuthZ RequireAssertion --- .../AuthorizationPolicyBuilder.cs | 17 +++++++++++++++ .../Infrastructure/AssertionRequirement.cs | 21 ++++++++++++++----- .../DefaultAuthorizationServiceTests.cs | 19 +++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs index 0cc0195e60..965ffe02ef 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization.Infrastructure; namespace Microsoft.AspNetCore.Authorization @@ -139,6 +140,22 @@ namespace Microsoft.AspNetCore.Authorization return this; } + /// + /// Requires that this Function returns true + /// + /// Function that must return true + /// + public AuthorizationPolicyBuilder RequireAssertion(Func> assert) + { + if (assert == null) + { + throw new ArgumentNullException(nameof(assert)); + } + + Requirements.Add(new AssertionRequirement(assert)); + return this; + } + public AuthorizationPolicy Build() { return new AuthorizationPolicy(Requirements, AuthenticationSchemes.Distinct()); diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs index 0d3ab2bf28..0cc1751a49 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs @@ -2,15 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { - public class AssertionRequirement : AuthorizationHandler, IAuthorizationRequirement + public class AssertionRequirement : IAuthorizationHandler, IAuthorizationRequirement { /// /// Function that is called to handle this requirement /// - public Func Handler { get; } + public Func> Handler { get; } public AssertionRequirement(Func assert) { @@ -19,14 +20,24 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure throw new ArgumentNullException(nameof(assert)); } + Handler = context => Task.FromResult(assert(context)); + } + + public AssertionRequirement(Func> assert) + { + if (assert == null) + { + throw new ArgumentNullException(nameof(assert)); + } + Handler = assert; } - protected override void Handle(AuthorizationContext context, AssertionRequirement requirement) + public async Task HandleAsync(AuthorizationContext context) { - if (Handler(context)) + if (await Handler(context)) { - context.Succeed(requirement); + context.Succeed(this); } } } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 60988448ba..7f11916940 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -923,6 +923,25 @@ namespace Microsoft.AspNetCore.Authorization.Test Assert.True(allowed); } + [Fact] + public async Task CanAuthorizeWithAsyncAssertionRequirement() + { + var authorizationService = BuildAuthorizationService(services => + { + services.AddAuthorization(options => + { + options.AddPolicy("Basic", policy => policy.RequireAssertion(context => Task.FromResult(true))); + }); + }); + var user = new ClaimsPrincipal(); + + // Act + var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); + + // Assert + Assert.True(allowed); + } + public class StaticPolicyProvider : IAuthorizationPolicyProvider { public Task GetPolicyAsync(string policyName) From e737f3207e8ceb80f6bcf1286b4ea0fec9ea72ea Mon Sep 17 00:00:00 2001 From: Mike Surcouf Date: Tue, 26 Jan 2016 13:38:50 +0000 Subject: [PATCH 461/900] Remove username from Facebook Add default fields for Facebook Remove default fields except name and email Add all the core fields for Facebook Fix location and field uniqueness --- .../FacebookHandler.cs | 70 +++++++-- .../FacebookHelper.cs | 148 ++++++++++++++++-- .../FacebookMiddleware.cs | 1 + .../FacebookOptions.cs | 7 +- 4 files changed, 202 insertions(+), 24 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 126f48d66d..675ae51494 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -48,10 +48,22 @@ namespace Microsoft.AspNetCore.Authentication.Facebook identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, identifier, ClaimValueTypes.String, Options.ClaimsIssuer)); } - var userName = FacebookHelper.GetUserName(payload); - if (!string.IsNullOrEmpty(userName)) + var ageRangeMin = FacebookHelper.GetAgeRangeMin(payload); + if (!string.IsNullOrEmpty(ageRangeMin)) { - identity.AddClaim(new Claim(ClaimsIdentity.DefaultNameClaimType, userName, ClaimValueTypes.String, Options.ClaimsIssuer)); + identity.AddClaim(new Claim("urn:facebook:age_range_min", ageRangeMin, ClaimValueTypes.String, Options.ClaimsIssuer)); + } + + var ageRangeMax = FacebookHelper.GetAgeRangeMax(payload); + if (!string.IsNullOrEmpty(ageRangeMax)) + { + identity.AddClaim(new Claim("urn:facebook:age_range_max", ageRangeMax, ClaimValueTypes.String, Options.ClaimsIssuer)); + } + + var birthday = FacebookHelper.GetBirthday(payload); + if (!string.IsNullOrEmpty(birthday)) + { + identity.AddClaim(new Claim(ClaimTypes.DateOfBirth, birthday, ClaimValueTypes.String, Options.ClaimsIssuer)); } var email = FacebookHelper.GetEmail(payload); @@ -60,16 +72,22 @@ namespace Microsoft.AspNetCore.Authentication.Facebook identity.AddClaim(new Claim(ClaimTypes.Email, email, ClaimValueTypes.String, Options.ClaimsIssuer)); } - var name = FacebookHelper.GetName(payload); - if (!string.IsNullOrEmpty(name)) + var firstName = FacebookHelper.GetFirstName(payload); + if (!string.IsNullOrEmpty(firstName)) { - identity.AddClaim(new Claim("urn:facebook:name", name, ClaimValueTypes.String, Options.ClaimsIssuer)); + identity.AddClaim(new Claim(ClaimTypes.GivenName, firstName, ClaimValueTypes.String, Options.ClaimsIssuer)); + } - // Many Facebook accounts do not set the UserName field. Fall back to the Name field instead. - if (string.IsNullOrEmpty(userName)) - { - identity.AddClaim(new Claim(identity.NameClaimType, name, ClaimValueTypes.String, Options.ClaimsIssuer)); - } + var gender = FacebookHelper.GetGender(payload); + if (!string.IsNullOrEmpty(gender)) + { + identity.AddClaim(new Claim(ClaimTypes.Gender, gender, ClaimValueTypes.String, Options.ClaimsIssuer)); + } + + var lastName = FacebookHelper.GetLastName(payload); + if (!string.IsNullOrEmpty(lastName)) + { + identity.AddClaim(new Claim(ClaimTypes.Surname, lastName, ClaimValueTypes.String, Options.ClaimsIssuer)); } var link = FacebookHelper.GetLink(payload); @@ -78,6 +96,36 @@ namespace Microsoft.AspNetCore.Authentication.Facebook identity.AddClaim(new Claim("urn:facebook:link", link, ClaimValueTypes.String, Options.ClaimsIssuer)); } + var location = FacebookHelper.GetLocation(payload); + if (!string.IsNullOrEmpty(location)) + { + identity.AddClaim(new Claim("urn:facebook:location", location, ClaimValueTypes.String, Options.ClaimsIssuer)); + } + + var locale = FacebookHelper.GetLocale(payload); + if (!string.IsNullOrEmpty(locale)) + { + identity.AddClaim(new Claim(ClaimTypes.Locality, locale, ClaimValueTypes.String, Options.ClaimsIssuer)); + } + + var middleName = FacebookHelper.GetMiddleName(payload); + if (!string.IsNullOrEmpty(middleName)) + { + identity.AddClaim(new Claim("urn:facebook:middle_name", middleName, ClaimValueTypes.String, Options.ClaimsIssuer)); + } + + var name = FacebookHelper.GetName(payload); + if (!string.IsNullOrEmpty(name)) + { + identity.AddClaim(new Claim(ClaimTypes.Name, name, ClaimValueTypes.String, Options.ClaimsIssuer)); + } + + var timeZone = FacebookHelper.GetTimeZone(payload); + if (!string.IsNullOrEmpty(timeZone)) + { + identity.AddClaim(new Claim("urn:facebook:timezone", timeZone, ClaimValueTypes.String, Options.ClaimsIssuer)); + } + await Options.Events.CreatingTicket(context); return context.Ticket; diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs index af68a7c32a..48e3590990 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs @@ -26,16 +26,91 @@ namespace Microsoft.AspNetCore.Authentication.Facebook } /// - /// Gets the user's name. + /// Gets the user's min age. /// - public static string GetName(JObject user) + public static string GetAgeRangeMin(JObject user) + { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + return TryGetValue(user, "age_range", "min"); + } + + /// + /// Gets the user's max age. + /// + public static string GetAgeRangeMax(JObject user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } - return user.Value("name"); + return TryGetValue(user, "age_range", "max"); + } + + /// + /// Gets the user's birthday. + /// + public static string GetBirthday(JObject user) + { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + return user.Value("birthday"); + } + + /// + /// Gets the Facebook email. + /// + public static string GetEmail(JObject user) + { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + + return user.Value("email"); + } + + /// + /// Gets the user's first name. + /// + public static string GetFirstName(JObject user) + { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + + return user.Value("first_name"); + } + + /// + /// Gets the user's gender. + /// + public static string GetGender(JObject user) + { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + return user.Value("gender"); + } + + /// + /// Gets the user's family name. + /// + public static string GetLastName(JObject user) + { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + + return user.Value("last_name"); } /// @@ -51,30 +126,81 @@ namespace Microsoft.AspNetCore.Authentication.Facebook } /// - /// Gets the Facebook username. + /// Gets the user's location. /// - public static string GetUserName(JObject user) + public static string GetLocation(JObject user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } - - return user.Value("username"); + return TryGetValue(user, "location", "name"); } - /// - /// Gets the Facebook email. + /// Gets the user's locale. /// - public static string GetEmail(JObject user) + public static string GetLocale(JObject user) + { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + return user.Value("locale"); + } + + /// + /// Gets the user's middle name. + /// + public static string GetMiddleName(JObject user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } - return user.Value("email"); + return user.Value("middle_name"); } + + /// + /// Gets the user's name. + /// + public static string GetName(JObject user) + { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + + return user.Value("name"); + } + + /// + /// Gets the user's timezone. + /// + public static string GetTimeZone(JObject user) + { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + return user.Value("timezone"); + } + + // Get the given subProperty from a property. + private static string TryGetValue(JObject user, string propertyName, string subProperty) + { + JToken value; + if (user.TryGetValue(propertyName, out value)) + { + var subObject = JObject.Parse(value.ToString()); + if (subObject != null && subObject.TryGetValue(subProperty, out value)) + { + return value.ToString(); + } + } + return null; + } + } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs index 4ceda639cc..16b60e1dd4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs @@ -71,6 +71,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.AppId))); } + if (string.IsNullOrEmpty(Options.AppSecret)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.AppSecret))); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs index af82c6f9a7..ac6987f3df 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs @@ -24,7 +24,10 @@ namespace Microsoft.AspNetCore.Builder AuthorizationEndpoint = FacebookDefaults.AuthorizationEndpoint; TokenEndpoint = FacebookDefaults.TokenEndpoint; UserInformationEndpoint = FacebookDefaults.UserInformationEndpoint; - Fields = new List(); + Scope.Add("public_profile"); + Scope.Add("email"); + Fields.Add("name"); + Fields.Add("email"); } // Facebook uses a non-standard term for this field. @@ -57,6 +60,6 @@ namespace Microsoft.AspNetCore.Builder /// The list of fields to retrieve from the UserInformationEndpoint. /// https://developers.facebook.com/docs/graph-api/reference/user /// - public IList Fields { get; } + public ICollection Fields { get; } = new HashSet(); } } From e00453af4dffdd861de65de88b4ecdfe8adc9e59 Mon Sep 17 00:00:00 2001 From: Mike Surcouf Date: Thu, 4 Feb 2016 09:08:03 +0000 Subject: [PATCH 462/900] Ensure scope has no duplicates --- src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs | 4 ++-- .../OpenIdConnectOptions.cs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs index a094e681ba..22d5e35573 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -56,9 +56,9 @@ namespace Microsoft.AspNetCore.Builder } /// - /// A list of permissions to request. + /// Gets the list of permissions to request. /// - public IList Scope { get; } = new List(); + public ICollection Scope { get; } = new HashSet(); /// /// Gets or sets the type used to secure data handled by the middleware. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 9e8eef1e19..de7bee1633 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -53,6 +53,8 @@ namespace Microsoft.AspNetCore.Builder DisplayName = OpenIdConnectDefaults.Caption; CallbackPath = new PathString("/signin-oidc"); Events = new OpenIdConnectEvents(); + Scope.Add("openid"); + Scope.Add("profile"); } /// @@ -155,7 +157,7 @@ namespace Microsoft.AspNetCore.Builder /// /// Gets the list of permissions to request. /// - public IList Scope { get; } = new List { "openid", "profile" }; + public ICollection Scope { get; } = new HashSet(); /// /// Gets or sets the type used to secure data handled by the middleware. From 1b4ccd0ddfc97f57818fdaee0989518760e4d0c0 Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Thu, 4 Feb 2016 13:31:57 +0300 Subject: [PATCH 463/900] Add 'UseServer' --- samples/CookieSample/Startup.cs | 1 + samples/CookieSample/hosting.json | 3 --- samples/CookieSessionSample/Startup.cs | 1 + samples/CookieSessionSample/hosting.json | 3 --- samples/JwtBearerSample/Startup.cs | 1 + samples/JwtBearerSample/hosting.json | 3 --- samples/OpenIdConnectSample/Startup.cs | 1 + samples/OpenIdConnectSample/hosting.json | 3 --- samples/SocialSample/Startup.cs | 1 + samples/SocialSample/hosting.json | 3 --- 10 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 samples/CookieSample/hosting.json delete mode 100644 samples/CookieSessionSample/hosting.json delete mode 100644 samples/JwtBearerSample/hosting.json delete mode 100644 samples/OpenIdConnectSample/hosting.json delete mode 100644 samples/SocialSample/hosting.json diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 1f8b494c41..8b0568b313 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -46,6 +46,7 @@ namespace CookieSample { var host = new WebHostBuilder() .UseDefaultConfiguration(args) + .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/CookieSample/hosting.json b/samples/CookieSample/hosting.json deleted file mode 100644 index 6a93dbafa8..0000000000 --- a/samples/CookieSample/hosting.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "server": "Microsoft.AspNetCore.Server.Kestrel" -} diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 57593d8789..3db8f11556 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -56,6 +56,7 @@ namespace CookieSessionSample { var host = new WebHostBuilder() .UseDefaultConfiguration(args) + .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/CookieSessionSample/hosting.json b/samples/CookieSessionSample/hosting.json deleted file mode 100644 index 6a93dbafa8..0000000000 --- a/samples/CookieSessionSample/hosting.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "server": "Microsoft.AspNetCore.Server.Kestrel" -} diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 34ee646c77..3a4ecfba6c 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -116,6 +116,7 @@ namespace JwtBearerSample { var host = new WebHostBuilder() .UseDefaultConfiguration(args) + .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/JwtBearerSample/hosting.json b/samples/JwtBearerSample/hosting.json deleted file mode 100644 index 6a93dbafa8..0000000000 --- a/samples/JwtBearerSample/hosting.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "server": "Microsoft.AspNetCore.Server.Kestrel" -} diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 11a95a5717..f0f9feb3ae 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -70,6 +70,7 @@ namespace OpenIdConnectSample { var host = new WebHostBuilder() .UseDefaultConfiguration(args) + .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/OpenIdConnectSample/hosting.json b/samples/OpenIdConnectSample/hosting.json deleted file mode 100644 index 6a93dbafa8..0000000000 --- a/samples/OpenIdConnectSample/hosting.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "server": "Microsoft.AspNetCore.Server.Kestrel" -} diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 8e6cd1768f..ffbaf8dc59 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -327,6 +327,7 @@ namespace CookieSample { var host = new WebHostBuilder() .UseDefaultConfiguration(args) + .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/samples/SocialSample/hosting.json b/samples/SocialSample/hosting.json deleted file mode 100644 index 6a93dbafa8..0000000000 --- a/samples/SocialSample/hosting.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "server": "Microsoft.AspNetCore.Server.Kestrel" -} From c2194ea99d5acdcf755c31a33005d36844f633c2 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 4 Feb 2016 15:50:27 -0800 Subject: [PATCH 464/900] Updated Json.Net versions --- src/Microsoft.AspNetCore.Authentication.Cookies/project.json | 3 +-- src/Microsoft.AspNetCore.Authentication.Facebook/project.json | 3 +-- src/Microsoft.AspNetCore.Authentication.OAuth/project.json | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index de5c6c09dc..5ceb5b7a64 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -12,8 +12,7 @@ "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", "Microsoft.Extensions.Options": "1.0.0-*", - "Microsoft.Extensions.WebEncoders": "1.0.0-*", - "Newtonsoft.Json": "6.0.6" + "Microsoft.Extensions.WebEncoders": "1.0.0-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 2a11e8fd5c..479a08011a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -10,8 +10,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*", - "Newtonsoft.Json": "6.0.6" + "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index 352ccfe905..5049862100 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -11,7 +11,7 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", - "Newtonsoft.Json": "6.0.6" + "Newtonsoft.Json": "8.0.2" }, "frameworks": { "net451": { From bafb097e9f8a770d31c8d1558729330d93fb47f8 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sat, 6 Feb 2016 19:10:09 -0800 Subject: [PATCH 465/900] Update to new CLI. - Added appropriate imports/net core platform libraries. --- samples/CookieSample/project.json | 3 ++- samples/CookieSessionSample/project.json | 3 ++- samples/JwtBearerSample/project.json | 3 ++- samples/OpenIdConnectSample/project.json | 3 ++- samples/SocialSample/project.json | 3 ++- .../project.json | 4 +++- src/Microsoft.AspNetCore.Authentication.Google/project.json | 4 +++- .../project.json | 4 +++- .../project.json | 4 +++- src/Microsoft.AspNetCore.Authentication.OAuth/project.json | 3 ++- .../project.json | 4 +++- src/Microsoft.AspNetCore.Authentication/project.json | 3 ++- test/Microsoft.AspNetCore.Authentication.Test/project.json | 5 ++++- test/Microsoft.AspNetCore.Authorization.Test/project.json | 6 ++++-- test/Microsoft.AspNetCore.CookiePolicy.Test/project.json | 6 ++++-- test/Microsoft.Owin.Security.Interop.Test/project.json | 1 + 16 files changed, 42 insertions(+), 17 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 22d51833b2..fa17dd9cf3 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -4,7 +4,8 @@ "Microsoft.AspNetCore.DataProtection": "1.0.0-*", "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*" }, "compilationOptions": { "emitEntryPoint": true diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index dd58262480..8de831b403 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -5,7 +5,8 @@ "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Caching.Memory": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*" }, "compilationOptions": { "emitEntryPoint": true diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 9ba387d674..436a2203be 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -8,7 +8,8 @@ "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*" + "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*" }, "commands": { "web": "JwtBearerSample" diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index b0befb5403..e5bec9e8c6 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -5,7 +5,8 @@ "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*" }, "frameworks": { "dnx451": {}, diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index a8eb114c99..00570902f6 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -9,7 +9,8 @@ "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*" }, "compilationOptions": { "emitEntryPoint": true diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 479a08011a..5dbf6f6cfb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -14,6 +14,8 @@ }, "frameworks": { "net451": {}, - "dotnet5.4": {} + "dotnet5.4": { + "imports": "portable-net451+win8" + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index 10862c3180..929424cc14 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -14,6 +14,8 @@ }, "frameworks": { "net451": {}, - "dotnet5.4": {} + "dotnet5.4": { + "imports": "portable-net451+win8" + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 0ff2727364..f6e200b7c2 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -15,6 +15,8 @@ }, "frameworks": { "net451": { }, - "dotnet54": { } + "dotnet5.4": { + "imports": "portable-net451+win8" + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index db03dbd5c7..c415b2a63f 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -14,6 +14,8 @@ }, "frameworks": { "net451": {}, - "dotnet5.4": {} + "dotnet5.4": { + "imports": "portable-net451+win8" + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index 5049862100..c5128412c4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -22,7 +22,8 @@ "dotnet5.4": { "dependencies": { "System.Net.Http": "4.0.1-*" - } + }, + "imports": "portable-net451+win8" } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 40825201c6..90487a898b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -15,6 +15,8 @@ }, "frameworks": { "net451": {}, - "dotnet54": {} + "dotnet5.4": { + "imports": "portable-net451+win8" + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index c7a58a242c..d34a6697bc 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -30,7 +30,8 @@ "dotnet5.4": { "dependencies": { "System.Net.Http": "4.0.1-*" - } + }, + "imports": "portable-net451" } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index dcaa71f520..2048801a64 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -12,6 +12,7 @@ "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.AspNetCore.Testing": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0" }, "frameworks": { @@ -26,8 +27,10 @@ }, "dnxcore50": { "dependencies": { + "System.Runtime": "4.0.21-*", "xunit.runner.aspnet": "2.0.0-aspnet-*" - } + }, + "imports": "portable-net451+win8" } }, "testRunner": "xunit", diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index a2b212276f..d5d5544626 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -7,6 +7,7 @@ "Microsoft.AspNetCore.Testing": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", "Microsoft.Extensions.Logging": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0" }, "frameworks": { @@ -19,10 +20,11 @@ "xunit.runner.console": "2.1.0" } }, - "dnxcore50": { + "dnxcore50": { "dependencies": { "xunit.runner.aspnet": "2.0.0-aspnet-*" - } + }, + "imports": "portable-net451+win8" } }, "testRunner": "xunit", diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 4ee196a260..d39a059744 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -6,6 +6,7 @@ "Microsoft.AspNetCore.CookiePolicy": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0" }, "frameworks": { @@ -19,10 +20,11 @@ "xunit.runner.console": "2.1.0" } }, - "dnxcore50": { + "dnxcore50": { "dependencies": { "xunit.runner.aspnet": "2.0.0-aspnet-*" - } + }, + "imports": "portable-net451+win8" } }, "testRunner": "xunit", diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index 660f338685..46fd46b489 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -8,6 +8,7 @@ "Microsoft.Owin.Security.Cookies": "3.0.1", "Microsoft.Owin.Security.Interop": "1.0.0-*", "Microsoft.Owin.Testing": "3.0.1", + "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0", "xunit.runner.console": "2.1.0" }, From bbcabc0212a298ec5d30ed7f25aa9ee40c511a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Mon, 18 Jan 2016 00:20:44 +0100 Subject: [PATCH 466/900] Move GenerateCorrelationId and ValidateCorrelationId to RemoteAuthenticationHandler --- .../Constants.cs | 12 --- .../OAuthHandler.cs | 77 ++----------------- .../OpenIdConnectDefaults.cs | 5 -- .../OpenIdConnectHandler.cs | 77 ++----------------- .../TwitterHandler.cs | 6 +- .../TwitterOptions.cs | 7 ++ .../RemoteAuthenticationHandler.cs | 75 ++++++++++++++++++ .../RemoteAuthenticationOptions.cs | 5 ++ .../Facebook/FacebookMiddlewareTests.cs | 4 +- .../Google/GoogleMiddlewareTests.cs | 34 ++++---- .../MicrosoftAccountMiddlewareTests.cs | 6 +- ...uthenticationPropertiesFormaterKeyValue.cs | 3 +- .../OpenIdConnectMiddlewareTests.cs | 2 +- 13 files changed, 126 insertions(+), 187 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Constants.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Constants.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Constants.cs deleted file mode 100644 index fb4d8b76d8..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Constants.cs +++ /dev/null @@ -1,12 +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.AspNetCore.Authentication.OAuth -{ - internal static class Constants - { - internal const string SecurityAuthenticate = "security.Authenticate"; - internal const string CorrelationPrefix = ".AspNetCore.Correlation."; - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index c31f6e29ed..7a06bee702 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -7,15 +7,12 @@ using System.Globalization; using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; -using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; @@ -23,8 +20,6 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { public class OAuthHandler : RemoteAuthenticationHandler where TOptions : OAuthOptions { - private static readonly RandomNumberGenerator CryptoRandom = RandomNumberGenerator.Create(); - public OAuthHandler(HttpClient backchannel) { Backchannel = backchannel; @@ -177,7 +172,11 @@ namespace Microsoft.AspNetCore.Authentication.OAuth throw new ArgumentNullException(nameof(context)); } - var properties = new AuthenticationProperties(context.Properties); + var properties = new AuthenticationProperties(context.Properties) + { + ExpiresUtc = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout) + }; + if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; @@ -216,71 +215,5 @@ namespace Microsoft.AspNetCore.Authentication.OAuth // OAuth2 3.3 space separated return string.Join(" ", Options.Scope); } - - protected void GenerateCorrelationId(AuthenticationProperties properties) - { - if (properties == null) - { - throw new ArgumentNullException(nameof(properties)); - } - - var correlationKey = Constants.CorrelationPrefix + Options.AuthenticationScheme; - - var nonceBytes = new byte[32]; - CryptoRandom.GetBytes(nonceBytes); - var correlationId = Base64UrlTextEncoder.Encode(nonceBytes); - - var cookieOptions = new CookieOptions - { - HttpOnly = true, - Secure = Request.IsHttps - }; - - properties.Items[correlationKey] = correlationId; - - Response.Cookies.Append(correlationKey, correlationId, cookieOptions); - } - - protected bool ValidateCorrelationId(AuthenticationProperties properties) - { - if (properties == null) - { - throw new ArgumentNullException(nameof(properties)); - } - - var correlationKey = Constants.CorrelationPrefix + Options.AuthenticationScheme; - var correlationCookie = Request.Cookies[correlationKey]; - if (string.IsNullOrEmpty(correlationCookie)) - { - Logger.LogWarning("{0} cookie not found.", correlationKey); - return false; - } - - var cookieOptions = new CookieOptions - { - HttpOnly = true, - Secure = Request.IsHttps - }; - Response.Cookies.Delete(correlationKey, cookieOptions); - - string correlationExtra; - if (!properties.Items.TryGetValue( - correlationKey, - out correlationExtra)) - { - Logger.LogWarning("{0} state property not found.", correlationKey); - return false; - } - - properties.Items.Remove(correlationKey); - - if (!string.Equals(correlationCookie, correlationExtra, StringComparison.Ordinal)) - { - Logger.LogWarning("{0} correlation cookie and state property mismatch.", correlationKey); - return false; - } - - return true; - } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs index 378c594479..a099a72769 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs @@ -28,11 +28,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// public static readonly string CookieNoncePrefix = ".AspNetCore.OpenIdConnect.Nonce."; - /// - /// The prefix used for the state in the cookie. - /// - public static readonly string CookieStatePrefix = ".AspNetCore.OpenIdConnect.State."; - /// /// The property for the RedirectUri that was used when asking for a 'authorizationCode'. /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 3650101472..f7c675ff32 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -184,7 +184,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // order for local RedirectUri // 1. challenge.Properties.RedirectUri // 2. CurrentUri if RedirectUri is not set) - var properties = new AuthenticationProperties(context.Properties); + var properties = new AuthenticationProperties(context.Properties) + { + ExpiresUtc = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout) + }; if (string.IsNullOrEmpty(properties.RedirectUri)) { @@ -810,7 +813,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { HttpOnly = true, Secure = Request.IsHttps, - Expires = DateTime.UtcNow + Options.ProtocolValidator.NonceLifetime + Expires = Options.SystemClock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) }); } @@ -857,76 +860,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return null; } - private void GenerateCorrelationId(AuthenticationProperties properties) - { - if (properties == null) - { - throw new ArgumentNullException(nameof(properties)); - } - - var correlationKey = OpenIdConnectDefaults.CookieStatePrefix; - - var nonceBytes = new byte[32]; - CryptoRandom.GetBytes(nonceBytes); - var correlationId = Base64UrlTextEncoder.Encode(nonceBytes); - - var cookieOptions = new CookieOptions - { - HttpOnly = true, - Secure = Request.IsHttps, - Expires = DateTime.UtcNow + Options.ProtocolValidator.NonceLifetime - }; - - properties.Items[correlationKey] = correlationId; - - Response.Cookies.Append(correlationKey + correlationId, NonceProperty, cookieOptions); - } - - private bool ValidateCorrelationId(AuthenticationProperties properties) - { - if (properties == null) - { - throw new ArgumentNullException(nameof(properties)); - } - - var correlationKey = OpenIdConnectDefaults.CookieStatePrefix; - - string correlationId; - if (!properties.Items.TryGetValue( - correlationKey, - out correlationId)) - { - Logger.LogWarning(26, "{0} state property not found.", correlationKey); - return false; - } - - properties.Items.Remove(correlationKey); - - var cookieName = correlationKey + correlationId; - - var correlationCookie = Request.Cookies[cookieName]; - if (string.IsNullOrEmpty(correlationCookie)) - { - Logger.LogWarning(27, "{0} cookie not found.", cookieName); - return false; - } - - var cookieOptions = new CookieOptions - { - HttpOnly = true, - Secure = Request.IsHttps - }; - Response.Cookies.Delete(cookieName, cookieOptions); - - if (!string.Equals(correlationCookie, NonceProperty, StringComparison.Ordinal)) - { - Logger.LogWarning(28, "{0} correlation cookie and state property mismatch.", correlationKey); - return false; - } - - return true; - } - private AuthenticationProperties GetPropertiesFromState(string state) { // assume a well formed query string: OpenIdConnectAuthenticationDefaults.AuthenticationPropertiesKey=kasjd;fljasldkjflksdj<&c=d> diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 3b66f3128f..c39cce1210 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -122,7 +122,11 @@ namespace Microsoft.AspNetCore.Authentication.Twitter throw new ArgumentNullException(nameof(context)); } - var properties = new AuthenticationProperties(context.Properties); + var properties = new AuthenticationProperties(context.Properties) + { + ExpiresUtc = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout) + }; + if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index cd13d1798f..77fb0bd7a8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.ComponentModel; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.AspNetCore.Http; @@ -50,5 +51,11 @@ namespace Microsoft.AspNetCore.Builder get { return (ITwitterEvents)base.Events; } set { base.Events = value; } } + + /// + /// For testing purposes only. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ISystemClock SystemClock { get; set; } = new SystemClock(); } } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index ef4a1db52d..bf64109a2c 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -2,15 +2,24 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Security.Cryptography; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.Http.Authentication; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Authentication { public abstract class RemoteAuthenticationHandler : AuthenticationHandler where TOptions : RemoteAuthenticationOptions { + private const string CorrelationPrefix = ".AspNetCore.Correlation."; + private const string CorrelationProperty = ".xsrf"; + private const string CorrelationMarker = "N"; + + private static readonly RandomNumberGenerator CryptoRandom = RandomNumberGenerator.Create(); + public override async Task HandleRequestAsync() { if (Options.CallbackPath == Request.Path) @@ -99,5 +108,71 @@ namespace Microsoft.AspNetCore.Authentication { throw new NotSupportedException(); } + + protected virtual void GenerateCorrelationId(AuthenticationProperties properties) + { + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + var bytes = new byte[32]; + CryptoRandom.GetBytes(bytes); + var correlationId = Base64UrlTextEncoder.Encode(bytes); + + var cookieOptions = new CookieOptions + { + HttpOnly = true, + Secure = Request.IsHttps, + Expires = properties.ExpiresUtc + }; + + properties.Items[CorrelationProperty] = correlationId; + + var cookieName = CorrelationPrefix + Options.AuthenticationScheme + "." + correlationId; + + Response.Cookies.Append(cookieName, CorrelationMarker, cookieOptions); + } + + protected virtual bool ValidateCorrelationId(AuthenticationProperties properties) + { + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + string correlationId; + if (!properties.Items.TryGetValue(CorrelationProperty, out correlationId)) + { + Logger.LogWarning(26, "{0} state property not found.", CorrelationPrefix); + return false; + } + + properties.Items.Remove(CorrelationProperty); + + var cookieName = CorrelationPrefix + Options.AuthenticationScheme + "." + correlationId; + + var correlationCookie = Request.Cookies[cookieName]; + if (string.IsNullOrEmpty(correlationCookie)) + { + Logger.LogWarning(27, "'{0}' cookie not found.", cookieName); + return false; + } + + var cookieOptions = new CookieOptions + { + HttpOnly = true, + Secure = Request.IsHttps + }; + Response.Cookies.Delete(cookieName, cookieOptions); + + if (!string.Equals(correlationCookie, CorrelationMarker, StringComparison.Ordinal)) + { + Logger.LogWarning(28, "The correlation cookie value '{0}' did not match the expected value '{1}'.", cookieName); + return false; + } + + return true; + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 86fcdcc97b..0388c04bda 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -56,6 +56,11 @@ namespace Microsoft.AspNetCore.Builder /// public bool SaveTokensAsClaims { get; set; } + /// + /// Gets or sets the time limit for completing the authentication flow (15 minutes by default). + /// + public TimeSpan RemoteAuthenticationTimeout { get; set; } = TimeSpan.FromMinutes(15); + public IRemoteAuthenticationEvents Events = new RemoteAuthenticationEvents(); } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs index aadb62f51b..eaa339d153 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -212,14 +212,14 @@ namespace Microsoft.AspNetCore.Authentication.Facebook }, handler: null); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNetCore.Correlation.Facebook"; + var correlationKey = ".xsrf"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; var state = stateFormat.Protect(properties); var transaction = await server.SendAsync( "https://example.com/signin-facebook?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - correlationKey + "=" + correlationValue); + $".AspNetCore.Correlation.Facebook.{correlationValue}=N"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(1, finalUserInfoEndpoint.Count(c => c == '?')); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 854c49ce97..6a07808127 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.Authentication.Google ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/challenge"); - Assert.Contains(".AspNetCore.Correlation.Google=", transaction.SetCookie.Single()); + Assert.Contains(transaction.SetCookie, cookie => cookie.StartsWith(".AspNetCore.Correlation.Google.")); } [Fact] @@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Authentication.Google AutomaticChallenge = true }); var transaction = await server.SendAsync("https://example.com/401"); - Assert.Contains(".AspNetCore.Correlation.Google=", transaction.SetCookie.Single()); + Assert.Contains(transaction.SetCookie, cookie => cookie.StartsWith(".AspNetCore.Correlation.Google.")); } [Fact] @@ -335,18 +335,18 @@ namespace Microsoft.AspNetCore.Authentication.Google } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNetCore.Correlation.Google"; + var correlationKey = ".xsrf"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; var state = stateFormat.Protect(properties); var transaction = await server.SendAsync( "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - correlationKey + "=" + correlationValue); + $".AspNetCore.Correlation.Google.{correlationValue}=N"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); - Assert.Contains(correlationKey, transaction.SetCookie[0]); + Assert.Contains($".AspNetCore.Correlation.Google.{correlationValue}", transaction.SetCookie[0]); Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); var authCookie = transaction.AuthenticationCookieValue; @@ -394,7 +394,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } : new OAuthEvents() }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNetCore.Correlation.Google"; + var correlationKey = ".xsrf"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -402,7 +402,7 @@ namespace Microsoft.AspNetCore.Authentication.Google var state = stateFormat.Protect(properties); var sendTask = server.SendAsync( "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - correlationKey + "=" + correlationValue); + $".AspNetCore.Correlation.Google.{correlationValue}=N"); if (redirect) { var transaction = await sendTask; @@ -446,14 +446,14 @@ namespace Microsoft.AspNetCore.Authentication.Google } : new OAuthEvents() }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNetCore.Correlation.Google"; + var correlationKey = ".xsrf"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; var state = stateFormat.Protect(properties); var sendTask = server.SendAsync( "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - correlationKey + "=" + correlationValue); + $".AspNetCore.Correlation.Google.{correlationValue}=N"); if (redirect) { var transaction = await sendTask; @@ -528,18 +528,18 @@ namespace Microsoft.AspNetCore.Authentication.Google } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNetCore.Correlation.Google"; + var correlationKey = ".xsrf"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; var state = stateFormat.Protect(properties); var transaction = await server.SendAsync( "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - correlationKey + "=" + correlationValue); + $".AspNetCore.Correlation.Google.{correlationValue}=N"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); - Assert.Contains(correlationKey, transaction.SetCookie[0]); + Assert.Contains($".AspNetCore.Correlation.Google.{correlationValue}", transaction.SetCookie[0]); Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); var authCookie = transaction.AuthenticationCookieValue; @@ -607,17 +607,17 @@ namespace Microsoft.AspNetCore.Authentication.Google } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNetCore.Correlation.Google"; + var correlationKey = ".xsrf"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); var state = stateFormat.Protect(properties); var transaction = await server.SendAsync( "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - correlationKey + "=" + correlationValue); + $".AspNetCore.Correlation.Google.{correlationValue}=N"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal("/", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); - Assert.Contains(correlationKey, transaction.SetCookie[0]); + Assert.Contains($".AspNetCore.Correlation.Google.{correlationValue}", transaction.SetCookie[0]); Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); } @@ -690,7 +690,7 @@ namespace Microsoft.AspNetCore.Authentication.Google }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNetCore.Correlation.Google"; + var correlationKey = ".xsrf"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/foo"; @@ -699,7 +699,7 @@ namespace Microsoft.AspNetCore.Authentication.Google //Post a message to the Google middleware var transaction = await server.SendAsync( "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - correlationKey + "=" + correlationValue); + $".AspNetCore.Correlation.Google.{correlationValue}=N"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal("/foo", transaction.Response.Headers.GetValues("Location").First()); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index 2aad3cfef7..f5a43b8ed2 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -152,18 +152,18 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNetCore.Correlation.Microsoft"; + var correlationKey = ".xsrf"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; var state = stateFormat.Protect(properties); var transaction = await server.SendAsync( "https://example.com/signin-microsoft?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - correlationKey + "=" + correlationValue); + $".AspNetCore.Correlation.Microsoft.{correlationValue}=N"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); - Assert.Contains(correlationKey, transaction.SetCookie[0]); + Assert.Contains($".AspNetCore.Correlation.Microsoft.{correlationValue}", transaction.SetCookie[0]); Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); var authCookie = transaction.AuthenticationCookieValue; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs index 494e2d92a7..1be4b80bca 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs @@ -22,11 +22,10 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect return "null"; } - var encoder = UrlEncoder.Default; var sb = new StringBuilder(); foreach(var item in data.Items) { - sb.Append(encoder.Encode(item.Key) + " " + encoder.Encode(item.Value) + " "); + sb.Append(Uri.EscapeDataString(item.Key) + " " + Uri.EscapeDataString(item.Value) + " "); } return sb.ToString(); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 040812d88b..cadcf80884 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect Assert.Contains("expires", firstCookie); var secondCookie = transaction.SetCookie.Skip(1).First(); - Assert.Contains(OpenIdConnectDefaults.CookieStatePrefix, secondCookie); + Assert.StartsWith(".AspNetCore.Correlation.OpenIdConnect.", secondCookie); Assert.Contains("expires", secondCookie); } From 34bc9c52e1d9bd7aa6fe84fe60aaf7d1f6eb099f Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 3 Feb 2016 16:12:53 -0800 Subject: [PATCH 467/900] #456 Unify OIDC Code/IdToken/Hybride flows. --- samples/OpenIdConnectSample/Startup.cs | 50 ++- .../OpenIdConnectHandler.cs | 425 ++++++++---------- 2 files changed, 232 insertions(+), 243 deletions(-) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index f0f9feb3ae..ddcf9fa2b2 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; @@ -34,6 +35,28 @@ namespace OpenIdConnectSample { loggerfactory.AddConsole(LogLevel.Information); + // Simple error page + app.Use(async (context, next) => + { + try + { + await next(); + } + catch (Exception ex) + { + if (!context.Response.HasStarted) + { + context.Response.Clear(); + context.Response.StatusCode = 500; + await context.Response.WriteAsync(ex.ToString()); + } + else + { + throw; + } + } + }); + app.UseIISPlatformHandler(); app.UseCookieAuthentication(new CookieAuthenticationOptions @@ -52,17 +75,30 @@ namespace OpenIdConnectSample app.Run(async context => { - if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) + if (context.Request.Path.Equals("/signout")) { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" }); - - context.Response.ContentType = "text/plain"; - await context.Response.WriteAsync("Hello First timer"); + await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + context.Response.ContentType = "text/html"; + await context.Response.WriteAsync($"Signing out {context.User.Identity.Name}
{Environment.NewLine}"); + await context.Response.WriteAsync("Sign In"); + await context.Response.WriteAsync($""); return; } - context.Response.ContentType = "text/plain"; - await context.Response.WriteAsync("Hello Authenticated User"); + if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) + { + await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" }); + return; + } + + context.Response.ContentType = "text/html"; + await context.Response.WriteAsync($"Hello Authenticated User {context.User.Identity.Name}
{Environment.NewLine}"); + foreach (var claim in context.User.Claims) + { + await context.Response.WriteAsync($"{claim.Type}: {claim.Value}
{Environment.NewLine}"); + } + await context.Response.WriteAsync("Sign Out"); + await context.Response.WriteAsync($""); }); } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index f7c675ff32..4084e21007 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -308,16 +308,16 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { Logger.LogTrace(10, "Entering: {0}." + nameof(HandleRemoteAuthenticateAsync), GetType()); - OpenIdConnectMessage message = null; + OpenIdConnectMessage authorizationResponse = null; if (string.Equals(Request.Method, "GET", StringComparison.OrdinalIgnoreCase)) { - message = new OpenIdConnectMessage(Request.Query.Select(pair => new KeyValuePair(pair.Key, pair.Value))); + authorizationResponse = new OpenIdConnectMessage(Request.Query.Select(pair => new KeyValuePair(pair.Key, pair.Value))); // response_mode=query (explicit or not) and a response_type containing id_token // or token are not considered as a safe combination and MUST be rejected. // See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#Security - if (!string.IsNullOrEmpty(message.IdToken) || !string.IsNullOrEmpty(message.AccessToken)) + if (!string.IsNullOrEmpty(authorizationResponse.IdToken) || !string.IsNullOrEmpty(authorizationResponse.AccessToken)) { if (Options.SkipUnrecognizedRequests) { @@ -336,10 +336,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect && Request.Body.CanRead) { var form = await Request.ReadFormAsync(); - message = new OpenIdConnectMessage(form.Select(pair => new KeyValuePair(pair.Key, pair.Value))); + authorizationResponse = new OpenIdConnectMessage(form.Select(pair => new KeyValuePair(pair.Key, pair.Value))); } - if (message == null) + if (authorizationResponse == null) { if (Options.SkipUnrecognizedRequests) { @@ -349,54 +349,52 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return AuthenticateResult.Fail("No message."); } + AuthenticateResult result; + try { - var messageReceivedContext = await RunMessageReceivedEventAsync(message); - if (messageReceivedContext.HandledResponse) + var messageReceivedContext = await RunMessageReceivedEventAsync(authorizationResponse); + if (CheckEventResult(messageReceivedContext, out result)) { - return AuthenticateResult.Success(messageReceivedContext.Ticket); + return result; } - else if (messageReceivedContext.Skipped) - { - return AuthenticateResult.Skip(); - } - message = messageReceivedContext.ProtocolMessage; + authorizationResponse = messageReceivedContext.ProtocolMessage; // Fail if state is missing, it's required for the correlation id. - if (string.IsNullOrEmpty(message.State)) + if (string.IsNullOrEmpty(authorizationResponse.State)) { // This wasn't a valid OIDC message, it may not have been intended for us. + Logger.LogDebug(11, "message.State is null or empty."); if (Options.SkipUnrecognizedRequests) { return AuthenticateResult.Skip(); } - Logger.LogDebug(11, "message.State is null or empty."); return AuthenticateResult.Fail(Resources.MessageStateIsNullOrEmpty); } // if state exists and we failed to 'unprotect' this is not a message we should process. - var properties = Options.StateDataFormat.Unprotect(Uri.UnescapeDataString(message.State)); + var properties = Options.StateDataFormat.Unprotect(Uri.UnescapeDataString(authorizationResponse.State)); if (properties == null) { + Logger.LogDebug(12, "Unable to read the message.State."); if (Options.SkipUnrecognizedRequests) { // Not for us? return AuthenticateResult.Skip(); } - Logger.LogError(12, "Unable to read the message.State."); return AuthenticateResult.Fail(Resources.MessageStateIsInvalid); } // if any of the error fields are set, throw error null - if (!string.IsNullOrEmpty(message.Error)) + if (!string.IsNullOrEmpty(authorizationResponse.Error)) { - Logger.LogError(13, "Message contains error: '{0}', error_description: '{1}', error_uri: '{2}'.", message.Error, message.ErrorDescription ?? "ErrorDecription null", message.ErrorUri ?? "ErrorUri null"); - return AuthenticateResult.Fail(new OpenIdConnectProtocolException(string.Format(CultureInfo.InvariantCulture, Resources.MessageContainsError, message.Error, message.ErrorDescription ?? "ErrorDecription null", message.ErrorUri ?? "ErrorUri null"))); + Logger.LogError(13, "Message contains error: '{0}', error_description: '{1}', error_uri: '{2}'.", authorizationResponse.Error, authorizationResponse.ErrorDescription ?? "ErrorDecription null", authorizationResponse.ErrorUri ?? "ErrorUri null"); + return AuthenticateResult.Fail(new OpenIdConnectProtocolException(string.Format(CultureInfo.InvariantCulture, Resources.MessageContainsError, authorizationResponse.Error, authorizationResponse.ErrorDescription ?? "ErrorDecription null", authorizationResponse.ErrorUri ?? "ErrorUri null"))); } string userstate = null; properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out userstate); - message.State = userstate; + authorizationResponse.State = userstate; if (!ValidateCorrelationId(properties)) { @@ -409,38 +407,113 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); } - Logger.LogTrace(15, "Authorization response received."); - var authorizationResponseReceivedContext = new AuthorizationResponseReceivedContext(Context, Options, properties) + var authorizationResponseReceivedContext = await RunAuthorizationResponseReceivedEventAsync(authorizationResponse, properties); + if (CheckEventResult(authorizationResponseReceivedContext, out result)) { - ProtocolMessage = message - }; - await Options.Events.AuthorizationResponseReceived(authorizationResponseReceivedContext); - if (authorizationResponseReceivedContext.HandledResponse) - { - Logger.LogDebug(16, "AuthorizationResponseReceived.HandledResponse"); - return AuthenticateResult.Success(authorizationResponseReceivedContext.Ticket); + return result; } - else if (authorizationResponseReceivedContext.Skipped) - { - Logger.LogDebug(17, "AuthorizationResponseReceived.Skipped"); - return AuthenticateResult.Skip(); - } - message = authorizationResponseReceivedContext.ProtocolMessage; + authorizationResponse = authorizationResponseReceivedContext.ProtocolMessage; properties = authorizationResponseReceivedContext.Properties; - if (string.IsNullOrEmpty(message.IdToken) && !string.IsNullOrEmpty(message.Code)) + PopulateSessionProperties(authorizationResponse, properties); + + AuthenticationTicket ticket = null; + JwtSecurityToken jwt = null; + string nonce = null; + var validationParameters = Options.TokenValidationParameters.Clone(); + + // Hybrid or Implicit flow + if (!string.IsNullOrEmpty(authorizationResponse.IdToken)) { - return await HandleCodeOnlyFlow(message, properties); + Logger.LogDebug(23, "'id_token' received."); + ticket = ValidateToken(authorizationResponse.IdToken, properties, validationParameters, out jwt); + + nonce = jwt?.Payload.Nonce; + if (!string.IsNullOrEmpty(nonce)) + { + nonce = ReadNonceCookie(nonce); + } } - else if (!string.IsNullOrEmpty(message.IdToken)) + + Options.ProtocolValidator.ValidateAuthenticationResponse(new OpenIdConnectProtocolValidationContext() { - return await HandleIdTokenFlows(message, properties); - } - else + ClientId = Options.ClientId, + ProtocolMessage = authorizationResponse, + ValidatedIdToken = jwt, + Nonce = nonce + }); + + // TODO: AuthorizationResponseValidated event? + + OpenIdConnectMessage tokenEndpointResponse = null; + + // Authorization Code or Hybrid flow + if (!string.IsNullOrEmpty(authorizationResponse.Code)) { - Logger.LogTrace(18, "Cannot process the message. Both id_token and code are missing."); - return AuthenticateResult.Fail(Resources.IdTokenCodeMissing); + // TODO: Does this event provide any value over AuthorizationResponseReceived or AuthorizationResponseValidated? + var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(authorizationResponse, properties, ticket, jwt); + if (CheckEventResult(authorizationCodeReceivedContext, out result)) + { + return result; + } + authorizationResponse = authorizationCodeReceivedContext.ProtocolMessage; + var code = authorizationCodeReceivedContext.Code; + + tokenEndpointResponse = await RedeemAuthorizationCodeAsync(code, authorizationCodeReceivedContext.RedirectUri); + + var authorizationCodeRedeemedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties); + if (CheckEventResult(authorizationCodeRedeemedContext, out result)) + { + return result; + } + authorizationResponse = authorizationCodeRedeemedContext.ProtocolMessage; + tokenEndpointResponse = authorizationCodeRedeemedContext.TokenEndpointResponse; + + // We only have to process the IdToken if we didn't already get one in the AuthorizationResponse + if (ticket == null) + { + // no need to validate signature when token is received using "code flow" as per spec + // [http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation]. + validationParameters.RequireSignedTokens = false; + + ticket = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out jwt); + + nonce = jwt?.Payload.Nonce; + if (!string.IsNullOrEmpty(nonce)) + { + nonce = ReadNonceCookie(nonce); + } + } + + Options.ProtocolValidator.ValidateTokenResponse(new OpenIdConnectProtocolValidationContext() + { + ClientId = Options.ClientId, + ProtocolMessage = tokenEndpointResponse, + ValidatedIdToken = jwt, + Nonce = nonce + }); } + + var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(authorizationResponse, ticket, properties, tokenEndpointResponse); + if (CheckEventResult(authenticationValidatedContext, out result)) + { + return result; + } + authorizationResponse = authenticationValidatedContext.ProtocolMessage; + tokenEndpointResponse = authenticationValidatedContext.TokenEndpointResponse; + ticket = authenticationValidatedContext.Ticket; + + if (Options.SaveTokensAsClaims) + { + SaveTokens(ticket.Principal, tokenEndpointResponse ?? authorizationResponse, jwt.Issuer); + } + + if (Options.GetClaimsFromUserInfoEndpoint) + { + return await GetUserInformationAsync(tokenEndpointResponse ?? authorizationResponse, jwt, ticket); + } + + return AuthenticateResult.Success(ticket); } catch (Exception exception) { @@ -456,179 +529,43 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } } - var authenticationFailedContext = await RunAuthenticationFailedEventAsync(message, exception); - if (authenticationFailedContext.HandledResponse) + var authenticationFailedContext = await RunAuthenticationFailedEventAsync(authorizationResponse, exception); + if (CheckEventResult(authenticationFailedContext, out result)) { - return AuthenticateResult.Success(authenticationFailedContext.Ticket); - } - else if (authenticationFailedContext.Skipped) - { - return AuthenticateResult.Skip(); + return result; } - throw; + return AuthenticateResult.Fail(exception); } } - // Authorization Code Flow - private async Task HandleCodeOnlyFlow(OpenIdConnectMessage message, AuthenticationProperties properties) + private bool CheckEventResult(BaseControlContext context, out AuthenticateResult result) { - AuthenticationTicket ticket = null; - JwtSecurityToken jwt = null; - - Options.ProtocolValidator.ValidateAuthenticationResponse(new OpenIdConnectProtocolValidationContext() + if (context.HandledResponse) { - ClientId = Options.ClientId, - ProtocolMessage = message, - }); - - var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(message, properties, ticket, jwt); - if (authorizationCodeReceivedContext.HandledResponse) - { - return AuthenticateResult.Success(authorizationCodeReceivedContext.Ticket); + result = AuthenticateResult.Success(context.Ticket); + return true; } - else if (authorizationCodeReceivedContext.Skipped) + else if (context.Skipped) { - return AuthenticateResult.Skip(); + result = AuthenticateResult.Skip(); + return true; } - message = authorizationCodeReceivedContext.ProtocolMessage; - var code = authorizationCodeReceivedContext.Code; - - // Redeeming authorization code for tokens - Logger.LogTrace(21, "Id Token is null. Redeeming code '{0}' for tokens.", code); - - var tokenEndpointResponse = await RedeemAuthorizationCodeAsync(code, authorizationCodeReceivedContext.RedirectUri); - - var authorizationCodeRedeemedContext = await RunTokenResponseReceivedEventAsync(message, tokenEndpointResponse, properties); - if (authorizationCodeRedeemedContext.HandledResponse) - { - return AuthenticateResult.Success(authorizationCodeRedeemedContext.Ticket); - } - else if (authorizationCodeRedeemedContext.Skipped) - { - return AuthenticateResult.Skip(); - } - - message = authorizationCodeRedeemedContext.ProtocolMessage; - tokenEndpointResponse = authorizationCodeRedeemedContext.TokenEndpointResponse; - - // no need to validate signature when token is received using "code flow" as per spec [http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation]. - var validationParameters = Options.TokenValidationParameters.Clone(); - validationParameters.RequireSignedTokens = false; - - ticket = ValidateToken(tokenEndpointResponse.IdToken, message, properties, validationParameters, out jwt); - - var nonce = jwt?.Payload.Nonce; - if (!string.IsNullOrEmpty(nonce)) - { - nonce = ReadNonceCookie(nonce); - } - - Options.ProtocolValidator.ValidateTokenResponse(new OpenIdConnectProtocolValidationContext() - { - ClientId = Options.ClientId, - ProtocolMessage = tokenEndpointResponse, - ValidatedIdToken = jwt, - Nonce = nonce - }); - - var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(message, ticket, properties, tokenEndpointResponse); - if (authenticationValidatedContext.HandledResponse) - { - return AuthenticateResult.Success(authenticationValidatedContext.Ticket); - } - else if (authenticationValidatedContext.Skipped) - { - return AuthenticateResult.Skip(); - } - ticket = authenticationValidatedContext.Ticket; - - if (Options.SaveTokensAsClaims) - { - // Persist the tokens extracted from the token response. - SaveTokens(ticket.Principal, tokenEndpointResponse, jwt.Issuer, saveRefreshToken: true); - } - - if (Options.GetClaimsFromUserInfoEndpoint) - { - Logger.LogTrace(22, "Sending request to user info endpoint for retrieving claims."); - ticket = await GetUserInformationAsync(tokenEndpointResponse, jwt, ticket); - } - - return AuthenticateResult.Success(ticket); + result = null; + return false; } - // Implicit Flow or Hybrid Flow - private async Task HandleIdTokenFlows(OpenIdConnectMessage message, AuthenticationProperties properties) + private void PopulateSessionProperties(OpenIdConnectMessage message, AuthenticationProperties properties) { - Logger.LogTrace(23, "'id_token' received: '{0}'", message.IdToken); - - JwtSecurityToken jwt = null; - var validationParameters = Options.TokenValidationParameters.Clone(); - var ticket = ValidateToken(message.IdToken, message, properties, validationParameters, out jwt); - - var nonce = jwt?.Payload.Nonce; - if (!string.IsNullOrEmpty(nonce)) + if (!string.IsNullOrEmpty(message.SessionState)) { - nonce = ReadNonceCookie(nonce); + properties.Items[OpenIdConnectSessionProperties.SessionState] = message.SessionState; } - Options.ProtocolValidator.ValidateAuthenticationResponse(new OpenIdConnectProtocolValidationContext() + if (!string.IsNullOrEmpty(_configuration.CheckSessionIframe)) { - ClientId = Options.ClientId, - ProtocolMessage = message, - ValidatedIdToken = jwt, - Nonce = nonce - }); - - var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(message, ticket, properties, tokenEndpointResponse: null); - if (authenticationValidatedContext.HandledResponse) - { - return AuthenticateResult.Success(authenticationValidatedContext.Ticket); + properties.Items[OpenIdConnectSessionProperties.CheckSessionIFrame] = _configuration.CheckSessionIframe; } - else if (authenticationValidatedContext.Skipped) - { - return AuthenticateResult.Skip(); - } - message = authenticationValidatedContext.ProtocolMessage; - ticket = authenticationValidatedContext.Ticket; - - // Hybrid Flow - if (message.Code != null) - { - var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(message, properties, ticket, jwt); - if (authorizationCodeReceivedContext.HandledResponse) - { - return AuthenticateResult.Success(authorizationCodeReceivedContext.Ticket); - } - else if (authorizationCodeReceivedContext.Skipped) - { - return AuthenticateResult.Skip(); - } - message = authorizationCodeReceivedContext.ProtocolMessage; - ticket = authorizationCodeReceivedContext.Ticket; - - if (Options.SaveTokensAsClaims) - { - // TODO: call SaveTokens with the token response and set - // saveRefreshToken to true when the hybrid flow is fully implemented. - SaveTokens(ticket.Principal, message, jwt.Issuer, saveRefreshToken: false); - } - } - // Implicit Flow - else - { - if (Options.SaveTokensAsClaims) - { - // Note: don't save the refresh token when it is extracted from the authorization - // response, since it's not a valid parameter when using the implicit flow. - // See http://openid.net/specs/openid-connect-core-1_0.html#Authentication - // and https://tools.ietf.org/html/rfc6749#section-4.2.2. - SaveTokens(ticket.Principal, message, jwt.Issuer, saveRefreshToken: false); - } - } - - return AuthenticateResult.Success(ticket); } /// @@ -639,6 +576,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// OpenIdConnect message that has tokens inside it. protected virtual async Task RedeemAuthorizationCodeAsync(string authorizationCode, string redirectUri) { + Logger.LogDebug(21, "Redeeming code for tokens."); + var openIdMessage = new OpenIdConnectMessage() { ClientId = Options.ClientId, @@ -648,6 +587,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect RedirectUri = redirectUri }; + // TODO: Event that lets you customize the message. E.g. use certificates, specify resources. + var requestMessage = new HttpRequestMessage(HttpMethod.Post, _configuration.TokenEndpoint); requestMessage.Content = new FormUrlEncodedContent(openIdMessage.Parameters); var responseMessage = await Backchannel.SendAsync(requestMessage); @@ -663,21 +604,28 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// message that is being processed /// authentication ticket with claims principal and identities /// Authentication ticket with identity with additional claims, if any. - protected virtual async Task GetUserInformationAsync(OpenIdConnectMessage message, JwtSecurityToken jwt, AuthenticationTicket ticket) + protected virtual async Task GetUserInformationAsync(OpenIdConnectMessage message, JwtSecurityToken jwt, AuthenticationTicket ticket) { var userInfoEndpoint = _configuration?.UserInfoEndpoint; if (string.IsNullOrEmpty(userInfoEndpoint)) { - Logger.LogWarning(24, nameof(_configuration.UserInfoEndpoint) + " is not set. Request to retrieve claims cannot be completed."); - return ticket; + Logger.LogDebug(24, $"{nameof(_configuration.UserInfoEndpoint)} is not set. Claims cannot be retrieved."); + return AuthenticateResult.Success(ticket); } + if (string.IsNullOrEmpty(message.AccessToken)) + { + Logger.LogDebug(47, "The access_token is not available. Claims cannot be retrieved."); + return AuthenticateResult.Success(ticket); + } + Logger.LogTrace(22, "Retrieving claims from the user info endpoint."); var requestMessage = new HttpRequestMessage(HttpMethod.Get, userInfoEndpoint); requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", message.AccessToken); var responseMessage = await Backchannel.SendAsync(requestMessage); responseMessage.EnsureSuccessStatusCode(); var userInfoResponse = await responseMessage.Content.ReadAsStringAsync(); + JObject user; var contentType = responseMessage.Content.Headers.ContentType; if (contentType.MediaType.Equals("application/json", StringComparison.OrdinalIgnoreCase)) @@ -691,17 +639,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } else { - throw new NotSupportedException("Unknown response type: " + contentType.MediaType); + return AuthenticateResult.Fail("Unknown response type: " + contentType.MediaType); } var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(ticket, message, user); - if (userInformationReceivedContext.HandledResponse) + AuthenticateResult result; + if (CheckEventResult(userInformationReceivedContext, out result)) { - return userInformationReceivedContext.Ticket; - } - else if (userInformationReceivedContext.Skipped) - { - return ticket; + return result; } ticket = userInformationReceivedContext.Ticket; user = userInformationReceivedContext.User; @@ -742,7 +687,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect identity.AddClaim(new Claim(pair.Key, claimValue, ClaimValueTypes.String, jwt.Issuer)); } - return ticket; + return AuthenticateResult.Success(ticket); } /// @@ -750,8 +695,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// The principal in which tokens are saved. /// The OpenID Connect response. - /// A indicating whether the refresh token should be stored. - private void SaveTokens(ClaimsPrincipal principal, OpenIdConnectMessage message, string issuer, bool saveRefreshToken) + private void SaveTokens(ClaimsPrincipal principal, OpenIdConnectMessage message, string issuer) { var identity = (ClaimsIdentity)principal.Identity; @@ -767,7 +711,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect ClaimValueTypes.String, issuer)); } - if (saveRefreshToken && !string.IsNullOrEmpty(message.RefreshToken)) + if (!string.IsNullOrEmpty(message.RefreshToken)) { identity.AddClaim(new Claim(OpenIdConnectParameterNames.RefreshToken, message.RefreshToken, ClaimValueTypes.String, issuer)); @@ -911,6 +855,25 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return messageReceivedContext; } + private async Task RunAuthorizationResponseReceivedEventAsync(OpenIdConnectMessage message, AuthenticationProperties properties) + { + Logger.LogTrace(15, "Authorization response received."); + var authorizationResponseReceivedContext = new AuthorizationResponseReceivedContext(Context, Options, properties) + { + ProtocolMessage = message + }; + await Options.Events.AuthorizationResponseReceived(authorizationResponseReceivedContext); + if (authorizationResponseReceivedContext.HandledResponse) + { + Logger.LogDebug(16, "AuthorizationResponseReceived.HandledResponse"); + } + else if (authorizationResponseReceivedContext.Skipped) + { + Logger.LogDebug(17, "AuthorizationResponseReceived.Skipped"); + } + return authorizationResponseReceivedContext; + } + private async Task RunAuthorizationCodeReceivedEventAsync(OpenIdConnectMessage message, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt) { var redirectUri = properties.Items[OpenIdConnectDefaults.RedirectUriForCodePropertiesKey]; @@ -960,13 +923,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return tokenResponseReceivedContext; } - private async Task RunAuthenticationValidatedEventAsync(OpenIdConnectMessage message, AuthenticationTicket ticket, AuthenticationProperties properties, OpenIdConnectMessage tokenEndpointResponse) + private async Task RunAuthenticationValidatedEventAsync(OpenIdConnectMessage message, AuthenticationTicket ticket, AuthenticationProperties properties, OpenIdConnectMessage tokenResponse) { var authenticationValidatedContext = new AuthenticationValidatedContext(Context, Options, properties) { Ticket = ticket, ProtocolMessage = message, - TokenEndpointResponse = tokenEndpointResponse, + TokenEndpointResponse = tokenResponse, }; await Options.Events.AuthenticationValidated(authenticationValidatedContext); @@ -1027,10 +990,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return authenticationFailedContext; } - private AuthenticationTicket ValidateToken(string idToken, OpenIdConnectMessage message, AuthenticationProperties properties, TokenValidationParameters validationParameters, out JwtSecurityToken jwt) + private AuthenticationTicket ValidateToken(string idToken, AuthenticationProperties properties, TokenValidationParameters validationParameters, out JwtSecurityToken jwt) { - AuthenticationTicket ticket = null; - jwt = null; + if (!Options.SecurityTokenValidator.CanReadToken(idToken)) + { + Logger.LogError(48, "Unable to read the 'id_token', no suitable ISecurityTokenValidator was found for: '{0}'.", idToken); + throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.UnableToValidateToken, idToken)); + } if (_configuration != null) { @@ -1047,16 +1013,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } SecurityToken validatedToken = null; - ClaimsPrincipal principal = null; - if (Options.SecurityTokenValidator.CanReadToken(idToken)) + var principal = Options.SecurityTokenValidator.ValidateToken(idToken, validationParameters, out validatedToken); + jwt = validatedToken as JwtSecurityToken; + if (jwt == null) { - principal = Options.SecurityTokenValidator.ValidateToken(idToken, validationParameters, out validatedToken); - jwt = validatedToken as JwtSecurityToken; - if (jwt == null) - { - Logger.LogError(45, "The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{0}'", validatedToken?.GetType()); - throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.ValidatedSecurityTokenNotJwt, validatedToken?.GetType())); - } + Logger.LogError(45, "The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{0}'", validatedToken?.GetType()); + throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.ValidatedSecurityTokenNotJwt, validatedToken?.GetType())); } if (validatedToken == null) @@ -1065,16 +1027,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.UnableToValidateToken, idToken)); } - ticket = new AuthenticationTicket(principal, properties, Options.AuthenticationScheme); - if (!string.IsNullOrEmpty(message.SessionState)) - { - ticket.Properties.Items[OpenIdConnectSessionProperties.SessionState] = message.SessionState; - } - - if (_configuration != null && !string.IsNullOrEmpty(_configuration.CheckSessionIframe)) - { - ticket.Properties.Items[OpenIdConnectSessionProperties.CheckSessionIFrame] = _configuration.CheckSessionIframe; - } + var ticket = new AuthenticationTicket(principal, properties, Options.AuthenticationScheme); if (Options.UseTokenLifetime) { From 552afb87b5b048e5de0cb84abe956a8786da13e7 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Wed, 10 Feb 2016 05:47:19 -0800 Subject: [PATCH 468/900] Enable tests to run using dotnet xunit runner --- .../project.json | 19 +++++++--------- .../project.json | 21 ++++++++---------- .../project.json | 22 ++++++++----------- 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 2048801a64..58a7082455 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -16,6 +16,13 @@ "xunit": "2.1.0" }, "frameworks": { + "dnxcore50": { + "dependencies": { + "System.Runtime": "4.0.21-*", + "dotnet-test-xunit": "1.0.0-dev-*" + }, + "imports": "portable-net451+win8" + }, "dnx451": { "frameworkAssemblies": { "System.Runtime": "", @@ -24,17 +31,7 @@ "dependencies": { "xunit.runner.console": "2.1.0" } - }, - "dnxcore50": { - "dependencies": { - "System.Runtime": "4.0.21-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "imports": "portable-net451+win8" } }, - "testRunner": "xunit", - "commands": { - "test": "xunit.runner.aspnet" - } + "testRunner": "xunit" } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index d5d5544626..abe001fe46 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -11,24 +11,21 @@ "xunit": "2.1.0" }, "frameworks": { + "dnxcore50": { + "dependencies": { + "dotnet-test-xunit": "1.0.0-dev-*" + }, + "imports": "portable-net451+win8" + }, "dnx451": { - "frameworkAssemblies": { + "frameworkAssemblies": { "System.Runtime": "", "System.Threading.Tasks": "" }, "dependencies": { "xunit.runner.console": "2.1.0" } - }, - "dnxcore50": { - "dependencies": { - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "imports": "portable-net451+win8" } }, - "testRunner": "xunit", - "commands": { - "test": "xunit.runner.aspnet" - } -} + "testRunner": "xunit" +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index d39a059744..248e085c26 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -10,8 +10,14 @@ "xunit": "2.1.0" }, "frameworks": { + "dnxcore50": { + "dependencies": { + "dotnet-test-xunit": "1.0.0-dev-*" + }, + "imports": "portable-net451+win8" + }, "dnx451": { - "frameworkAssemblies": { + "frameworkAssemblies": { "System.Runtime": "", "System.Threading.Tasks": "", "System.Xml.Linq": "" @@ -19,17 +25,7 @@ "dependencies": { "xunit.runner.console": "2.1.0" } - }, - "dnxcore50": { - "dependencies": { - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "imports": "portable-net451+win8" } }, - "testRunner": "xunit", - "commands": { - "test": "xunit.runner.aspnet" - } - -} + "testRunner": "xunit" +} \ No newline at end of file From 2dc353e21991aa35424b37cc14239d52ccb245b1 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sat, 13 Feb 2016 21:20:20 -0800 Subject: [PATCH 469/900] Fixed 1300 errors reported in VS on build --- test/Microsoft.AspNetCore.Authentication.Test/project.json | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 58a7082455..b3ca2d48d8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -18,7 +18,6 @@ "frameworks": { "dnxcore50": { "dependencies": { - "System.Runtime": "4.0.21-*", "dotnet-test-xunit": "1.0.0-dev-*" }, "imports": "portable-net451+win8" From 0372daeebf59a79db0c054a37583b7d254f13bbe Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 19 Feb 2016 12:37:51 -0800 Subject: [PATCH 470/900] Updating test TFMs for custom test discovery --- .../Microsoft.AspNetCore.Authentication.Test/project.json | 4 ++-- test/Microsoft.AspNetCore.Authorization.Test/project.json | 4 ++-- test/Microsoft.AspNetCore.CookiePolicy.Test/project.json | 4 ++-- test/Microsoft.Owin.Security.Interop.Test/project.json | 8 +++----- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index b3ca2d48d8..eb36173bf2 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -22,7 +22,7 @@ }, "imports": "portable-net451+win8" }, - "dnx451": { + "net451": { "frameworkAssemblies": { "System.Runtime": "", "System.Threading.Tasks": "" @@ -33,4 +33,4 @@ } }, "testRunner": "xunit" -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index abe001fe46..651b9acb69 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -17,7 +17,7 @@ }, "imports": "portable-net451+win8" }, - "dnx451": { + "net451": { "frameworkAssemblies": { "System.Runtime": "", "System.Threading.Tasks": "" @@ -28,4 +28,4 @@ } }, "testRunner": "xunit" -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 248e085c26..db1fce596a 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -16,7 +16,7 @@ }, "imports": "portable-net451+win8" }, - "dnx451": { + "net451": { "frameworkAssemblies": { "System.Runtime": "", "System.Threading.Tasks": "", @@ -28,4 +28,4 @@ } }, "testRunner": "xunit" -} \ No newline at end of file +} diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index 46fd46b489..ae53f6e2f7 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -13,15 +13,13 @@ "xunit.runner.console": "2.1.0" }, "frameworks": { - "dnx451": { + "net451": { "frameworkAssemblies": { "System.Runtime": "", "System.Threading.Tasks": "" } } }, - "testRunner": "xunit", - "commands": { - "test": "xunit.runner.aspnet" - } + "testRunner": "xunit" } + From 9bbbe535f2e979333d523a229ddd034af15c20cb Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 19 Feb 2016 12:24:40 -0800 Subject: [PATCH 471/900] #690 Enable custom OIDC authorization code redemption. --- Security.sln | 18 +- .../AuthPropertiesTokenCache.cs | 56 ++++++ .../OpenIdConnect.AzureAdSample.xproj | 23 +++ .../Properties/launchSettings.json | 25 +++ .../OpenIdConnect.AzureAdSample/Startup.cs | 171 ++++++++++++++++++ .../OpenIdConnect.AzureAdSample/project.json | 23 +++ .../wwwroot/web.config | 9 + .../AuthorizationCodeReceivedContext.cs | 74 ++++++-- .../OpenIdConnectHandler.cs | 72 ++++---- 9 files changed, 423 insertions(+), 48 deletions(-) create mode 100644 samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs create mode 100644 samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj create mode 100644 samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json create mode 100644 samples/OpenIdConnect.AzureAdSample/Startup.cs create mode 100644 samples/OpenIdConnect.AzureAdSample/project.json create mode 100644 samples/OpenIdConnect.AzureAdSample/wwwroot/web.config diff --git a/Security.sln b/Security.sln index 4c24c1d22f..2ed873270c 100644 --- a/Security.sln +++ b/Security.sln @@ -1,7 +1,6 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -56,6 +55,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Owin.Security.Int EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Owin.Security.Interop.Test", "test\Microsoft.Owin.Security.Interop.Test\Microsoft.Owin.Security.Interop.Test.xproj", "{A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "OpenIdConnect.AzureAdSample", "samples\OpenIdConnect.AzureAdSample\OpenIdConnect.AzureAdSample.xproj", "{3A7AD414-EBDE-4F92-B307-4E8F19B6117E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -312,6 +313,18 @@ Global {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.Build.0 = Release|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.ActiveCfg = Release|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.Build.0 = Release|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|x86.ActiveCfg = Debug|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|x86.Build.0 = Debug|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|Any CPU.Build.0 = Release|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|x86.ActiveCfg = Release|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -338,5 +351,6 @@ Global {D399B84F-591B-4E98-92BA-B0F63E7B6957} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {A7922DD8-09F1-43E4-938B-CC523EA08898} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} EndGlobalSection EndGlobal diff --git a/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs b/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs new file mode 100644 index 0000000000..f174174cf8 --- /dev/null +++ b/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs @@ -0,0 +1,56 @@ +using System; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.IdentityModel.Clients.ActiveDirectory; + +namespace OpenIdConnect.AzureAdSample +{ + public class AuthPropertiesTokenCache : TokenCache + { + private const string TokenCacheKey = ".TokenCache"; + + private AuthenticationProperties _authProperties; + + public bool HasCacheChanged { get; internal set; } + + public AuthPropertiesTokenCache(AuthenticationProperties authProperties) : base() + { + _authProperties = authProperties; + BeforeAccess = BeforeAccessNotification; + AfterAccess = AfterAccessNotification; + BeforeWrite = BeforeWriteNotification; + + string cachedTokensText; + if (authProperties.Items.TryGetValue(TokenCacheKey, out cachedTokensText)) + { + var cachedTokens = Convert.FromBase64String(cachedTokensText); + Deserialize(cachedTokens); + } + } + + // Notification raised before ADAL accesses the cache. + // This is your chance to update the in-memory copy from the DB, if the in-memory version is stale + private void BeforeAccessNotification(TokenCacheNotificationArgs args) + { + + } + + // Notification raised after ADAL accessed the cache. + // If the HasStateChanged flag is set, ADAL changed the content of the cache + private void AfterAccessNotification(TokenCacheNotificationArgs args) + { + // if state changed + if (HasStateChanged) + { + HasCacheChanged = true; + var cachedTokens = Serialize(); + var cachedTokensText = Convert.ToBase64String(cachedTokens); + _authProperties.Items[TokenCacheKey] = cachedTokensText; + } + } + + private void BeforeWriteNotification(TokenCacheNotificationArgs args) + { + // if you want to ensure that no concurrent write take place, use this notification to place a lock on the entry + } + } +} diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj new file mode 100644 index 0000000000..c7b0ff10ed --- /dev/null +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj @@ -0,0 +1,23 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 3a7ad414-ebde-4f92-b307-4e8f19b6117e + OpenIdConnect.AzureAdSample + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + 2.0 + + + + + + + + \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json new file mode 100644 index 0000000000..22d7eec72e --- /dev/null +++ b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json @@ -0,0 +1,25 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:42023", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "Hosting:Environment": "Development" + } + }, + "web": { + "commandName": "web", + "environmentVariables": { + "Hosting:Environment": "Development" + } + } + } +} \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs new file mode 100644 index 0000000000..c5ddafd5ff --- /dev/null +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -0,0 +1,171 @@ +using System; +using System.Linq; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Extensions; +using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.IdentityModel.Clients.ActiveDirectory; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; + +namespace OpenIdConnect.AzureAdSample +{ + public class Startup + { + private const string GraphResourceID = "https://graph.windows.net"; + + public Startup() + { + Configuration = new ConfigurationBuilder() + .AddEnvironmentVariables() + .AddUserSecrets() + .Build(); + } + + public IConfiguration Configuration { get; set; } + + public void ConfigureServices(IServiceCollection services) + { + services.AddAuthentication(sharedOptions => + sharedOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); + } + + public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + { + loggerfactory.AddConsole(LogLevel.Information); + + // Simple error page + app.Use(async (context, next) => + { + try + { + await next(); + } + catch (Exception ex) + { + if (!context.Response.HasStarted) + { + context.Response.Clear(); + context.Response.StatusCode = 500; + await context.Response.WriteAsync(ex.ToString()); + } + else + { + throw; + } + } + }); + + app.UseIISPlatformHandler(); + + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + AutomaticAuthenticate = true + }); + + var clientId = Configuration["oidc:clientid"]; + var clientSecret = Configuration["oidc:clientsecret"]; + var authority = Configuration["oidc:authority"]; + var resource = "https://graph.windows.net"; + app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions + { + ClientId = clientId, + ClientSecret = clientSecret, // for code flow + Authority = authority, + ResponseType = OpenIdConnectResponseTypes.CodeIdToken, + // GetClaimsFromUserInfoEndpoint = true, + Events = new OpenIdConnectEvents() + { + OnAuthorizationCodeReceived = async context => + { + var request = context.HttpContext.Request; + var currentUri = UriHelper.Encode(request.Scheme, request.Host, request.PathBase, request.Path); + var credential = new ClientCredential(clientId, clientSecret); + var authContext = new AuthenticationContext(authority, new AuthPropertiesTokenCache(context.Properties)); + + var result = await authContext.AcquireTokenByAuthorizationCodeAsync( + context.ProtocolMessage.Code, new Uri(currentUri), credential, resource); + + context.HandleCodeRedemption(result.AccessToken, result.IdToken); + } + } + }); + + app.Run(async context => + { + if (context.Request.Path.Equals("/signout")) + { + await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + context.Response.ContentType = "text/html"; + await context.Response.WriteAsync($"Signing out {context.User.Identity.Name}
{Environment.NewLine}"); + await context.Response.WriteAsync("Sign In"); + await context.Response.WriteAsync($""); + return; + } + + if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) + { + await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" }); + return; + } + + context.Response.ContentType = "text/html"; + await context.Response.WriteAsync($"Hello Authenticated User {context.User.Identity.Name}
{Environment.NewLine}"); + await context.Response.WriteAsync("Claims:
" + Environment.NewLine); + foreach (var claim in context.User.Claims) + { + await context.Response.WriteAsync($"{claim.Type}: {claim.Value}
{Environment.NewLine}"); + } + + await context.Response.WriteAsync("Tokens:
" + Environment.NewLine); + try + { + // Retrieve the auth session with the cached tokens + var authenticateContext = new AuthenticateContext(CookieAuthenticationDefaults.AuthenticationScheme); + await context.Authentication.AuthenticateAsync(authenticateContext); + var authProperties = new AuthenticationProperties(authenticateContext.Properties); + var tokenCache = new AuthPropertiesTokenCache(authProperties); + + // Use ADAL to get the right token + var authContext = new AuthenticationContext(authority, tokenCache); + var credential = new ClientCredential(clientId, clientSecret); + string userObjectID = context.User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; + var result = authContext.AcquireTokenSilent(resource, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId)); + + // Update the cookie with the modified tokens + if (tokenCache.HasCacheChanged) + { + await context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, authenticateContext.Principal, authProperties); + } + + await context.Response.WriteAsync($"access_token: {result.AccessToken}
{Environment.NewLine}"); + } + catch (Exception ex) + { + await context.Response.WriteAsync($"AquireToken error: {ex.Message}
{Environment.NewLine}"); + } + + await context.Response.WriteAsync("Sign Out"); + await context.Response.WriteAsync($""); + }); + } + + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseDefaultConfiguration(args) + .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseIISPlatformHandlerUrl() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json new file mode 100644 index 0000000000..dabb9262fc --- /dev/null +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -0,0 +1,23 @@ +{ + "dependencies": { + "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", + "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", + "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", + "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.IdentityModel.Clients.ActiveDirectory": "2.22.302111727", + "Microsoft.NETCore.Platforms": "1.0.1-*" + }, + "frameworks": { + "dnx451": { } + }, + "compilationOptions": { + "emitEntryPoint": true + }, + "commands": { + "web": "OpenIdConnect.AzureAdSample" + }, + "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" +} \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/wwwroot/web.config b/samples/OpenIdConnect.AzureAdSample/wwwroot/web.config new file mode 100644 index 0000000000..8485f6719f --- /dev/null +++ b/samples/OpenIdConnect.AzureAdSample/wwwroot/web.config @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs index d1737cd259..49c863e4b8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs @@ -1,11 +1,12 @@ // 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.Diagnostics.CodeAnalysis; using System.IdentityModel.Tokens.Jwt; +using System.Net.Http; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { @@ -17,29 +18,76 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Creates a /// - public AuthorizationCodeReceivedContext(HttpContext context, OpenIdConnectOptions options, AuthenticationProperties properties) + public AuthorizationCodeReceivedContext(HttpContext context, OpenIdConnectOptions options) : base(context, options) { - Properties = properties; } public AuthenticationProperties Properties { get; set; } /// - /// Gets or sets the 'code'. - /// - public string Code { get; set; } - - /// - /// Gets or sets the that was received in the id_token + code OpenIdConnectRequest. + /// Gets or sets the that was received in the authentication response, if any. /// public JwtSecurityToken JwtSecurityToken { get; set; } /// - /// Gets or sets the 'redirect_uri'. + /// The request that will be sent to the token endpoint and is available for customization. /// - /// This is the redirect_uri that was sent in the id_token + code OpenIdConnectRequest. - [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "user controlled, not necessarily a URI")] - public string RedirectUri { get; set; } + public OpenIdConnectMessage TokenEndpointRequest { get; set; } + + /// + /// The configured communication channel to the identity provider for use when making custom requests to the token endpoint. + /// + public HttpClient Backchannel { get; internal set; } + + /// + /// If the developer chooses to redeem the code themselves then they can provide the resulting tokens here. This is the + /// same as calling HandleCodeRedemption. If set then the middleware will not attempt to redeem the code. An IdToken + /// is required if one had not been previously received in the authorization response. An access token is optional + /// if the middleware is to contact the user-info endpoint. + /// + public OpenIdConnectMessage TokenEndpointResponse { get; set; } + + /// + /// Indicates if the developer choose to handle (or skip) the code redemption. If true then the middleware will not attempt + /// to redeem the code. See HandleCodeRedemption and TokenEndpointResponse. + /// + public bool HandledCodeRedemption => TokenEndpointResponse != null; + + /// + /// Tells the middleware to skip the code redemption process. The developer may have redeemed the code themselves, or + /// decided that the redemption was not required. If tokens were retrieved that are needed for further processing then + /// call one of the overloads that allows providing tokens. An IdToken is required if one had not been previously received + /// in the authorization response. An access token can optionally be provided for the middleware to contact the + /// user-info endpoint. Calling this is the same as setting TokenEndpointResponse. + /// + public void HandleCodeRedemption() + { + TokenEndpointResponse = new OpenIdConnectMessage(); + } + + /// + /// Tells the middleware to skip the code redemption process. The developer may have redeemed the code themselves, or + /// decided that the redemption was not required. If tokens were retrieved that are needed for further processing then + /// call one of the overloads that allows providing tokens. An IdToken is required if one had not been previously received + /// in the authorization response. An access token can optionally be provided for the middleware to contact the + /// user-info endpoint. Calling this is the same as setting TokenEndpointResponse. + /// + public void HandleCodeRedemption(string accessToken, string idToken) + { + TokenEndpointResponse = new OpenIdConnectMessage() { AccessToken = accessToken, IdToken = idToken }; + } + + /// + /// Tells the middleware to skip the code redemption process. The developer may have redeemed the code themselves, or + /// decided that the redemption was not required. If tokens were retrieved that are needed for further processing then + /// call one of the overloads that allows providing tokens. An IdToken is required if one had not been previously received + /// in the authorization response. An access token can optionally be provided for the middleware to contact the + /// user-info endpoint. Calling this is the same as setting TokenEndpointResponse. + /// + public void HandleCodeRedemption(OpenIdConnectMessage tokenEndpointResponse) + { + TokenEndpointResponse = tokenEndpointResponse; + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 4084e21007..4dc4a32b85 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -303,7 +303,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Invoked to process incoming OpenIdConnect messages. ///
/// An if successful. - /// Uses log id's OIDCH-0000 - OIDCH-0025 protected override async Task HandleRemoteAuthenticateAsync() { Logger.LogTrace(10, "Entering: {0}." + nameof(HandleRemoteAuthenticateAsync), GetType()); @@ -450,16 +449,23 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // Authorization Code or Hybrid flow if (!string.IsNullOrEmpty(authorizationResponse.Code)) { - // TODO: Does this event provide any value over AuthorizationResponseReceived or AuthorizationResponseValidated? var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(authorizationResponse, properties, ticket, jwt); if (CheckEventResult(authorizationCodeReceivedContext, out result)) { return result; } authorizationResponse = authorizationCodeReceivedContext.ProtocolMessage; - var code = authorizationCodeReceivedContext.Code; + properties = authorizationCodeReceivedContext.Properties; + var tokenEndpointRequest = authorizationCodeReceivedContext.TokenEndpointRequest; + // If the developer redeemed the code themselves... + tokenEndpointResponse = authorizationCodeReceivedContext.TokenEndpointResponse; + ticket = authorizationCodeReceivedContext.Ticket; + jwt = authorizationCodeReceivedContext.JwtSecurityToken; - tokenEndpointResponse = await RedeemAuthorizationCodeAsync(code, authorizationCodeReceivedContext.RedirectUri); + if (!authorizationCodeReceivedContext.HandledCodeRedemption) + { + tokenEndpointResponse = await RedeemAuthorizationCodeAsync(tokenEndpointRequest); + } var authorizationCodeRedeemedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties); if (CheckEventResult(authorizationCodeRedeemedContext, out result)) @@ -485,13 +491,17 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } } - Options.ProtocolValidator.ValidateTokenResponse(new OpenIdConnectProtocolValidationContext() + // Validate the token response if it wasn't provided manually + if (!authorizationCodeReceivedContext.HandledCodeRedemption) { - ClientId = Options.ClientId, - ProtocolMessage = tokenEndpointResponse, - ValidatedIdToken = jwt, - Nonce = nonce - }); + Options.ProtocolValidator.ValidateTokenResponse(new OpenIdConnectProtocolValidationContext() + { + ClientId = Options.ClientId, + ProtocolMessage = tokenEndpointResponse, + ValidatedIdToken = jwt, + Nonce = nonce + }); + } } var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(authorizationResponse, ticket, properties, tokenEndpointResponse); @@ -574,23 +584,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// The authorization code to redeem. /// Uri that was passed in the request sent for the authorization code. /// OpenIdConnect message that has tokens inside it. - protected virtual async Task RedeemAuthorizationCodeAsync(string authorizationCode, string redirectUri) + protected virtual async Task RedeemAuthorizationCodeAsync(OpenIdConnectMessage tokenEndpointRequest) { Logger.LogDebug(21, "Redeeming code for tokens."); - - var openIdMessage = new OpenIdConnectMessage() - { - ClientId = Options.ClientId, - ClientSecret = Options.ClientSecret, - Code = authorizationCode, - GrantType = "authorization_code", - RedirectUri = redirectUri - }; - - // TODO: Event that lets you customize the message. E.g. use certificates, specify resources. - var requestMessage = new HttpRequestMessage(HttpMethod.Post, _configuration.TokenEndpoint); - requestMessage.Content = new FormUrlEncodedContent(openIdMessage.Parameters); + requestMessage.Content = new FormUrlEncodedContent(tokenEndpointRequest.Parameters); var responseMessage = await Backchannel.SendAsync(requestMessage); responseMessage.EnsureSuccessStatusCode(); var tokenResonse = await responseMessage.Content.ReadAsStringAsync(); @@ -874,19 +872,27 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return authorizationResponseReceivedContext; } - private async Task RunAuthorizationCodeReceivedEventAsync(OpenIdConnectMessage message, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt) + private async Task RunAuthorizationCodeReceivedEventAsync(OpenIdConnectMessage authorizationResponse, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt) { - var redirectUri = properties.Items[OpenIdConnectDefaults.RedirectUriForCodePropertiesKey]; + Logger.LogTrace(32, "AuthorizationCode received"); - Logger.LogTrace(32, "AuthorizationCode received: '{0}'", message.Code); - - var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Options, properties) + var tokenEndpointRequest = new OpenIdConnectMessage() { - Code = message.Code, - ProtocolMessage = message, - RedirectUri = redirectUri, + ClientId = Options.ClientId, + ClientSecret = Options.ClientSecret, + Code = authorizationResponse.Code, + GrantType = OpenIdConnectGrantTypes.AuthorizationCode, + RedirectUri = properties.Items[OpenIdConnectDefaults.RedirectUriForCodePropertiesKey] + }; + + var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Options) + { + ProtocolMessage = authorizationResponse, + Properties = properties, + TokenEndpointRequest = tokenEndpointRequest, Ticket = ticket, - JwtSecurityToken = jwt + JwtSecurityToken = jwt, + Backchannel = Backchannel, }; await Options.Events.AuthorizationCodeReceived(authorizationCodeReceivedContext); From a9ac505088024afc671dd340b9fc80c488959e60 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Wed, 24 Feb 2016 13:04:07 -0800 Subject: [PATCH 472/900] Use Mono 4.0.5 - Mono beta is now 4.2.1 which doesn't work reliably with `nuget.exe` - see also aspnet/External#48 --- build.cmd | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build.cmd b/build.cmd index ebb619e737..95b049cf63 100644 --- a/build.cmd +++ b/build.cmd @@ -2,7 +2,7 @@ SETLOCAL SET REPO_FOLDER=%~dp0 -CD %REPO_FOLDER% +CD "%REPO_FOLDER%" SET BUILD_FOLDER=.build SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet @@ -28,12 +28,11 @@ IF NOT EXIST %NUGET_PATH% ( copy %CACHED_NUGET% %NUGET_PATH% > nul ) +SET KOREBUILD_DOWNLOAD_ARGS= +IF NOT "%KOREBUILD_VERSION%"=="" ( + SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% +) IF NOT EXIST %KOREBUILD_FOLDER% ( - SET KOREBUILD_DOWNLOAD_ARGS= - IF NOT "%KOREBUILD_VERSION%"=="" ( - SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% - ) - %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS% ) From 4499c55109fa59a0336ce73763027bd850a9761e Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Sat, 27 Feb 2016 12:51:14 -0800 Subject: [PATCH 473/900] Update the build scripts --- build.cmd | 41 ++----------------------------------- build.ps1 | 36 +++++++++++++++++++++++++++++++++ build.sh | 60 +++++++++++++++++++++++-------------------------------- 3 files changed, 63 insertions(+), 74 deletions(-) create mode 100644 build.ps1 diff --git a/build.cmd b/build.cmd index 95b049cf63..2fa024b15e 100644 --- a/build.cmd +++ b/build.cmd @@ -1,39 +1,2 @@ -@ECHO off -SETLOCAL - -SET REPO_FOLDER=%~dp0 -CD "%REPO_FOLDER%" - -SET BUILD_FOLDER=.build -SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet -SET KOREBUILD_VERSION= - -SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe -SET NUGET_VERSION=latest -SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe - -IF NOT EXIST %BUILD_FOLDER% ( - md %BUILD_FOLDER% -) - -IF NOT EXIST %NUGET_PATH% ( - IF NOT EXIST %CACHED_NUGET% ( - echo Downloading latest version of NuGet.exe... - IF NOT EXIST %LocalAppData%\NuGet ( - md %LocalAppData%\NuGet - ) - @powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" - ) - - copy %CACHED_NUGET% %NUGET_PATH% > nul -) - -SET KOREBUILD_DOWNLOAD_ARGS= -IF NOT "%KOREBUILD_VERSION%"=="" ( - SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% -) -IF NOT EXIST %KOREBUILD_FOLDER% ( - %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS% -) - -"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %* +@ECHO OFF +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*" \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000000..4fd24a30d5 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,36 @@ +cd $PSScriptRoot + +$repoFolder = $PSScriptRoot +$env:REPO_FOLDER = $repoFolder + +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +if ($env:KOREBUILD_ZIP) +{ + $koreBuildZip=$env:KOREBUILD_ZIP +} + +$buildFolder = ".build" +$buildFile="$buildFolder\KoreBuild.ps1" + +if (!(Test-Path $buildFolder)) { + Write-Host "Downloading KoreBuild from $koreBuildZip" + + $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() + New-Item -Path "$tempFolder" -Type directory | Out-Null + + $localZipFile="$tempFolder\korebuild.zip" + + Invoke-WebRequest $koreBuildZip -OutFile $localZipFile + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) + + New-Item -Path "$buildFolder" -Type directory | Out-Null + copy-item "$tempFolder\**\build\*" $buildFolder -Recurse + + # Cleanup + if (Test-Path $tempFolder) { + Remove-Item -Recurse -Force $tempFolder + } +} + +&"$buildFile" $args \ No newline at end of file diff --git a/build.sh b/build.sh index 263fb667a8..79638d06b6 100755 --- a/build.sh +++ b/build.sh @@ -1,45 +1,35 @@ #!/usr/bin/env bash +repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $repoFolder -buildFolder=.build -koreBuildFolder=$buildFolder/KoreBuild-dotnet - -nugetPath=$buildFolder/nuget.exe - -if test `uname` = Darwin; then - cachedir=~/Library/Caches/KBuild -else - if [ -z $XDG_DATA_HOME ]; then - cachedir=$HOME/.local/share - else - cachedir=$XDG_DATA_HOME; - fi +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +if [ ! -z $KOREBUILD_ZIP ]; then + koreBuildZip=$KOREBUILD_ZIP fi -mkdir -p $cachedir -nugetVersion=latest -cacheNuget=$cachedir/nuget.$nugetVersion.exe -nugetUrl=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe +buildFolder=".build" +buildFile="$buildFolder/KoreBuild.sh" if test ! -d $buildFolder; then + echo "Downloading KoreBuild from $koreBuildZip" + + tempFolder="/tmp/KoreBuild-$(uuidgen)" + mkdir $tempFolder + + localZipFile="$tempFolder/korebuild.zip" + + wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip /dev/null + unzip -q -d $tempFolder $localZipFile + mkdir $buildFolder -fi - -if test ! -f $nugetPath; then - if test ! -f $cacheNuget; then - wget -O $cacheNuget $nugetUrl 2>/dev/null || curl -o $cacheNuget --location $nugetUrl /dev/null + cp -r $tempFolder/**/build/** $buildFolder + + chmod +x $buildFile + + # Cleanup + if test ! -d $tempFolder; then + rm -rf $tempFolder fi - - cp $cacheNuget $nugetPath fi -if test ! -d $koreBuildFolder; then - mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre - chmod +x $koreBuildFolder/build/KoreBuild.sh -fi - -makeFile=makefile.shade -if [ ! -e $makeFile ]; then - makeFile=$koreBuildFolder/build/makefile.shade -fi - -./$koreBuildFolder/build/KoreBuild.sh -n $nugetPath -m $makeFile "$@" +$buildFile -r $repoFolder "$@" From 9a57f8116da0b1cd9eb2d7114df4a7ca42590057 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Sun, 28 Feb 2016 10:12:17 -0800 Subject: [PATCH 474/900] Return the error code from build.cmd --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index 2fa024b15e..7d4894cb4a 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*" \ No newline at end of file +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" \ No newline at end of file From e3979fd3feb5d55b47bb4115f2afd0cf61f632b0 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 1 Mar 2016 13:36:53 -0800 Subject: [PATCH 475/900] Transition to netstandard. - dotnet5.X => netstandard1.y (where y = x-1). - DNXCore50 => netstandardapp1.5. - Applied the same changes to ifdefs. --- samples/CookieSample/project.json | 10 +++++++--- samples/CookieSessionSample/project.json | 10 +++++++--- samples/JwtBearerSample/project.json | 10 +++++++--- samples/OpenIdConnectSample/project.json | 6 +++++- samples/SocialSample/project.json | 10 +++++++--- .../project.json | 6 +++++- .../project.json | 7 +++++-- .../project.json | 7 +++++-- .../project.json | 11 +++++++---- .../project.json | 7 +++++-- .../project.json | 9 ++++++--- .../project.json | 7 +++++-- .../project.json | 9 ++++++--- src/Microsoft.AspNetCore.Authentication/project.json | 9 ++++++--- src/Microsoft.AspNetCore.Authorization/project.json | 9 ++++++--- src/Microsoft.AspNetCore.CookiePolicy/project.json | 6 +++++- .../project.json | 9 ++++++--- .../project.json | 11 +++++++---- .../project.json | 9 ++++++--- 19 files changed, 113 insertions(+), 49 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index fa17dd9cf3..a3e9f4556d 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -14,7 +14,11 @@ "web": "CookieSample" }, "frameworks": { - "dnx451": { }, - "dnxcore50": { } + "dnx451": {}, + "netstandardapp1.5": { + "imports": [ + "dnxcore50" + ] + } } -} +} \ No newline at end of file diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index 8de831b403..e60b1b355c 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -15,7 +15,11 @@ "web": "CookieSessionSample" }, "frameworks": { - "dnx451": { }, - "dnxcore50": { } + "dnx451": {}, + "netstandardapp1.5": { + "imports": [ + "dnxcore50" + ] + } } -} +} \ No newline at end of file diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 436a2203be..0f6a6c9df5 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -15,8 +15,12 @@ "web": "JwtBearerSample" }, "frameworks": { - "dnx451": { }, - "dnxcore50": { } + "dnx451": {}, + "netstandardapp1.5": { + "imports": [ + "dnxcore50" + ] + } }, "exclude": [ "wwwroot", @@ -27,4 +31,4 @@ "**.vspscc" ], "userSecretsId": "aspnet5-JwtBearerSample-20151210102827" -} +} \ No newline at end of file diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index e5bec9e8c6..12d88dfed1 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -10,7 +10,11 @@ }, "frameworks": { "dnx451": {}, - "dnxcore50": {} + "netstandardapp1.5": { + "imports": [ + "dnxcore50" + ] + } }, "compilationOptions": { "emitEntryPoint": true diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 00570902f6..a4c71e0b70 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -19,8 +19,12 @@ "web": "SocialSample" }, "frameworks": { - "dnx451": { }, - "dnxcore50": { } + "dnx451": {}, + "netstandardapp1.5": { + "imports": [ + "dnxcore50" + ] + } }, "userSecretsId": "aspnet5-SocialSample-20151210111056" -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index 5ceb5b7a64..46666ed124 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -16,6 +16,10 @@ }, "frameworks": { "net451": {}, - "dotnet5.4": {} + "netstandard1.3": { + "imports": [ + "dotnet5.4" + ] + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 5dbf6f6cfb..e93b2feb4d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -14,8 +14,11 @@ }, "frameworks": { "net451": {}, - "dotnet5.4": { - "imports": "portable-net451+win8" + "netstandard1.3": { + "imports": [ + "dotnet5.4", + "portable-net451+win8" + ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index 929424cc14..d250dee275 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -14,8 +14,11 @@ }, "frameworks": { "net451": {}, - "dotnet5.4": { - "imports": "portable-net451+win8" + "netstandard1.3": { + "imports": [ + "dotnet5.4", + "portable-net451+win8" + ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index f6e200b7c2..21be97e4b8 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -14,9 +14,12 @@ "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { - "net451": { }, - "dotnet5.4": { - "imports": "portable-net451+win8" + "net451": {}, + "netstandard1.3": { + "imports": [ + "dotnet5.4", + "portable-net451+win8" + ] } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index c415b2a63f..468955a931 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -14,8 +14,11 @@ }, "frameworks": { "net451": {}, - "dotnet5.4": { - "imports": "portable-net451+win8" + "netstandard1.3": { + "imports": [ + "dotnet5.4", + "portable-net451+win8" + ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index c5128412c4..dc073ab7ba 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -19,11 +19,14 @@ "System.Net.Http": "" } }, - "dotnet5.4": { + "netstandard1.3": { "dependencies": { "System.Net.Http": "4.0.1-*" }, - "imports": "portable-net451+win8" + "imports": [ + "dotnet5.4", + "portable-net451+win8" + ] } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 90487a898b..fc58e6a890 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -15,8 +15,11 @@ }, "frameworks": { "net451": {}, - "dotnet5.4": { - "imports": "portable-net451+win8" + "netstandard1.3": { + "imports": [ + "dotnet5.4", + "portable-net451+win8" + ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 67ebf2c0db..8dd3556bcc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -18,10 +18,13 @@ "System.Net.Http": "" } }, - "dotnet5.4": { + "netstandard1.3": { "dependencies": { "System.Net.Http": "4.0.1-*" - } + }, + "imports": [ + "dotnet5.4" + ] } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index d34a6697bc..73f7ed80d2 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -27,11 +27,14 @@ "System.Net.Http": "" } }, - "dotnet5.4": { + "netstandard1.3": { "dependencies": { "System.Net.Http": "4.0.1-*" }, - "imports": "portable-net451" + "imports": [ + "dotnet5.4", + "portable-net451" + ] } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 688fd84037..f07e8d2d5d 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -14,11 +14,14 @@ "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { - "net451": { }, - "dotnet5.4": { + "net451": {}, + "netstandard1.3": { "dependencies": { "System.Security.Claims": "4.0.1-*" - } + }, + "imports": [ + "dotnet5.4" + ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json index a2c04f1455..ce4c552dc9 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/project.json @@ -15,6 +15,10 @@ }, "frameworks": { "net451": {}, - "dotnet5.4": {} + "netstandard1.3": { + "imports": [ + "dotnet5.4" + ] + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index eb36173bf2..c05a8963b7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -16,11 +16,14 @@ "xunit": "2.1.0" }, "frameworks": { - "dnxcore50": { + "netstandardapp1.5": { "dependencies": { "dotnet-test-xunit": "1.0.0-dev-*" }, - "imports": "portable-net451+win8" + "imports": [ + "dnxcore50", + "portable-net451+win8" + ] }, "net451": { "frameworkAssemblies": { @@ -33,4 +36,4 @@ } }, "testRunner": "xunit" -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 651b9acb69..560766c038 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -11,11 +11,14 @@ "xunit": "2.1.0" }, "frameworks": { - "dnxcore50": { + "netstandardapp1.5": { "dependencies": { - "dotnet-test-xunit": "1.0.0-dev-*" + "dotnet-test-xunit": "1.0.0-dev-*" }, - "imports": "portable-net451+win8" + "imports": [ + "dnxcore50", + "portable-net451+win8" + ] }, "net451": { "frameworkAssemblies": { @@ -28,4 +31,4 @@ } }, "testRunner": "xunit" -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index db1fce596a..f6dad148ab 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -10,11 +10,14 @@ "xunit": "2.1.0" }, "frameworks": { - "dnxcore50": { + "netstandardapp1.5": { "dependencies": { "dotnet-test-xunit": "1.0.0-dev-*" }, - "imports": "portable-net451+win8" + "imports": [ + "dnxcore50", + "portable-net451+win8" + ] }, "net451": { "frameworkAssemblies": { @@ -28,4 +31,4 @@ } }, "testRunner": "xunit" -} +} \ No newline at end of file From e9760b48d039b40345f51bd14e61d44b6fb98d80 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Wed, 2 Mar 2016 09:31:20 -0800 Subject: [PATCH 476/900] Fixed broken link Fixes https://github.com/aspnet/Security/issues/724. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b994c1eeac..02e65225c1 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,4 @@ This project is part of ASP.NET 5. You can find samples, documentation and getti ### Notes -ASP.NET Security will not include Basic Authentication middleware due to its potential insecurity and performance problems. If you host under IIS you can enable it via IIS configuration. If you require Basic Authentication middleware for testing purposes, as a shared secret authentication mechanism for server to server communication, or to use a database as a user source then please look at the samples from [leastprivilege](https://github.com/leastprivilege/BasicAuthentication.AspNet5) or [Kukkimonsuta](https://github.com/Kukkimonsuta/Odachi/tree/master/src/Odachi.AspNet.Authentication.Basic). +ASP.NET Security will not include Basic Authentication middleware due to its potential insecurity and performance problems. If you host under IIS you can enable it via IIS configuration. If you require Basic Authentication middleware for testing purposes, as a shared secret authentication mechanism for server to server communication, or to use a database as a user source then please look at the samples from [leastprivilege](https://github.com/leastprivilege/BasicAuthentication.AspNet5) or [Kukkimonsuta](https://github.com/Kukkimonsuta/Odachi/tree/master/src/Odachi.AspNetCore.Authentication.Basic). From b5300ad0e4c48a9d69b3be27df8bed9db3f959b2 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 2 Mar 2016 13:46:47 -0800 Subject: [PATCH 477/900] Update doc comments --- .../CookieAuthenticationOptions.cs | 2 +- .../OpenIdConnectOptions.cs | 2 +- .../AuthenticationOptions.cs | 2 +- .../ClaimsTransformationOptions.cs | 6 ++++++ .../IClaimsTransformer.cs | 8 ++++++++ .../RemoteAuthenticationOptions.cs | 3 +++ .../AuthorizationOptions.cs | 18 ++++++++++++++++++ .../CookiePolicyOptions.cs | 16 ++++++++++++++++ 8 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index dc1a63bbf3..51cf43a0f1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -13,7 +13,7 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { /// - /// Contains the options used by the CookiesAuthenticationMiddleware + /// Configuration options for . /// public class CookieAuthenticationOptions : AuthenticationOptions, IOptions { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index de7bee1633..1b179c3369 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -17,7 +17,7 @@ using Microsoft.IdentityModel.Tokens; namespace Microsoft.AspNetCore.Builder { /// - /// Configuration options for + /// Configuration options for /// public class OpenIdConnectOptions : RemoteAuthenticationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs index 8f1fb06912..04d050b06e 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Builder { /// - /// Base Options for all authentication middleware + /// Base Options for all authentication middleware. /// public abstract class AuthenticationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs index 7772457a02..70a76f27c6 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs @@ -5,8 +5,14 @@ using Microsoft.AspNetCore.Authentication; namespace Microsoft.AspNetCore.Builder { + /// + /// Contains the options used by the . + /// public class ClaimsTransformationOptions { + /// + /// Responsible for transforming the claims principal. + /// public IClaimsTransformer Transformer { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs b/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs index 03eece9318..5111c79714 100644 --- a/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs +++ b/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs @@ -6,8 +6,16 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authentication { + /// + /// Used for claims transformation. + /// public interface IClaimsTransformer { + /// + /// Provides a central transformation point to change the specified principal. + /// + /// The principal to transform. + /// The transformed principal. Task TransformAsync(ClaimsPrincipal principal); } } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 0388c04bda..43e011c40e 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -8,6 +8,9 @@ using Microsoft.AspNetCore.Authentication; namespace Microsoft.AspNetCore.Builder { + /// + /// Contains the options used by the . + /// public class RemoteAuthenticationOptions : AuthenticationOptions { /// diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs index c3019c907f..94799af29b 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -6,6 +6,9 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Authorization { + /// + /// Provides programmatic configuration used by and . + /// public class AuthorizationOptions { private IDictionary PolicyMap { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -15,6 +18,11 @@ namespace Microsoft.AspNetCore.Authorization /// public AuthorizationPolicy DefaultPolicy { get; set; } = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + /// + /// Add an authorization policy with the provided name. + /// + /// The name of the policy. + /// The authorization policy. public void AddPolicy(string name, AuthorizationPolicy policy) { if (name == null) @@ -30,6 +38,11 @@ namespace Microsoft.AspNetCore.Authorization PolicyMap[name] = policy; } + /// + /// Add a policy that is built from a delegate with the provided name. + /// + /// The name of the policy. + /// The delegate that will be used to build the policy. public void AddPolicy(string name, Action configurePolicy) { if (name == null) @@ -47,6 +60,11 @@ namespace Microsoft.AspNetCore.Authorization PolicyMap[name] = policyBuilder.Build(); } + /// + /// Returns the policy for the specified name, or null if a policy with the name does not exist. + /// + /// The name of the policy to return. + /// The policy for the specified name, or null if a policy with the name does not exist. public AuthorizationPolicy GetPolicy(string name) { if (name == null) diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index 812c714288..8201b58639 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -6,12 +6,28 @@ using Microsoft.AspNetCore.CookiePolicy; namespace Microsoft.AspNetCore.Builder { + /// + /// Provides programmatic configuration for the . + /// public class CookiePolicyOptions { + /// + /// Affects whether cookies must be HttpOnly. + /// public HttpOnlyPolicy HttpOnly { get; set; } = HttpOnlyPolicy.None; + /// + /// Affects whether cookies must be Secure. + /// public SecurePolicy Secure { get; set; } = SecurePolicy.None; + /// + /// Called when a cookie is appended. + /// public Action OnAppendCookie { get; set; } + + /// + /// Called when a cookie is deleted. + /// public Action OnDeleteCookie { get; set; } } } \ No newline at end of file From fbb628298cfabb610464388c42b7a8392295145a Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Wed, 2 Mar 2016 21:20:11 -0800 Subject: [PATCH 478/900] Remove project name from output path - aspnet/Coherence-Signed#187 - remove `` settings but maintain other unique aspects e.g. `` - in a few cases, standardize on VS version `14.0` and not something more specific --- samples/CookieSample/CookieSample.xproj | 2 +- samples/CookieSessionSample/CookieSessionSample.xproj | 2 +- samples/JwtBearerSample/JwtBearerSample.xproj | 7 ++----- .../OpenIdConnect.AzureAdSample.xproj | 3 +-- samples/OpenIdConnectSample/OpenIdConnectSample.xproj | 2 +- samples/SocialSample/SocialSample.xproj | 2 +- .../Microsoft.AspNetCore.Authentication.Cookies.xproj | 2 +- .../Microsoft.AspNetCore.Authentication.Facebook.xproj | 2 +- .../Microsoft.AspNetCore.Authentication.Google.xproj | 2 +- .../Microsoft.AspNetCore.Authentication.JwtBearer.xproj | 2 +- ...soft.AspNetCore.Authentication.MicrosoftAccount.xproj | 2 +- .../Microsoft.AspNetCore.Authentication.OAuth.xproj | 2 +- ...crosoft.AspNetCore.Authentication.OpenIdConnect.xproj | 2 +- .../Microsoft.AspNetCore.Authentication.Twitter.xproj | 2 +- .../Microsoft.AspNetCore.Authentication.xproj | 2 +- .../Microsoft.AspNetCore.Authorization.xproj | 2 +- .../Microsoft.AspNetCore.CookiePolicy.xproj | 6 ++---- .../Microsoft.Owin.Security.Interop.xproj | 9 +++------ .../Microsoft.AspNetCore.Authentication.Test.xproj | 2 +- .../Microsoft.AspNetCore.Authorization.Test.xproj | 2 +- .../Microsoft.AspNetCore.CookiePolicy.Test.xproj | 5 ++--- .../Microsoft.Owin.Security.Interop.Test.xproj | 3 +-- 22 files changed, 27 insertions(+), 38 deletions(-) diff --git a/samples/CookieSample/CookieSample.xproj b/samples/CookieSample/CookieSample.xproj index 50d06f00e8..bb23e6481a 100644 --- a/samples/CookieSample/CookieSample.xproj +++ b/samples/CookieSample/CookieSample.xproj @@ -8,7 +8,7 @@ 558c2c2a-aed8-49de-bb60-d5f8ae06c714 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/samples/CookieSessionSample/CookieSessionSample.xproj b/samples/CookieSessionSample/CookieSessionSample.xproj index ec3d4dd5e6..c81393af16 100644 --- a/samples/CookieSessionSample/CookieSessionSample.xproj +++ b/samples/CookieSessionSample/CookieSessionSample.xproj @@ -8,7 +8,7 @@ 19711880-46da-4a26-9e0f-9b2e41d27651 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/samples/JwtBearerSample/JwtBearerSample.xproj b/samples/JwtBearerSample/JwtBearerSample.xproj index 15adb23f1b..ed0c9b32bd 100644 --- a/samples/JwtBearerSample/JwtBearerSample.xproj +++ b/samples/JwtBearerSample/JwtBearerSample.xproj @@ -4,15 +4,12 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - d399b84f-591b-4e98-92ba-b0f63e7b6957 - JwtBearerSample ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ - 2.0 @@ -22,4 +19,4 @@ - + \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj index c7b0ff10ed..e3495a2118 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj @@ -7,9 +7,8 @@ 3a7ad414-ebde-4f92-b307-4e8f19b6117e - OpenIdConnect.AzureAdSample ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.xproj b/samples/OpenIdConnectSample/OpenIdConnectSample.xproj index 1f0879ea47..905bce8e3b 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.xproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.xproj @@ -8,7 +8,7 @@ bef0f5c3-ef4e-4649-9c49-d5e279a3ca2b ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/samples/SocialSample/SocialSample.xproj b/samples/SocialSample/SocialSample.xproj index 3d2aa528d0..775eebbc26 100644 --- a/samples/SocialSample/SocialSample.xproj +++ b/samples/SocialSample/SocialSample.xproj @@ -8,7 +8,7 @@ 8c73d216-332d-41d8-bfd0-45bc4bc36552 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj index bc93d6322f..8c4f3cd41f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj @@ -8,7 +8,7 @@ fc152cc4-054b-457e-8d91-389c5de3c561 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj index 68ee50c4b7..3952592121 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj @@ -8,7 +8,7 @@ eeaaee68-607b-4e33-af3e-45c66b4dba5a ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj index f92646ce65..ff412f08ae 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj @@ -8,7 +8,7 @@ 76579c39-b829-490d-b8be-1bd35fe8412e ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj index ef8673b48c..8d87a04b76 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj @@ -8,7 +8,7 @@ 2755BFE5-7421-4A31-A644-F817DF5CAA98 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj index c15c0534e8..52dd6cb676 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj @@ -8,7 +8,7 @@ acb45e19-f520-4d0c-8916-b0ceb9c017fe ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj index 962888b9de..34a397bd59 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj @@ -8,7 +8,7 @@ 1657c79e-7755-4aee-9d61-571295b69a30 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj index 9ae8192f24..2f970b5136 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj @@ -8,7 +8,7 @@ 35115d55-b69e-46d4-bb33-c9e9e6ec5e7a ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj index 55deb0714f..5fba7a9742 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj @@ -8,7 +8,7 @@ 0330fff6-b4b5-42dd-8c99-26a789569000 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj index fe12613f9e..e03db08476 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj @@ -8,7 +8,7 @@ 2286250a-52c8-4126-9f93-b1e45f0ad078 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj index be8ba0e0ea..c6a57567b4 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj @@ -8,7 +8,7 @@ 6ab3e514-5894-4131-9399-dc7d5284addb ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj index 4b5fbfe3b9..5ffad968d9 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -7,11 +7,9 @@ 86183dc3-02a8-4a68-8b60-71ecec066e79 - Microsoft.AspNetCore.CookiePolicy ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ - 2.0 diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj index bb58ad7121..c6b01504ae 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj @@ -4,17 +4,14 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - a7922dd8-09f1-43e4-938b-cc523ea08898 - Microsoft.Owin.Security.Interop - ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\ - 2.0 - + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj index aaf23b99e3..aec10ee939 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj @@ -8,7 +8,7 @@ 8da26cd1-1302-4cfd-9270-9fa1b7c6138b ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj index 579dd0f442..d596a5bb47 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj @@ -8,7 +8,7 @@ 7af5ad96-eb6e-4d0e-8abe-c0b543c0f4c2 ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj index b04b3cd612..cf42659a08 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj @@ -1,4 +1,4 @@ - + 14.0 @@ -7,9 +7,8 @@ 1790e052-646f-4529-b90e-6fea95520d69 - Microsoft.AspNetCore.CookiePolicy.Test ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj index c3f5e576de..96d5b6c5a0 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj @@ -7,9 +7,8 @@ a2b5dc39-68d5-4145-a8cc-6aeab7d33a24 - Microsoft.Owin.Security.Interop.Test ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 From cedef4dcbaf6f0b7a36270bbe13040e8b4103aed Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 3 Mar 2016 06:39:15 -0800 Subject: [PATCH 479/900] Fix build break --- src/Microsoft.AspNetCore.Authorization/project.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index f07e8d2d5d..511a05d56c 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -14,7 +14,11 @@ "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { - "net451": {}, + "net451": { + "frameworkAssemblies": { + "System.Runtime": { "type": "build" } + } + }, "netstandard1.3": { "dependencies": { "System.Security.Claims": "4.0.1-*" From ace166fa31af61a6c9924873e6bdcb45e7785d5d Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 3 Mar 2016 12:50:46 -0800 Subject: [PATCH 480/900] Save tokens in auth properties instead of claims --- samples/SocialSample/Startup.cs | 66 ++++---- .../JwtBearerHandler.cs | 8 + .../JwtBearerOptions.cs | 6 + .../OAuthHandler.cs | 23 +-- .../OpenIdConnectHandler.cs | 27 ++-- .../TwitterHandler.cs | 8 +- .../AuthenticationToken.cs | 12 ++ .../RemoteAuthenticationOptions.cs | 16 +- .../TokenExtensions.cs | 115 ++++++++++++++ .../Google/GoogleMiddlewareTests.cs | 15 ++ .../TestExtensions.cs | 19 +++ .../TokenExtensionTests.cs | 144 ++++++++++++++++++ .../Transaction.cs | 12 ++ 13 files changed, 404 insertions(+), 67 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication/AuthenticationToken.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index ffbaf8dc59..4ab304c32e 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -5,6 +5,7 @@ using System.Net.Http.Headers; using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Google; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; @@ -71,13 +72,13 @@ namespace CookieSample // You must first create an app with facebook and add it's ID and Secret to your config.json or user-secrets. // https://developers.facebook.com/apps/ - app.UseFacebookAuthentication(new FacebookOptions - { - AppId = Configuration["facebook:appid"], - AppSecret = Configuration["facebook:appsecret"], - Scope = { "email" }, - Fields = { "name", "email" } - }); + //app.UseFacebookAuthentication(new FacebookOptions + //{ + // AppId = Configuration["facebook:appid"], + // AppSecret = Configuration["facebook:appsecret"], + // Scope = { "email" }, + // Fields = { "name", "email" } + //}); // See config.json app.UseOAuthAuthentication(new OAuthOptions @@ -90,7 +91,7 @@ namespace CookieSample AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint, TokenEndpoint = GoogleDefaults.TokenEndpoint, Scope = { "openid", "profile", "email" }, - SaveTokensAsClaims = true + SaveTokens = true }); // See config.json @@ -146,27 +147,27 @@ namespace CookieSample The sample app can then be run via: dnx web */ - app.UseOAuthAuthentication(new OAuthOptions - { - AuthenticationScheme = "Microsoft-AccessToken", - DisplayName = "MicrosoftAccount-AccessToken - Requires project changes", - ClientId = Configuration["msa:clientid"], - ClientSecret = Configuration["msa:clientsecret"], - CallbackPath = new PathString("/signin-microsoft-token"), - AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint, - TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint, - Scope = { "wl.basic" }, - SaveTokensAsClaims = true - }); + //app.UseOAuthAuthentication(new OAuthOptions + //{ + // AuthenticationScheme = "Microsoft-AccessToken", + // DisplayName = "MicrosoftAccount-AccessToken - Requires project changes", + // ClientId = Configuration["msa:clientid"], + // ClientSecret = Configuration["msa:clientsecret"], + // CallbackPath = new PathString("/signin-microsoft-token"), + // AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint, + // TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint, + // Scope = { "wl.basic" }, + // SaveTokens = true + //}); - //// You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. - app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions - { - DisplayName = "MicrosoftAccount - Requires project changes", - ClientId = Configuration["msa:clientid"], - ClientSecret = Configuration["msa:clientsecret"], - Scope = { "wl.emails" } - }); + ////// You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. + //app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions + //{ + // DisplayName = "MicrosoftAccount - Requires project changes", + // ClientId = Configuration["msa:clientid"], + // ClientSecret = Configuration["msa:clientsecret"], + // Scope = { "wl.emails" } + //}); // See config.json // https://github.com/settings/applications/ @@ -179,7 +180,7 @@ namespace CookieSample CallbackPath = new PathString("/signin-github-token"), AuthorizationEndpoint = "https://github.com/login/oauth/authorize", TokenEndpoint = "https://github.com/login/oauth/access_token", - SaveTokensAsClaims = true + SaveTokens = true }); // See config.json @@ -318,6 +319,13 @@ namespace CookieSample { await context.Response.WriteAsync(claim.Type + ": " + claim.Value + "
"); } + + await context.Response.WriteAsync("Tokens:
"); + + await context.Response.WriteAsync("Access Token: " + await AuthenticationToken.GetTokenAsync(context, CookieAuthenticationDefaults.AuthenticationScheme, "access_token") + "
"); + await context.Response.WriteAsync("Refresh Token: " + await AuthenticationToken.GetTokenAsync(context, CookieAuthenticationDefaults.AuthenticationScheme, "refresh_token") + "
"); + await context.Response.WriteAsync("Token Type: " + await AuthenticationToken.GetTokenAsync(context, CookieAuthenticationDefaults.AuthenticationScheme, "token_type") + "
"); + await context.Response.WriteAsync("expires_at: " + await AuthenticationToken.GetTokenAsync(context, CookieAuthenticationDefaults.AuthenticationScheme, "expires_at") + "
"); await context.Response.WriteAsync("Logout"); await context.Response.WriteAsync(""); }); diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 00ecae0fb2..613dfbc152 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -153,6 +153,14 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer return AuthenticateResult.Skip(); } + if (Options.SaveToken) + { + ticket.Properties.StoreTokens(new[] + { + new AuthenticationToken { Name = "access_token", Value = token } + }); + } + return AuthenticateResult.Success(ticket); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs index 0a08ff3e44..a4b5ef2ae2 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -110,5 +110,11 @@ namespace Microsoft.AspNetCore.Builder /// Contains the types and definitions required for validating a token. /// if 'value' is null. public TokenValidationParameters TokenValidationParameters { get; set; } = new TokenValidationParameters(); + + /// + /// Defines whether the bearer token should be stored in the + /// after a successful authorization. + /// + public bool SaveToken { get; set; } = true; } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 7a06bee702..ddd26d9f01 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -85,21 +85,19 @@ namespace Microsoft.AspNetCore.Authentication.OAuth var identity = new ClaimsIdentity(Options.ClaimsIssuer); - if (Options.SaveTokensAsClaims) + if (Options.SaveTokens) { - identity.AddClaim(new Claim("access_token", tokens.AccessToken, - ClaimValueTypes.String, Options.ClaimsIssuer)); + var authTokens = new List(); + authTokens.Add(new AuthenticationToken { Name = "access_token", Value = tokens.AccessToken }); if (!string.IsNullOrEmpty(tokens.RefreshToken)) { - identity.AddClaim(new Claim("refresh_token", tokens.RefreshToken, - ClaimValueTypes.String, Options.ClaimsIssuer)); + authTokens.Add(new AuthenticationToken { Name = "refresh_token", Value = tokens.RefreshToken }); } if (!string.IsNullOrEmpty(tokens.TokenType)) { - identity.AddClaim(new Claim("token_type", tokens.TokenType, - ClaimValueTypes.String, Options.ClaimsIssuer)); + authTokens.Add(new AuthenticationToken { Name = "token_type", Value = tokens.TokenType }); } if (!string.IsNullOrEmpty(tokens.ExpiresIn)) @@ -107,13 +105,18 @@ namespace Microsoft.AspNetCore.Authentication.OAuth int value; if (int.TryParse(tokens.ExpiresIn, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) { - var expiresAt = Options.SystemClock.UtcNow + TimeSpan.FromSeconds(value); // https://www.w3.org/TR/xmlschema-2/#dateTime // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx - identity.AddClaim(new Claim("expires_at", expiresAt.ToString("o", CultureInfo.InvariantCulture), - ClaimValueTypes.DateTime, Options.ClaimsIssuer)); + var expiresAt = Options.SystemClock.UtcNow + TimeSpan.FromSeconds(value); + authTokens.Add(new AuthenticationToken + { + Name = "expires_at", + Value = expiresAt.ToString("o", CultureInfo.InvariantCulture) + }); } } + + properties.StoreTokens(authTokens); } return AuthenticateResult.Success(await CreateTicketAsync(identity, properties, tokens)); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 4dc4a32b85..3c7f044386 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -105,9 +105,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect message.PostLogoutRedirectUri = logoutRedirectUri; } - var principal = await Context.Authentication.AuthenticateAsync(Options.SignInScheme); - message.IdTokenHint = principal?.FindFirst(OpenIdConnectParameterNames.IdToken)?.Value; - + message.IdTokenHint = await Context.Authentication.GetTokenAsync(OpenIdConnectParameterNames.IdToken); var redirectContext = new RedirectContext(Context, Options, properties) { ProtocolMessage = message @@ -513,9 +511,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect tokenEndpointResponse = authenticationValidatedContext.TokenEndpointResponse; ticket = authenticationValidatedContext.Ticket; - if (Options.SaveTokensAsClaims) + if (Options.SaveTokens) { - SaveTokens(ticket.Principal, tokenEndpointResponse ?? authorizationResponse, jwt.Issuer); + SaveTokens(ticket.Properties, tokenEndpointResponse ?? authorizationResponse); } if (Options.GetClaimsFromUserInfoEndpoint) @@ -693,32 +691,28 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect ///
/// The principal in which tokens are saved. /// The OpenID Connect response. - private void SaveTokens(ClaimsPrincipal principal, OpenIdConnectMessage message, string issuer) + private void SaveTokens(AuthenticationProperties properties, OpenIdConnectMessage message) { - var identity = (ClaimsIdentity)principal.Identity; + var tokens = new List(); if (!string.IsNullOrEmpty(message.AccessToken)) { - identity.AddClaim(new Claim(OpenIdConnectParameterNames.AccessToken, message.AccessToken, - ClaimValueTypes.String, issuer)); + tokens.Add(new AuthenticationToken { Name = OpenIdConnectParameterNames.AccessToken, Value = message.AccessToken }); } if (!string.IsNullOrEmpty(message.IdToken)) { - identity.AddClaim(new Claim(OpenIdConnectParameterNames.IdToken, message.IdToken, - ClaimValueTypes.String, issuer)); + tokens.Add(new AuthenticationToken { Name = OpenIdConnectParameterNames.IdToken, Value = message.IdToken }); } if (!string.IsNullOrEmpty(message.RefreshToken)) { - identity.AddClaim(new Claim(OpenIdConnectParameterNames.RefreshToken, message.RefreshToken, - ClaimValueTypes.String, issuer)); + tokens.Add(new AuthenticationToken { Name = OpenIdConnectParameterNames.RefreshToken, Value = message.RefreshToken }); } if (!string.IsNullOrEmpty(message.TokenType)) { - identity.AddClaim(new Claim(OpenIdConnectParameterNames.TokenType, message.TokenType, - ClaimValueTypes.String, issuer)); + tokens.Add(new AuthenticationToken { Name = OpenIdConnectParameterNames.TokenType, Value = message.TokenType }); } if (!string.IsNullOrEmpty(message.ExpiresIn)) @@ -729,8 +723,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var expiresAt = Options.SystemClock.UtcNow + TimeSpan.FromSeconds(value); // https://www.w3.org/TR/xmlschema-2/#dateTime // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx - identity.AddClaim(new Claim("expires_at", expiresAt.ToString("o", CultureInfo.InvariantCulture), - ClaimValueTypes.DateTime, issuer)); + tokens.Add(new AuthenticationToken { Name = "expires_at", Value = expiresAt.ToString("o", CultureInfo.InvariantCulture) }); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index c39cce1210..d856a9b845 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -88,10 +88,12 @@ namespace Microsoft.AspNetCore.Authentication.Twitter }, Options.ClaimsIssuer); - if (Options.SaveTokensAsClaims) + if (Options.SaveTokens) { - identity.AddClaim(new Claim("access_token", accessToken.Token, ClaimValueTypes.String, Options.ClaimsIssuer)); - identity.AddClaim(new Claim("access_token_secret", accessToken.TokenSecret, ClaimValueTypes.String, Options.ClaimsIssuer)); + properties.StoreTokens(new [] { + new AuthenticationToken { Name = "access_token", Value = accessToken.Token }, + new AuthenticationToken { Name = "access_token_secret", Value = accessToken.TokenSecret } + }); } return AuthenticateResult.Success(await CreateTicketAsync(identity, properties, accessToken)); diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationToken.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationToken.cs new file mode 100644 index 0000000000..6503f0bb85 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationToken.cs @@ -0,0 +1,12 @@ +// 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.AspNetCore.Authentication +{ + public class AuthenticationToken + { + public string Name { get; set; } + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 43e011c40e..d925be8ec4 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -51,19 +51,19 @@ namespace Microsoft.AspNetCore.Builder set { Description.DisplayName = value; } } - /// - /// Defines whether access and refresh tokens should be stored in the - /// after a successful authorization with the remote provider. - /// This property is set to false by default to reduce - /// the size of the final authentication cookie. - /// - public bool SaveTokensAsClaims { get; set; } - /// /// Gets or sets the time limit for completing the authentication flow (15 minutes by default). /// public TimeSpan RemoteAuthenticationTimeout { get; set; } = TimeSpan.FromMinutes(15); public IRemoteAuthenticationEvents Events = new RemoteAuthenticationEvents(); + + /// + /// Defines whether access and refresh tokens should be stored in the + /// after a successful authorization. + /// This property is set to false by default to reduce + /// the size of the final authentication cookie. + /// + public bool SaveTokens { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs b/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs new file mode 100644 index 0000000000..8065139baf --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs @@ -0,0 +1,115 @@ +// 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.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; + +namespace Microsoft.AspNetCore.Authentication +{ + public static class AuthenticationTokenExtensions + { + private static string TokenNamesKey = ".TokenNames"; + private static string TokenKeyPrefix = ".Token."; + + public static void StoreTokens(this AuthenticationProperties properties, IEnumerable tokens) + { + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + if (tokens == null) + { + throw new ArgumentNullException(nameof(tokens)); + } + + // Clear old tokens first + var oldTokens = properties.GetTokens(); + foreach (var t in oldTokens) + { + properties.Items.Remove(TokenKeyPrefix + t.Name); + } + properties.Items.Remove(TokenNamesKey); + + var tokenNames = new List(); + foreach (var token in tokens) + { + // REVIEW: should probably check that there are no ; in the token name and throw or encode + tokenNames.Add(token.Name); + properties.Items[TokenKeyPrefix+token.Name] = token.Value; + } + if (tokenNames.Count > 0) + { + properties.Items[TokenNamesKey] = string.Join(";", tokenNames.ToArray()); + } + } + + public static string GetTokenValue(this AuthenticationProperties properties, string tokenName) + { + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + if (tokenName == null) + { + throw new ArgumentNullException(nameof(tokenName)); + } + + var tokenKey = TokenKeyPrefix + tokenName; + return properties.Items.ContainsKey(tokenKey) + ? properties.Items[tokenKey] + : null; + } + + public static IEnumerable GetTokens(this AuthenticationProperties properties) + { + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + + var tokens = new List(); + if (properties.Items.ContainsKey(TokenNamesKey)) + { + var tokenNames = properties.Items[TokenNamesKey].Split(';'); + foreach (var name in tokenNames) + { + var token = properties.GetTokenValue(name); + if (token != null) + { + tokens.Add(new AuthenticationToken { Name = name, Value = token }); + } + } + } + + return tokens; + } + + public static Task GetTokenAsync(this AuthenticationManager manager, string tokenName) + { + return manager.GetTokenAsync(AuthenticationManager.AutomaticScheme, tokenName); + } + + public static async Task GetTokenAsync(this AuthenticationManager manager, string signInScheme, string tokenName) + { + if (manager == null) + { + throw new ArgumentNullException(nameof(manager)); + } + if (signInScheme == null) + { + throw new ArgumentNullException(nameof(signInScheme)); + } + if (tokenName == null) + { + throw new ArgumentNullException(nameof(tokenName)); + } + + var authContext = new AuthenticateContext(signInScheme); + await manager.AuthenticateAsync(authContext); + return new AuthenticationProperties(authContext.Properties).GetTokenValue(tokenName); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 6a07808127..6a3442e826 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -292,6 +292,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { ClientId = "Test Id", ClientSecret = "Test Secret", + SaveTokens = true, StateDataFormat = stateFormat, ClaimsIssuer = claimsIssuer, BackchannelHttpHandler = new TestHttpMessageHandler @@ -334,6 +335,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } } }); + var properties = new AuthenticationProperties(); var correlationKey = ".xsrf"; var correlationValue = "TestCorrelationId"; @@ -361,6 +363,12 @@ namespace Microsoft.AspNetCore.Authentication.Google // Ensure claims transformation Assert.Equal("yup", transaction.FindClaimValue("xform")); + + transaction = await server.SendAsync("https://example.com/tokens", authCookie); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + Assert.Equal("Test Access Token", transaction.FindTokenValue("access_token")); + Assert.Equal("Bearer", transaction.FindTokenValue("token_type")); + Assert.NotNull(transaction.FindTokenValue("expires_at")); } // REVIEW: Fix this once we revisit error handling to not blow up @@ -781,6 +789,13 @@ namespace Microsoft.AspNetCore.Authentication.Google { await context.Authentication.ChallengeAsync("Google"); } + else if (req.Path == new PathString("/tokens")) + { + var authContext = new AuthenticateContext(TestExtensions.CookieAuthenticationScheme); + await context.Authentication.AuthenticateAsync(authContext); + var tokens = AuthenticationToken.GetTokens(new AuthenticationProperties(authContext.Properties)); + res.Describe(tokens); + } else if (req.Path == new PathString("/me")) { res.Describe(context.User); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs b/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs index 2e9001dd8c..87d6d95a2c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.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.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; @@ -63,5 +64,23 @@ namespace Microsoft.AspNetCore.Authentication var xmlBytes = Encoding.UTF8.GetBytes(xml.ToString()); res.Body.Write(xmlBytes, 0, xmlBytes.Length); } + + public static void Describe(this HttpResponse res, IEnumerable tokens) + { + res.StatusCode = 200; + res.ContentType = "text/xml"; + var xml = new XElement("xml"); + if (tokens != null) + { + foreach (var token in tokens) + { + xml.Add(new XElement("token", new XAttribute("name", token.Name), + new XAttribute("value", token.Value))); + } + } + var xmlBytes = Encoding.UTF8.GetBytes(xml.ToString()); + res.Body.Write(xmlBytes, 0, xmlBytes.Length); + } + } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs new file mode 100644 index 0000000000..ef030d1154 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -0,0 +1,144 @@ +// 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.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication.Internal; +using Microsoft.AspNetCore.Http.Internal; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication +{ + public class TokenExtensionTests + { + [Fact] + public void CanStoreMultipleTokens() + { + var props = new AuthenticationProperties(); + var tokens = new List(); + var tok1 = new AuthenticationToken { Name = "One", Value = "1" }; + var tok2 = new AuthenticationToken { Name = "Two", Value = "2" }; + var tok3 = new AuthenticationToken { Name = "Three", Value = "3" }; + tokens.Add(tok1); + tokens.Add(tok2); + tokens.Add(tok3); + props.StoreTokens(tokens); + + Assert.Equal("1", props.GetTokenValue("One")); + Assert.Equal("2", props.GetTokenValue("Two")); + Assert.Equal("3", props.GetTokenValue("Three")); + Assert.Equal(3, props.GetTokens().Count()); + } + + [Fact] + public void SubsequentStoreTokenDeletesPreviousTokens() + { + var props = new AuthenticationProperties(); + var tokens = new List(); + var tok1 = new AuthenticationToken { Name = "One", Value = "1" }; + var tok2 = new AuthenticationToken { Name = "Two", Value = "2" }; + var tok3 = new AuthenticationToken { Name = "Three", Value = "3" }; + tokens.Add(tok1); + tokens.Add(tok2); + tokens.Add(tok3); + + props.StoreTokens(tokens); + + props.StoreTokens(new[] { new AuthenticationToken { Name = "Zero", Value = "0" } }); + + Assert.Equal("0", props.GetTokenValue("Zero")); + Assert.Equal(null, props.GetTokenValue("One")); + Assert.Equal(null, props.GetTokenValue("Two")); + Assert.Equal(null, props.GetTokenValue("Three")); + Assert.Equal(1, props.GetTokens().Count()); + } + + [Fact] + public void CanUpdateTokens() + { + var props = new AuthenticationProperties(); + var tokens = new List(); + var tok1 = new AuthenticationToken { Name = "One", Value = "1" }; + var tok2 = new AuthenticationToken { Name = "Two", Value = "2" }; + var tok3 = new AuthenticationToken { Name = "Three", Value = "3" }; + tokens.Add(tok1); + tokens.Add(tok2); + tokens.Add(tok3); + props.StoreTokens(tokens); + + tok1.Value = ".1"; + tok2.Value = ".2"; + tok3.Value = ".3"; + props.StoreTokens(tokens); + + Assert.Equal(".1", props.GetTokenValue("One")); + Assert.Equal(".2", props.GetTokenValue("Two")); + Assert.Equal(".3", props.GetTokenValue("Three")); + Assert.Equal(3, props.GetTokens().Count()); + } + + public class TestAuthHandler : IAuthenticationHandler + { + private readonly AuthenticationProperties _props; + public TestAuthHandler(AuthenticationProperties props) + { + _props = props; + } + + public Task AuthenticateAsync(AuthenticateContext context) + { + context.Authenticated(new ClaimsPrincipal(), _props.Items, new Dictionary()); + return Task.FromResult(0); + } + + public Task ChallengeAsync(ChallengeContext context) + { + throw new NotImplementedException(); + } + + public void GetDescriptions(DescribeSchemesContext context) + { + throw new NotImplementedException(); + } + + public Task SignInAsync(SignInContext context) + { + throw new NotImplementedException(); + } + + public Task SignOutAsync(SignOutContext context) + { + throw new NotImplementedException(); + } + } + + [Fact] + public async Task CanGetTokenFromContext() + { + var props = new AuthenticationProperties(); + var tokens = new List(); + var tok1 = new AuthenticationToken { Name = "One", Value = "1" }; + var tok2 = new AuthenticationToken { Name = "Two", Value = "2" }; + var tok3 = new AuthenticationToken { Name = "Three", Value = "3" }; + tokens.Add(tok1); + tokens.Add(tok2); + tokens.Add(tok3); + props.StoreTokens(tokens); + + var context = new DefaultHttpContext(); + var handler = new TestAuthHandler(props); + context.Features.Set(new HttpAuthenticationFeature() { Handler = handler }); + + Assert.Equal("1", await context.Authentication.GetTokenAsync("One")); + Assert.Equal("2", await context.Authentication.GetTokenAsync("Two")); + Assert.Equal("3", await context.Authentication.GetTokenAsync("Three")); + } + + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs index 63f8af1bb2..f7128a6f11 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs @@ -46,5 +46,17 @@ namespace Microsoft.AspNetCore.Authentication } return claim.Attribute("value").Value; } + + public string FindTokenValue(string name) + { + var claim = ResponseElement.Elements("token") + .SingleOrDefault(elt => elt.Attribute("name").Value == name); + if (claim == null) + { + return null; + } + return claim.Attribute("value").Value; + } + } } From 0ab5cdc6ad38666bd142c6834f36997717c6a547 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 3 Mar 2016 14:01:24 -0800 Subject: [PATCH 481/900] Fix bad rebase --- samples/SocialSample/Startup.cs | 8 ++++---- .../Google/GoogleMiddlewareTests.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 4ab304c32e..ed3f09a14a 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -322,10 +322,10 @@ namespace CookieSample await context.Response.WriteAsync("Tokens:
"); - await context.Response.WriteAsync("Access Token: " + await AuthenticationToken.GetTokenAsync(context, CookieAuthenticationDefaults.AuthenticationScheme, "access_token") + "
"); - await context.Response.WriteAsync("Refresh Token: " + await AuthenticationToken.GetTokenAsync(context, CookieAuthenticationDefaults.AuthenticationScheme, "refresh_token") + "
"); - await context.Response.WriteAsync("Token Type: " + await AuthenticationToken.GetTokenAsync(context, CookieAuthenticationDefaults.AuthenticationScheme, "token_type") + "
"); - await context.Response.WriteAsync("expires_at: " + await AuthenticationToken.GetTokenAsync(context, CookieAuthenticationDefaults.AuthenticationScheme, "expires_at") + "
"); + await context.Response.WriteAsync("Access Token: " + await context.Authentication.GetTokenAsync("access_token") + "
"); + await context.Response.WriteAsync("Refresh Token: " + await context.Authentication.GetTokenAsync("refresh_token") + "
"); + await context.Response.WriteAsync("Token Type: " + await context.Authentication.GetTokenAsync("token_type") + "
"); + await context.Response.WriteAsync("expires_at: " + await context.Authentication.GetTokenAsync("expires_at") + "
"); await context.Response.WriteAsync("Logout"); await context.Response.WriteAsync(""); }); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 6a3442e826..96bb574fb3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -793,7 +793,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { var authContext = new AuthenticateContext(TestExtensions.CookieAuthenticationScheme); await context.Authentication.AuthenticateAsync(authContext); - var tokens = AuthenticationToken.GetTokens(new AuthenticationProperties(authContext.Properties)); + var tokens = new AuthenticationProperties(authContext.Properties).GetTokens(); res.Describe(tokens); } else if (req.Path == new PathString("/me")) From 94e0088eea883c3dc9a268f1c3939dfe958f8870 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 3 Mar 2016 17:33:22 -0800 Subject: [PATCH 482/900] Added Company, Copyright and Product attributes to AssemblyInfo --- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 4 +++- 12 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Google/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs index b2437d9ad6..76feceeff0 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs @@ -5,4 +5,7 @@ using System.Reflection; using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs index c0526726a4..1fe857fd92 100644 --- a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs +++ b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// 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. using System.Reflection; @@ -10,3 +10,5 @@ using System.Runtime.InteropServices; // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("a7922dd8-09f1-43e4-938b-cc523ea08898")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] From 909c34271113d3db7ce2bb742f76fd742c3f1913 Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 4 Mar 2016 09:44:19 -0800 Subject: [PATCH 483/900] Small sample updates. --- samples/SocialSample/Startup.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index ed3f09a14a..108ad6ff86 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -72,13 +72,14 @@ namespace CookieSample // You must first create an app with facebook and add it's ID and Secret to your config.json or user-secrets. // https://developers.facebook.com/apps/ - //app.UseFacebookAuthentication(new FacebookOptions - //{ - // AppId = Configuration["facebook:appid"], - // AppSecret = Configuration["facebook:appsecret"], - // Scope = { "email" }, - // Fields = { "name", "email" } - //}); + app.UseFacebookAuthentication(new FacebookOptions + { + AppId = Configuration["facebook:appid"], + AppSecret = Configuration["facebook:appsecret"], + Scope = { "email" }, + Fields = { "name", "email" }, + SaveTokens = true, + }); // See config.json app.UseOAuthAuthentication(new OAuthOptions @@ -100,6 +101,7 @@ namespace CookieSample { ClientId = Configuration["google:clientid"], ClientSecret = Configuration["google:clientsecret"], + SaveTokens = true, Events = new OAuthEvents() { OnRemoteFailure = ctx => @@ -118,6 +120,7 @@ namespace CookieSample { ConsumerKey = Configuration["twitter:consumerkey"], ConsumerSecret = Configuration["twitter:consumersecret"], + SaveTokens = true, Events = new TwitterEvents() { OnRemoteFailure = ctx => @@ -195,6 +198,7 @@ namespace CookieSample TokenEndpoint = "https://github.com/login/oauth/access_token", UserInformationEndpoint = "https://api.github.com/user", ClaimsIssuer = "OAuth2-Github", + SaveTokens = true, // Retrieving user information is unique to each provider. Events = new OAuthEvents { From 8645ca0dc505d559cf4ef7649e6c548fc0db06b4 Mon Sep 17 00:00:00 2001 From: Osman M Elsayed Date: Sat, 30 Jan 2016 02:38:55 +0300 Subject: [PATCH 484/900] Update MicrosoftAccount to use converged auth -Updated MicrosoftAccountDefaults to use app model v2 & graph API -Updated MicrosoftAccountHelper to extract user info from the user object returned by the graph API -Updated MicrosoftAccountMiddlewareTests accordingly -Added the app model v2 client credentials to SocialSample/config.json -Configured SocialSample to use SSL Startup.cs - Sorted namespaces - Dropped openid scope from Microsoft-AccessToken project.json - Sorted dependencies MicrosoftAccountHelper.cs - Removed name claim transofmation - renamed GetName, GetFirstName & GetLastName --- .../Properties/launchSettings.json | 8 +- samples/SocialSample/Startup.cs | 100 +++++++++++------- .../SocialSample/compiler/resources/cert.pfx | Bin 0 -> 2483 bytes samples/SocialSample/config.json | 4 +- samples/SocialSample/project.json | 11 +- .../MicrosoftAccountDefaults.cs | 6 +- .../MicrosoftAccountHandler.cs | 16 ++- .../MicrosoftAccountHelper.cs | 21 ++-- .../MicrosoftAccountOptions.cs | 2 +- .../MicrosoftAccountMiddlewareTests.cs | 17 ++- 10 files changed, 114 insertions(+), 71 deletions(-) create mode 100644 samples/SocialSample/compiler/resources/cert.pfx diff --git a/samples/SocialSample/Properties/launchSettings.json b/samples/SocialSample/Properties/launchSettings.json index 15c91efdcb..e9d26ad03e 100644 --- a/samples/SocialSample/Properties/launchSettings.json +++ b/samples/SocialSample/Properties/launchSettings.json @@ -4,13 +4,14 @@ "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:54540", - "sslPort": 0 + "sslPort": 44318 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, + "launchUrl": "https://localhost:44318/", "environmentVariables": { "ASPNET_ENV": "Development" } @@ -18,10 +19,9 @@ "web": { "commandName": "web", "launchBrowser": true, - "launchUrl": "http://localhost:54540/", + "launchUrl": "https://localhost:54541/", "environmentVariables": { - "Hosting:Environment": "Development", - "ASPNET_server.urls": "http://localhost:54540/" + "Hosting:Environment": "Development" } } } diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 108ad6ff86..358a031cd3 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -1,8 +1,11 @@ using System; +using System.IO; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; +using System.Reflection; using System.Security.Claims; +using System.Security.Cryptography.X509Certificates; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; @@ -15,12 +18,15 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.HttpOverrides; +using Microsoft.AspNetCore.Server.Kestrel.Filter; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; -namespace CookieSample +namespace SocialSample { /* Note all servers must use the same address and port because these are pre-registered with the various providers. */ public class Startup @@ -45,6 +51,10 @@ namespace CookieSample { loggerfactory.AddConsole(LogLevel.Information); + //Configure SSL + var serverCertificate = LoadCertificate(); + app.UseKestrelHttps(serverCertificate); + // Simple error page to avoid a repo dependency. app.Use(async (context, next) => { @@ -63,6 +73,12 @@ namespace CookieSample } }); + // Forward the scheme from IISPlatformHandler + app.UseForwardedHeaders(new ForwardedHeadersOptions() + { + ForwardedHeaders = ForwardedHeaders.XForwardedProto, + }); + app.UseCookieAuthentication(new CookieAuthenticationOptions { AutomaticAuthenticate = true, @@ -105,7 +121,6 @@ namespace CookieSample Events = new OAuthEvents() { OnRemoteFailure = ctx => - { ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); ctx.HandleResponse(); @@ -132,45 +147,34 @@ namespace CookieSample } }); - // You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. - /* https://account.live.com/developers/applications - The MicrosoftAccount service has restrictions that prevent the use of http://localhost:54540/ for test applications. - As such, here is how to change this sample to uses http://mssecsample.localhost.this:54540/ instead. - - Edit the hosting.json file and add "server.urls": "http://mssecsample.localhost.this:54540/". - - From an admin command console first enter: - notepad C:\Windows\System32\drivers\etc\hosts - and add this to the file, save, and exit (and reboot?): - 127.0.0.1 MsSecSample.localhost.this - - [WebListener] Then you can choose to run the app as admin (see below) or add the following ACL as admin: - netsh http add urlacl url=http://mssecsample.localhost.this:54540/ user=[domain\user] - - The sample app can then be run via: - dnx web + /* Azure AD app model v2 has restrictions that prevent the use of plain HTTP for redirect URLs. + Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL: + https://localhost:54541/ */ - //app.UseOAuthAuthentication(new OAuthOptions - //{ - // AuthenticationScheme = "Microsoft-AccessToken", - // DisplayName = "MicrosoftAccount-AccessToken - Requires project changes", - // ClientId = Configuration["msa:clientid"], - // ClientSecret = Configuration["msa:clientsecret"], - // CallbackPath = new PathString("/signin-microsoft-token"), - // AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint, - // TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint, - // Scope = { "wl.basic" }, - // SaveTokens = true - //}); + // See config.json + // https://apps.dev.microsoft.com/ + app.UseOAuthAuthentication(new OAuthOptions + { + AuthenticationScheme = "Microsoft-AccessToken", + DisplayName = "MicrosoftAccount-AccessToken", + ClientId = Configuration["msa:clientid"], + ClientSecret = Configuration["msa:clientsecret"], + CallbackPath = new PathString("/signin-microsoft-token"), + AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint, + TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint, + Scope = { "https://graph.microsoft.com/user.read" }, + SaveTokens = true + }); - ////// You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. - //app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions - //{ - // DisplayName = "MicrosoftAccount - Requires project changes", - // ClientId = Configuration["msa:clientid"], - // ClientSecret = Configuration["msa:clientsecret"], - // Scope = { "wl.emails" } - //}); + // See config.json + // https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/ + app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions + { + DisplayName = "MicrosoftAccount", + ClientId = Configuration["msa:clientid"], + ClientSecret = Configuration["msa:clientsecret"], + SaveTokens = true + }); // See config.json // https://github.com/settings/applications/ @@ -346,5 +350,23 @@ namespace CookieSample host.Run(); } + + private X509Certificate2 LoadCertificate() + { + var socialSampleAssembly = GetType().GetTypeInfo().Assembly; + var embeddedFileProvider = new EmbeddedFileProvider(socialSampleAssembly, "SocialSample"); + var certificateFileInfo = embeddedFileProvider.GetFileInfo("compiler/resources/cert.pfx"); + using (var certificateStream = certificateFileInfo.CreateReadStream()) + { + byte[] certificatePayload; + using (var memoryStream = new MemoryStream()) + { + certificateStream.CopyTo(memoryStream); + certificatePayload = memoryStream.ToArray(); + } + + return new X509Certificate2(certificatePayload, "testPassword"); + } + } } } diff --git a/samples/SocialSample/compiler/resources/cert.pfx b/samples/SocialSample/compiler/resources/cert.pfx new file mode 100644 index 0000000000000000000000000000000000000000..7118908c2d730670c16e9f8b2c532a262c951989 GIT binary patch literal 2483 zcmaKuc|27A8pqF>IWr86E&Q@(n=B)p$ug!;QVB6xij*z;uPLG!yCz#DQB)+9G$9m9 zQU)=DWXU?*EZIwG!+0d++P@yZ4Xhoagg?p6B~|Ue7tN=Ny=UD?x#1n1MTq z#c9MHh+D#gd|(a(cN}8i91v^=GcdgW3SmA$49p~gM-dys3jVWdg8+!iVL)pz1LDE5 zSb=|GAn(@R=(Ux!MfS9@}sFu-xDd zIt2+mqSq$glwy_6UNs<2?(qERU!gJ;5j}Pp&6trxG=wi)=@k(w2+fJVnc+qvXVzy(>Om4;L|^)R`t*3nTpAmEmTl(#i!RV#a0t#u6>Q9mY`-Nmcs7$XjXT7 zUmCD`O~_j7!%R#I?cG-7C^hcH)@l?WC1vyw$FFu_(r)jhOq6p}W8sG7NO{YTy8tG4 zrb$tTkag*G?(7lfoGx$4YWui>{{@}-FB2ub=}RX{1zx?j)s-##J9|G7E1@-;7Nuln z9MQoX7FJ76+D#XXT@ZZmLZCufIdf3@OigG6m8I7!GT=7VD|>?6e!z9=eT}*E_tSn6 zl+clHCZ-kcIR#gen#LjMJW8>0QtViaQB#FhqsCb0YPYr3;jRITl@V9Aph24D?r2d` zetCyyCg<*O-u+M& zW^ptmT|}p$VAOZpmbQ1{5fK-6ytEvre#Po}6c2URn`viQAF2+e?Z~PK2&pd>7=7)I zTCYm)@3PFRu_6a6Kb)IpCzQ%e3l%O#SDA+$Pq{Dk{HCqi7z>qd{nVpebffL7h{c4( zmhXn~G+C27S3(IfC)q2KON=YwqHXEo%zc40DgWLzF{%RIdr@RcLu90qMSHf!Y}JaqP<={8_Rfe;ddR5= zKEo;^Yip&^m((#{czE{kUga3-@`*;&EwO}Jt>QdURP2P>ob^j-A!qld-0S_pm)kjs zkNo48oZnMt){W~o8g^f;4#?lRLr-T@f}wH1o~-Iq=NEVtTVEZ`vrW~!>2yh%;Bc~H zHl&OK>n@d`*e19*9#v>zZpU?I);f7}IPIfSSk#N|ujE492Itg)l!)TJ19@FE^x|p= zH16NC7OfK&|6_!AnWfTIf^YPOa&`|nbk3VR0vql6&s@y1V3QOU%(`Re+kJgrz?r9!{^wOQ4W-eng23gc}f(LxIs zH_Ls~5izbjcRQH#WH6s6hR;zn>j_R8aJ$A)6xNneu8UI-vWV8Z@HZu&WwvG5q{1ZS zdZeVf{Pv5-u281~y;aJe*x%Uv0@biMZ$vPbKj}O`(SOWQc~kJX` zXR&d4DtAe@2RH$^ z0os5*;0eIUeJi3Uh`A%44x(XzjClG8BO~-r_A}odiRuHo2-86#`mhrgN5p~<$RLY? zq(kynfFA5{v#p+EA1 z5aoe1763EQHorRm`C&ktKn(OQ1n)$Q{GZz&jRb`eDEMpl<0O#+)DMV(T7nsIzCG{QuM->B9g7Lrl2SE&gW`M!~(un|y0fIn=b^6_$ z9{zEzgYI~39xn0ZP*9qBL%fg7rg$ttt&TOmvfNNO<6FT0ZavM$Y4CYLQGIcIYv9Y& zBGPUh&QTfW;V2!)oIra@s&d968y-y}Y|ww(R$GzWS*V&)k@W0>Slem{|HdTCjm;_5 zwY*A8W3nUbemE^_f0ng$tbd<`sr?TO-_&VCw+F#7P@LkIl$1PzTBoPY1b88EIO>UO zP-NK7+g2yD3U6g3i|iA6+su>54sf_Sk0F=)1|9odnCM4u2Rs z=&Y?-V&VquSN%3FJ2~ZGweP~iLs|w=l@9yu$tj@}Dp?e-2JUsqOoswdXb=E%&0te_ zA2M+{5Hf-dqD7=yw*r@A*xkn(1IS~nfP}k}e?4Bt|9g(eph4hFX_|S6nj1&Sz9z^= zRw~<&-9d@FzTn6S*RVE{Wj5lgLJr9HLB8S9CgOm*>XA8*y4`JE;^s$=bqD#U4;e5C&x&ggKIAVL zrQ)Yd8|{>7Z(6*B&7&4&9(*vDOfHMuR-Dk1IZia*XM^EZUD^{?cWG>J>KrtElc*{K zaVl(7SN2cH4I6Q$bZOpJ8e5LKaG7p;?tJ~#+9QrTYU@f#5`Vo7cEX!szCT}iX-K^2 w#3o+=C+lQz2J+SOEzVX(eJ)e7=eicC{rr9U2VGDcdH?_b literal 0 HcmV?d00001 diff --git a/samples/SocialSample/config.json b/samples/SocialSample/config.json index 13d3ff94a0..5c1453e39f 100644 --- a/samples/SocialSample/config.json +++ b/samples/SocialSample/config.json @@ -6,5 +6,7 @@ "github:clientid": "49e302895d8b09ea5656", "github:clientsecret": "98f1bf028608901e9df91d64ee61536fe562064b", "github-token:clientid": "8c0c5a572abe8fe89588", - "github-token:clientsecret": "e1d95eaf03461d27acd6f49d4fc7bf19d6ac8cda" + "github-token:clientsecret": "e1d95eaf03461d27acd6f49d4fc7bf19d6ac8cda", + "msa:clientid": "e2105565-1f56-434a-ae61-9849ebaf606c", + "msa:clientsecret": "pjqtt3RXrFwcfSJyQ0BeUez" } diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index a4c71e0b70..1d02230294 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -6,9 +6,12 @@ "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-*", "Microsoft.AspNetCore.DataProtection": "1.0.0-*", + "Microsoft.AspNetCore.HttpOverrides": "1.0.0-*", "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", + "Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*" }, @@ -26,5 +29,9 @@ ] } }, - "userSecretsId": "aspnet5-SocialSample-20151210111056" -} \ No newline at end of file + "userSecretsId": "aspnet5-SocialSample-20151210111056", + "content": [ + "config.json", + "project.json" + ] +} diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs index d853794779..0d272f9792 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs @@ -7,10 +7,10 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { public const string AuthenticationScheme = "Microsoft"; - public static readonly string AuthorizationEndpoint = "https://login.live.com/oauth20_authorize.srf"; + public static readonly string AuthorizationEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"; - public static readonly string TokenEndpoint = "https://login.live.com/oauth20_token.srf"; + public static readonly string TokenEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/token"; - public static readonly string UserInformationEndpoint = "https://apis.live.net/v5.0/me"; + public static readonly string UserInformationEndpoint = "https://graph.microsoft.com/v1.0/me"; } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 245fbed87d..8b9177625c 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -38,13 +38,27 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount identity.AddClaim(new Claim("urn:microsoftaccount:id", identifier, ClaimValueTypes.String, Options.ClaimsIssuer)); } - var name = MicrosoftAccountHelper.GetName(payload); + var name = MicrosoftAccountHelper.GetDisplayName(payload); if (!string.IsNullOrEmpty(name)) { identity.AddClaim(new Claim(ClaimTypes.Name, name, ClaimValueTypes.String, Options.ClaimsIssuer)); identity.AddClaim(new Claim("urn:microsoftaccount:name", name, ClaimValueTypes.String, Options.ClaimsIssuer)); } + var givenName = MicrosoftAccountHelper.GetGivenName(payload); + if (!string.IsNullOrEmpty(givenName)) + { + identity.AddClaim(new Claim(ClaimTypes.GivenName, givenName, ClaimValueTypes.String, Options.ClaimsIssuer)); + identity.AddClaim(new Claim("urn:microsoftaccount:givenname", givenName, ClaimValueTypes.String, Options.ClaimsIssuer)); + } + + var surname = MicrosoftAccountHelper.GetSurname(payload); + if (!string.IsNullOrEmpty(surname)) + { + identity.AddClaim(new Claim(ClaimTypes.Surname, surname, ClaimValueTypes.String, Options.ClaimsIssuer)); + identity.AddClaim(new Claim("urn:microsoftaccount:surname", surname, ClaimValueTypes.String, Options.ClaimsIssuer)); + } + var email = MicrosoftAccountHelper.GetEmail(payload); if (!string.IsNullOrEmpty(email)) { diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs index 8b88cbc44c..cce8dcc73b 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs @@ -8,7 +8,8 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { /// /// Contains static methods that allow to extract user's information from a - /// instance retrieved from Google after a successful authentication process. + /// instance retrieved from Microsoft after a successful authentication process. + /// http://graph.microsoft.io/en-us/docs/api-reference/v1.0/resources/user /// public static class MicrosoftAccountHelper { @@ -28,40 +29,40 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount /// /// Gets the user's name. /// - public static string GetName(JObject user) + public static string GetDisplayName(JObject user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } - return user.Value("name"); + return user.Value("displayName"); } /// - /// Gets the user's first name. + /// Gets the user's given name. /// - public static string GetFirstName(JObject user) + public static string GetGivenName(JObject user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } - return user.Value("first_name"); + return user.Value("givenName"); } /// - /// Gets the user's last name. + /// Gets the user's surname. /// - public static string GetLastName(JObject user) + public static string GetSurname(JObject user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } - return user.Value("last_name"); + return user.Value("surname"); } /// @@ -74,7 +75,7 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount throw new ArgumentNullException(nameof(user)); } - return user.Value("emails")?.Value("preferred"); + return user.Value("mail") ?? user.Value("userPrincipalName"); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs index 2783bcef1f..625d4baf9c 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Builder AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint; TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; UserInformationEndpoint = MicrosoftAccountDefaults.UserInformationEndpoint; - Scope.Add("wl.basic"); + Scope.Add("https://graph.microsoft.com/user.read"); } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index f5a43b8ed2..0ddfb5a3c7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount var transaction = await server.SendAsync("http://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://login.live.com/oauth20_authorize.srf", location); + Assert.Contains("https://login.microsoftonline.com/common/oauth2/v2.0/authorize", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=", location); @@ -113,7 +113,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { Sender = req => { - if (req.RequestUri.AbsoluteUri == "https://login.live.com/oauth20_token.srf") + if (req.RequestUri.AbsoluteUri == "https://login.microsoftonline.com/common/oauth2/v2.0/token") { return ReturnJsonResponse(new { @@ -123,18 +123,15 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount refresh_token = "Test Refresh Token" }); } - else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://apis.live.net/v5.0/me") + else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://graph.microsoft.com/v1.0/me") { return ReturnJsonResponse(new { id = "Test User ID", - name = "Test Name", - first_name = "Test Given Name", - last_name = "Test Family Name", - emails = new - { - preferred = "Test email" - } + displayName = "Test Name", + givenName = "Test Given Name", + surname = "Test Family Name", + mail = "Test email" }); } From ef6dd4138400e443aba56c4372270c132d541dd4 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 4 Mar 2016 12:55:32 -0800 Subject: [PATCH 485/900] SaveTokens in OIDC --- .../OpenIdConnectHandler.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 3c7f044386..1e804ef314 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -726,6 +726,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect tokens.Add(new AuthenticationToken { Name = "expires_at", Value = expiresAt.ToString("o", CultureInfo.InvariantCulture) }); } } + + properties.StoreTokens(tokens); } /// From 9dfe4d96996cf65a7013b5b0eb329aab80434199 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Fri, 4 Mar 2016 15:49:20 -0800 Subject: [PATCH 486/900] Enabled xml doc generation --- NuGetPackageVerifier.json | 17 ++++------------- .../Events/CookieRedirectContext.cs | 1 + .../Events/CookieSigningOutContext.cs | 1 + .../Events/CookieValidatePrincipalContext.cs | 2 +- .../project.json | 4 +++- .../FacebookMiddleware.cs | 5 ++--- .../project.json | 4 +++- .../GoogleMiddleware.cs | 5 ++--- .../project.json | 4 +++- .../Events/IJwtBearerEvents.cs | 5 +---- .../Events/JwtBearerEvents.cs | 6 +----- .../JwtBearerOptions.cs | 2 +- .../project.json | 4 +++- .../MicrosoftAccountMiddleware.cs | 5 ++--- .../project.json | 4 +++- .../Events/IOAuthEvents.cs | 4 ++-- .../Events/OAuthEvents.cs | 4 ++-- .../OAuthRedirectToAuthorizationContext.cs | 1 + .../OAuthMiddleware.cs | 8 +++++--- .../OAuthOptions.cs | 2 +- .../project.json | 4 +++- .../OpenIdConnectAppBuilderExtensions.cs | 2 +- .../OpenIdConnectHandler.cs | 12 ++++++------ .../OpenIdConnectMiddleware.cs | 5 +++-- .../project.json | 4 +++- .../Events/ITwitterEvents.cs | 2 +- .../Events/TwitterCreatingTicketContext.cs | 1 + .../Events/TwitterEvents.cs | 2 +- .../TwitterMiddleware.cs | 5 ++--- .../project.json | 4 +++- .../AuthenticationHandler.cs | 1 + .../RemoteAuthenticationOptions.cs | 4 ++-- .../project.json | 4 +++- .../AuthorizationServiceExtensions.cs | 1 + .../project.json | 4 +++- .../project.json | 4 +++- .../Properties/AssemblyInfo.cs | 1 + .../project.json | 10 ++++++---- 38 files changed, 86 insertions(+), 72 deletions(-) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index 4c7cf6982f..9f3414fbc4 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -1,12 +1,7 @@ { "adx": { // Packages written by the ADX team and that ship on NuGet.org "rules": [ - "AssemblyHasDocumentFileRule", - "AssemblyHasVersionAttributesRule", - "AssemblyHasServicingAttributeRule", - "AssemblyHasNeutralResourcesLanguageAttributeRule", - "SatellitePackageRule", - "StrictSemanticVersionValidationRule" + "AdxVerificationCompositeRule" ], "packages": { "Microsoft.AspNetCore.Authentication": { }, @@ -19,17 +14,13 @@ "Microsoft.AspNetCore.Authentication.OpenIdConnect": { }, "Microsoft.AspNetCore.Authentication.Twitter": { }, "Microsoft.AspNetCore.Authorization": { }, - "Microsoft.AspNetCore.CookiePolicy": { } + "Microsoft.AspNetCore.CookiePolicy": { }, + "Microsoft.Owin.Security.Interop": { } } }, "Default": { // Rules to run for packages not listed in any other set. "rules": [ - "AssemblyHasDocumentFileRule", - "AssemblyHasVersionAttributesRule", - "AssemblyHasServicingAttributeRule", - "AssemblyHasNeutralResourcesLanguageAttributeRule", - "SatellitePackageRule", - "StrictSemanticVersionValidationRule" + "DefaultCompositeRule" ] } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs index e946548f49..c26cd5d662 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs @@ -19,6 +19,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// The HTTP request context /// The cookie middleware options /// The initial redirect URI + /// The . [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#", Justification = "Represents header value")] public CookieRedirectContext(HttpContext context, CookieAuthenticationOptions options, string redirectUri, AuthenticationProperties properties) : base(context, options) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs index ab5858e369..51c04a56b9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs @@ -17,6 +17,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// /// + /// /// public CookieSigningOutContext( HttpContext context, diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs index d2c1fd42f6..57a28191c8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs @@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// Called to replace the claims principal. The supplied principal will replace the value of the /// Principal property, which determines the identity of the authenticated request. /// - /// The identity used as the replacement + /// The used as the replacement public void ReplacePrincipal(ClaimsPrincipal principal) { Principal = principal; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index 46666ed124..0029e6a897 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs index 16b60e1dd4..e4a76e0e93 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs @@ -27,7 +27,6 @@ namespace Microsoft.AspNetCore.Authentication.Facebook /// /// /// Configuration options for the middleware. - /// public FacebookMiddleware( RequestDelegate next, IDataProtectionProvider dataProtectionProvider, @@ -79,9 +78,9 @@ namespace Microsoft.AspNetCore.Authentication.Facebook } /// - /// Provides the object for processing authentication-related requests. + /// Provides the object for processing authentication-related requests. /// - /// An configured with the supplied to the constructor. + /// An configured with the supplied to the constructor. protected override AuthenticationHandler CreateHandler() { return new FacebookHandler(Backchannel); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index e93b2feb4d..3cd595a96e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs index f81497f26a..190dc4b25a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs @@ -28,7 +28,6 @@ namespace Microsoft.AspNetCore.Authentication.Google /// /// /// Configuration options for the middleware. - /// public GoogleMiddleware( RequestDelegate next, IDataProtectionProvider dataProtectionProvider, @@ -70,9 +69,9 @@ namespace Microsoft.AspNetCore.Authentication.Google } /// - /// Provides the object for processing authentication-related requests. + /// Provides the object for processing authentication-related requests. /// - /// An configured with the supplied to the constructor. + /// An configured with the supplied to the constructor. protected override AuthenticationHandler CreateHandler() { return new GoogleHandler(Backchannel); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index d250dee275..702d45aefd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs index 4ad6f7c21b..2e023db130 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs @@ -3,13 +3,10 @@ using System.Threading.Tasks; -/// -/// Specifies events which the invokes to enable developer control over the authentication process. /> -/// namespace Microsoft.AspNetCore.Authentication.JwtBearer { /// - /// OpenIdConnect bearer token middleware events. + /// Specifies events which the invokes to enable developer control over the authentication process. /// public interface IJwtBearerEvents { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs index 5fc8a6b6c9..a14f238078 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -3,15 +3,11 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -/// -/// Specifies events which the invokes to enable developer control over the authentication process. /> -/// namespace Microsoft.AspNetCore.Authentication.JwtBearer { /// - /// OpenIdConnect bearer token middleware events. + /// Specifies events which the invokes to enable developer control over the authentication process. /// public class JwtBearerEvents : IJwtBearerEvents { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs index a4b5ef2ae2..c350c38baf 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -113,7 +113,7 @@ namespace Microsoft.AspNetCore.Builder /// /// Defines whether the bearer token should be stored in the - /// after a successful authorization. + /// after a successful authorization. /// public bool SaveToken { get; set; } = true; } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 21be97e4b8..091deca827 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs index e7ba9f8117..fc9866826b 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs @@ -26,7 +26,6 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount /// /// /// Configuration options for the middleware. - /// public MicrosoftAccountMiddleware( RequestDelegate next, IDataProtectionProvider dataProtectionProvider, @@ -68,9 +67,9 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount } /// - /// Provides the object for processing authentication-related requests. + /// Provides the object for processing authentication-related requests. /// - /// An configured with the supplied to the constructor. + /// An configured with the supplied to the constructor. protected override AuthenticationHandler CreateHandler() { return new MicrosoftAccountHandler(Backchannel); diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index 468955a931..e0a2fceb0d 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs index 76a238e07d..29316732cc 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authentication.OAuth { /// - /// Specifies callback methods which the invokes to enable developer control over the authentication process. + /// Specifies callback methods which the invokes to enable developer control over the authentication process. /// public interface IOAuthEvents : IRemoteAuthenticationEvents { @@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// Called when a Challenge causes a redirect to the authorize endpoint. /// - /// Contains redirect URI and of the challenge. + /// Contains redirect URI and of the challenge. Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs index cf1528e280..44c4260516 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -28,14 +28,14 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// Invoked after the provider successfully authenticates a user. /// - /// Contains information about the login session as well as the user . + /// Contains information about the login session as well as the user . /// A representing the completed operation. public virtual Task CreatingTicket(OAuthCreatingTicketContext context) => OnCreatingTicket(context); /// /// Called when a Challenge causes a redirect to authorize endpoint in the OAuth middleware. /// - /// Contains redirect URI and of the challenge. + /// Contains redirect URI and of the challenge. public virtual Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context) => OnRedirectToAuthorizationEndpoint(context); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs index 5dcbd568cb..63eaa35376 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs @@ -16,6 +16,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// Creates a new context object. ///
/// The HTTP request context. + /// The . /// The authentication properties of the challenge. /// The initial redirect URI. public OAuthRedirectToAuthorizationContext(HttpContext context, OAuthOptions options, AuthenticationProperties properties, string redirectUri) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs index 401537e831..1a16d2aa3b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs @@ -21,11 +21,13 @@ namespace Microsoft.AspNetCore.Authentication.OAuth public class OAuthMiddleware : AuthenticationMiddleware where TOptions : OAuthOptions, new() { /// - /// Initializes a new . + /// Initializes a new . /// /// The next middleware in the HTTP pipeline to invoke. /// /// + /// The . + /// The configuration options for this middleware. /// Configuration options for the middleware. public OAuthMiddleware( RequestDelegate next, @@ -127,9 +129,9 @@ namespace Microsoft.AspNetCore.Authentication.OAuth protected HttpClient Backchannel { get; private set; } /// - /// Provides the object for processing authentication-related requests. + /// Provides the object for processing authentication-related requests. /// - /// An configured with the supplied to the constructor. + /// An configured with the supplied to the constructor. protected override AuthenticationHandler CreateHandler() { return new OAuthHandler(Backchannel); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs index 22d5e35573..57ecba2f48 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Builder { /// - /// Configuration options for . + /// Configuration options for . /// public class OAuthOptions : RemoteAuthenticationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index dc073ab7ba..b8f056facb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs index 07aefec424..dde12494de 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Builder /// Adds the middleware to the specified , which enables OpenID Connect authentication capabilities. ///
/// The to add the middleware to. - /// A that specifies options for the middleware. + /// A that specifies options for the middleware. /// A reference to this instance after the operation has completed. public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app, OpenIdConnectOptions options) { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 1e804ef314..9c157e57bf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -579,8 +579,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Redeems the authorization code for tokens at the token endpoint /// - /// The authorization code to redeem. - /// Uri that was passed in the request sent for the authorization code. + /// The request that will be sent to the token endpoint and is available for customization. /// OpenIdConnect message that has tokens inside it. protected virtual async Task RedeemAuthorizationCodeAsync(OpenIdConnectMessage tokenEndpointRequest) { @@ -598,6 +597,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Goes to UserInfo endpoint to retrieve additional claims and add any unique claims to the given identity. ///
/// message that is being processed + /// The . /// authentication ticket with claims principal and identities /// Authentication ticket with identity with additional claims, if any. protected virtual async Task GetUserInformationAsync(OpenIdConnectMessage message, JwtSecurityToken jwt, AuthenticationTicket ticket) @@ -689,7 +689,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Save the tokens contained in the in the . /// - /// The principal in which tokens are saved. + /// The in which tokens are saved. /// The OpenID Connect response. private void SaveTokens(AuthenticationProperties properties, OpenIdConnectMessage message) { @@ -734,7 +734,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Adds the nonce to . ///
/// the nonce to remember. - /// is called to add a cookie with the name: 'OpenIdConnectAuthenticationDefaults.Nonce + (nonce)'. + /// of is called to add a cookie with the name: 'OpenIdConnectAuthenticationDefaults.Nonce + (nonce)' of . /// The value of the cookie is: "N". private void WriteNonceCookie(string nonce) { @@ -759,8 +759,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect ///
/// the nonce that we are looking for. /// echos 'nonce' if a cookie is found that matches, null otherwise. - /// Examine that start with the prefix: 'OpenIdConnectAuthenticationDefaults.Nonce'. - /// is used to obtain the actual 'nonce'. If the nonce is found, then is called. + /// Examine of that start with the prefix: 'OpenIdConnectAuthenticationDefaults.Nonce'. + /// of is used to obtain the actual 'nonce'. If the nonce is found, then of is called. private string ReadNonceCookie(string nonce) { if (nonce == null) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs index 09901cf372..86ba433123 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -31,6 +31,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// /// + /// The . [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Managed by caller")] public OpenIdConnectMiddleware( RequestDelegate next, @@ -172,9 +173,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect protected HtmlEncoder HtmlEncoder { get; private set; } /// - /// Provides the object for processing authentication-related requests. + /// Provides the object for processing authentication-related requests. /// - /// An configured with the supplied to the constructor. + /// An configured with the supplied to the constructor. protected override AuthenticationHandler CreateHandler() { return new OpenIdConnectHandler(Backchannel, HtmlEncoder); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index fc58e6a890..870884c4df 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs index 76b487b966..006fafc731 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Called when a Challenge causes a redirect to authorize endpoint in the Twitter middleware /// - /// Contains redirect URI and of the challenge + /// Contains redirect URI and of the challenge Task RedirectToAuthorizationEndpoint(TwitterRedirectToAuthorizationEndpointContext context); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs index 97d1d176a9..04a45ac6d8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs @@ -17,6 +17,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// Initializes a ///
/// The HTTP environment + /// The options for Twitter /// Twitter user ID /// Twitter screen name /// Twitter access token diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs index 99122e8553..21c5b57a7f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Called when a Challenge causes a redirect to authorize endpoint in the Twitter middleware /// - /// Contains redirect URI and of the challenge + /// Contains redirect URI and of the challenge public virtual Task RedirectToAuthorizationEndpoint(TwitterRedirectToAuthorizationEndpointContext context) => OnRedirectToAuthorizationEndpoint(context); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs index 1a1e199cc1..7845b4bbcc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs @@ -31,7 +31,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// /// Configuration options for the middleware - /// public TwitterMiddleware( RequestDelegate next, IDataProtectionProvider dataProtectionProvider, @@ -115,9 +114,9 @@ namespace Microsoft.AspNetCore.Authentication.Twitter } /// - /// Provides the object for processing authentication-related requests. + /// Provides the object for processing authentication-related requests. /// - /// An configured with the supplied to the constructor. + /// An configured with the supplied to the constructor. protected override AuthenticationHandler CreateHandler() { return new TwitterHandler(_httpClient); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 8dd3556bcc..3dbaf2bf6c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*" diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index ff98a10318..f50fd3dbbd 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -64,6 +64,7 @@ namespace Microsoft.AspNetCore.Authentication /// The original options passed by the application control behavior /// The utility object to observe the current request and response /// The logging factory used to create loggers + /// The . /// async completion public async Task InitializeAsync(TOptions options, HttpContext context, ILogger logger, UrlEncoder encoder) { diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index d925be8ec4..a78c14bbec 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Authentication; namespace Microsoft.AspNetCore.Builder { /// - /// Contains the options used by the . + /// Contains the options used by the . /// public class RemoteAuthenticationOptions : AuthenticationOptions { @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Builder /// /// Defines whether access and refresh tokens should be stored in the - /// after a successful authorization. + /// after a successful authorization. /// This property is set to false by default to reduce /// the size of the final authentication cookie. /// diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index 73f7ed80d2..8339dc0c31 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.DataProtection": "1.0.0-*", diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs index a2b0a755cf..8979c5c632 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -13,6 +13,7 @@ namespace Microsoft.AspNetCore.Authorization /// /// Checks if a user meets a specific requirement for the specified resource /// + /// The . /// /// /// diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 511a05d56c..7a53cad1db 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.Extensions.Logging.Abstractions": "1.0.0-*", diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json index ce4c552dc9..1c2a549bef 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/project.json @@ -7,7 +7,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Http": "1.0.0-*", diff --git a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs index 1fe857fd92..56cb77fdc5 100644 --- a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs +++ b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs @@ -12,3 +12,4 @@ using System.Runtime.InteropServices; [assembly: Guid("a7922dd8-09f1-43e4-938b-cc523ea08898")] [assembly: AssemblyCompany("Microsoft Corporation.")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.Owin.Security.Interop/project.json b/src/Microsoft.Owin.Security.Interop/project.json index 953428b7b4..741385c83a 100644 --- a/src/Microsoft.Owin.Security.Interop/project.json +++ b/src/Microsoft.Owin.Security.Interop/project.json @@ -1,9 +1,11 @@ { "version": "1.0.0-*", - "compilationOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" - }, + "compilationOptions": { + "warningsAsErrors": true, + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true + }, "description": "A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication.", "dependencies": { "Microsoft.AspNetCore.DataProtection.Extensions": "1.0.0-*", From e160f5e6c02877f7bee3f9ca1ecbe77264101de1 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Mon, 7 Mar 2016 20:55:02 -0800 Subject: [PATCH 487/900] Update the build scripts to the latest version --- build.ps1 | 33 ++++++++++++++++++++++++++++++++- build.sh | 15 +++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index 4fd24a30d5..8f2f99691a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,3 +1,33 @@ +$ErrorActionPreference = "Stop" + +function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) +{ + while($true) + { + try + { + Invoke-WebRequest $url -OutFile $downloadLocation + break + } + catch + { + $exceptionMessage = $_.Exception.Message + Write-Host "Failed to download '$url': $exceptionMessage" + if ($retries -gt 0) { + $retries-- + Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" + Start-Sleep -Seconds 10 + + } + else + { + $exception = $_.Exception + throw $exception + } + } + } +} + cd $PSScriptRoot $repoFolder = $PSScriptRoot @@ -20,7 +50,8 @@ if (!(Test-Path $buildFolder)) { $localZipFile="$tempFolder\korebuild.zip" - Invoke-WebRequest $koreBuildZip -OutFile $localZipFile + DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 + Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) diff --git a/build.sh b/build.sh index 79638d06b6..f4208100eb 100755 --- a/build.sh +++ b/build.sh @@ -18,7 +18,18 @@ if test ! -d $buildFolder; then localZipFile="$tempFolder/korebuild.zip" - wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip /dev/null + retries=6 + until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) + do + echo "Failed to download '$koreBuildZip'" + if [ "$retries" -le 0 ]; then + exit 1 + fi + retries=$((retries - 1)) + echo "Waiting 10 seconds before retrying. Retries left: $retries" + sleep 10s + done + unzip -q -d $tempFolder $localZipFile mkdir $buildFolder @@ -32,4 +43,4 @@ if test ! -d $buildFolder; then fi fi -$buildFile -r $repoFolder "$@" +$buildFile -r $repoFolder "$@" \ No newline at end of file From 553e036d2840844d25b879fb2ec2472bf1c66187 Mon Sep 17 00:00:00 2001 From: Mike Surcouf Date: Wed, 9 Mar 2016 11:04:11 +0000 Subject: [PATCH 488/900] Add GivenName and Surname default claims to FacebookOptions --- .../FacebookOptions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs index ac6987f3df..8e86b37c1f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs @@ -28,6 +28,8 @@ namespace Microsoft.AspNetCore.Builder Scope.Add("email"); Fields.Add("name"); Fields.Add("email"); + Fields.Add("first_name"); + Fields.Add("last_name"); } // Facebook uses a non-standard term for this field. From a5fcddc0a8d306218c54e4cafcc99c6754d22089 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 7 Mar 2016 15:59:34 -0800 Subject: [PATCH 489/900] #704 unregister auth handlers during unwind. --- .../AuthenticationMiddleware.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs index ad63b17614..a01490c3e4 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Authentication await _next(context); } } - catch (Exception) + finally { try { @@ -81,9 +81,8 @@ namespace Microsoft.AspNetCore.Authentication } catch (Exception) { - // Don't mask the original exception + // Don't mask the original exception, if any } - throw; } } From ebad0ad76803f27fda252c826ec5e4634af6e3fb Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 9 Mar 2016 16:35:15 -0800 Subject: [PATCH 490/900] Limit the branches that build on our public CI. [ci skip] --- .travis.yml | 6 ++++++ appveyor.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index bf811dc26a..dd4686f39c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,5 +16,11 @@ os: - linux - osx osx_image: xcode7.1 +branches: + only: + - master + - release + - dev + - /^(.*\\/)?ci-.*$/ script: - ./build.sh verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 3fab83e134..c6d5f7d997 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,11 @@ init: - git config --global core.autocrlf true +branches: + only: + - master + - release + - dev + - /^(.*\\/)?ci-.*$/ build_script: - build.cmd verify clone_depth: 1 From 26965fd1e178e6a5654348819be5097f2f6db551 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 9 Mar 2016 17:44:49 -0800 Subject: [PATCH 491/900] Fix backslashes in yml config. [ci skip] --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd4686f39c..df22f7a880 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,6 @@ branches: - master - release - dev - - /^(.*\\/)?ci-.*$/ + - /^(.*\/)?ci-.*$/ script: - ./build.sh verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index c6d5f7d997..b9a9bcd1e6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ branches: - master - release - dev - - /^(.*\\/)?ci-.*$/ + - /^(.*\/)?ci-.*$/ build_script: - build.cmd verify clone_depth: 1 From d78f7edfc7d3084c430eb129e3d6b8f703ff8eb9 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 8 Mar 2016 00:22:33 -0800 Subject: [PATCH 492/900] Fix package metadata And also a few other Core-related renames. --- README.md | 7 +++--- .../project.json | 9 +++++-- .../FacebookMiddleware.cs | 2 +- .../project.json | 9 +++++-- .../GoogleMiddleware.cs | 2 +- .../project.json | 9 +++++-- .../project.json | 9 +++++-- .../MicrosoftAccountMiddleware.cs | 2 +- .../project.json | 9 +++++-- .../OAuthMiddleware.cs | 4 ++-- .../project.json | 7 +++++- .../OpenIdConnectMiddleware.cs | 6 ++--- .../project.json | 9 +++++-- .../TwitterMiddleware.cs | 4 ++-- .../project.json | 7 +++++- .../project.json | 7 +++++- .../project.json | 6 ++++- .../project.json | 7 ++++-- .../project.json | 24 ++++++++++++------- .../CookieInteropTests.cs | 4 ++-- 20 files changed, 101 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 02e65225c1..f32798072d 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,11 @@ AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/fujhh8n956v5o Travis: [![Travis](https://travis-ci.org/aspnet/Security.svg?branch=dev)](https://travis-ci.org/aspnet/Security) -ASP.NET Security contains the security and authorization middlewares for ASP.NET 5. - -This project is part of ASP.NET 5. You can find samples, documentation and getting started instructions for ASP.NET 5 at the [Home](https://github.com/aspnet/home) repo. +Contains the security and authorization middlewares for ASP.NET Core. ### Notes ASP.NET Security will not include Basic Authentication middleware due to its potential insecurity and performance problems. If you host under IIS you can enable it via IIS configuration. If you require Basic Authentication middleware for testing purposes, as a shared secret authentication mechanism for server to server communication, or to use a database as a user source then please look at the samples from [leastprivilege](https://github.com/leastprivilege/BasicAuthentication.AspNet5) or [Kukkimonsuta](https://github.com/Kukkimonsuta/Odachi/tree/master/src/Odachi.AspNetCore.Authentication.Basic). + + +This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index 0029e6a897..b1148ce00c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -1,6 +1,11 @@ { "version": "1.0.0-*", - "description": "ASP.NET middleware that enables an application to use cookie based authentication, similar to ASP.NET's forms authentication.", + "description": "ASP.NET Core middleware that enables an application to use cookie based authentication.", + "tags": [ + "aspnetcore", + "authentication", + "security" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" @@ -17,7 +22,7 @@ "Microsoft.Extensions.WebEncoders": "1.0.0-*" }, "frameworks": { - "net451": {}, + "net451": { }, "netstandard1.3": { "imports": [ "dotnet5.4" diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs index e4a76e0e93..ac57e8ddeb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs @@ -14,7 +14,7 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication.Facebook { /// - /// An ASP.NET middleware for authenticating users using Facebook. + /// An ASP.NET Core middleware for authenticating users using Facebook. /// public class FacebookMiddleware : OAuthMiddleware { diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 3cd595a96e..2fe5040003 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -1,6 +1,11 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow.", + "description": "ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow.", + "tags": [ + "aspnetcore", + "authentication", + "security" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" @@ -15,7 +20,7 @@ "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" }, "frameworks": { - "net451": {}, + "net451": { }, "netstandard1.3": { "imports": [ "dotnet5.4", diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs index 190dc4b25a..ba6fb7d2ef 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs @@ -14,7 +14,7 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication.Google { /// - /// An ASP.NET middleware for authenticating users using Google OAuth 2.0. + /// An ASP.NET Core middleware for authenticating users using Google OAuth 2.0. /// [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Middleware are not disposable.")] public class GoogleMiddleware : OAuthMiddleware diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index 702d45aefd..ed29e86ae4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -1,6 +1,11 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 contains middlewares to support Google's OpenId and OAuth 2.0 authentication workflows.", + "description": "ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows.", + "tags": [ + "aspnetcore", + "authentication", + "security" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" @@ -15,7 +20,7 @@ "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" }, "frameworks": { - "net451": {}, + "net451": { }, "netstandard1.3": { "imports": [ "dotnet5.4", diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 091deca827..e86e914152 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -1,6 +1,11 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 middleware that enables an application to receive an OpenID Connect bearer token.", + "description": "ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token.", + "tags": [ + "aspnetcore", + "authentication", + "security" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" @@ -16,7 +21,7 @@ "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { - "net451": {}, + "net451": { }, "netstandard1.3": { "imports": [ "dotnet5.4", diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs index fc9866826b..3ad1bf5571 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs @@ -13,7 +13,7 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { /// - /// An ASP.NET middleware for authenticating users using the Microsoft Account service. + /// An ASP.NET Core middleware for authenticating users using the Microsoft Account service. /// public class MicrosoftAccountMiddleware : OAuthMiddleware { diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index e0a2fceb0d..7507e1eb4c 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -1,6 +1,11 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 middleware that enables an application to support the Microsoft Account authentication workflow.", + "description": "ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow.", + "tags": [ + "aspnetcore", + "authentication", + "security" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" @@ -15,7 +20,7 @@ "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" }, "frameworks": { - "net451": {}, + "net451": { }, "netstandard1.3": { "imports": [ "dotnet5.4", diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs index 1a16d2aa3b..7ef1863226 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs @@ -15,7 +15,7 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication.OAuth { /// - /// An ASP.NET middleware for authenticating users using OAuth services. + /// An ASP.NET Core middleware for authenticating users using OAuth services. /// [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Middleware are not disposable.")] public class OAuthMiddleware : AuthenticationMiddleware where TOptions : OAuthOptions, new() @@ -112,7 +112,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth } Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET OAuth middleware"); + Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OAuth middleware"); Backchannel.Timeout = Options.BackchannelTimeout; Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index b8f056facb..978dea7cc7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -1,6 +1,11 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 middleware that enables an application to support any standard OAuth 2.0 authentication workflow.", + "description": "ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow.", + "tags": [ + "aspnetcore", + "authentication", + "security" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs index 86ba433123..76936e25a6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -17,14 +17,14 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// - /// ASP.NET middleware for obtaining identities using OpenIdConnect protocol. + /// ASP.NET Core middleware for obtaining identities using OpenIdConnect protocol. /// public class OpenIdConnectMiddleware : AuthenticationMiddleware { /// /// Initializes a /// - /// The next middleware in the ASP.NET pipeline to invoke. + /// The next middleware in the middleware pipeline to invoke. /// provider for creating a data protector. /// factory for creating a . /// @@ -134,7 +134,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET OpenIdConnect middleware"); + Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OpenIdConnect middleware"); Backchannel.Timeout = Options.BackchannelTimeout; Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 870884c4df..eee5f0942f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -1,6 +1,11 @@ { "version": "0.1.0-*", - "description": "ASP.NET 5 middleware that enables an application to support the OpenID Connect authentication workflow.", + "description": "ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow.", + "tags": [ + "aspnetcore", + "authentication", + "security" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" @@ -16,7 +21,7 @@ "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { - "net451": {}, + "net451": { }, "netstandard1.3": { "imports": [ "dotnet5.4", diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs index 7845b4bbcc..542115117f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs @@ -15,7 +15,7 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication.Twitter { /// - /// ASP.NET middleware for authenticating users using Twitter + /// ASP.NET Core middleware for authenticating users using Twitter. /// [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Middleware are not disposable.")] public class TwitterMiddleware : AuthenticationMiddleware @@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter _httpClient.Timeout = Options.BackchannelTimeout; _httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB _httpClient.DefaultRequestHeaders.Accept.ParseAdd("*/*"); - _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Twitter middleware"); + _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core Twitter middleware"); _httpClient.DefaultRequestHeaders.ExpectContinue = false; } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 3dbaf2bf6c..73e5c9b7af 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -1,6 +1,11 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 middleware that enables an application to support Twitter's OAuth 2.0 authentication workflow.", + "description": "ASP.NET Core middleware that enables an application to support Twitter's OAuth 2.0 authentication workflow.", + "tags": [ + "aspnetcore", + "authentication", + "security" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index 8339dc0c31..f02351c2cd 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -1,6 +1,11 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 common types used by the various authentication middleware.", + "description": "ASP.NET Core common types used by the various authentication middleware components.", + "tags": [ + "aspnetcore", + "authentication", + "security" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 7a53cad1db..e75441dc84 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -1,6 +1,10 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 authorization classes.", + "description": "ASP.NET 5 authorization classes.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Authorization.AllowAnonymousAttribute\r\nMicrosoft.AspNetCore.Authorization.AuthorizeAttribute", + "tags": [ + "aspnetcore", + "authorization" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json index 1c2a549bef..f1c7b77b91 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/project.json @@ -1,6 +1,9 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 cookie policy classes.", + "description": "ASP.NET Core cookie policy classes to control the behavior of cookies.", + "tags": [ + "aspnetcore" + ], "repository": { "type": "git", "url": "git://github.com/aspnet/security" @@ -16,7 +19,7 @@ "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { - "net451": {}, + "net451": { }, "netstandard1.3": { "imports": [ "dotnet5.4" diff --git a/src/Microsoft.Owin.Security.Interop/project.json b/src/Microsoft.Owin.Security.Interop/project.json index 741385c83a..691b16c42d 100644 --- a/src/Microsoft.Owin.Security.Interop/project.json +++ b/src/Microsoft.Owin.Security.Interop/project.json @@ -1,17 +1,23 @@ { - "version": "1.0.0-*", + "version": "1.0.0-*", "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ "CS1591" ], "xmlDoc": true }, - "description": "A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication.", - "dependencies": { - "Microsoft.AspNetCore.DataProtection.Extensions": "1.0.0-*", - "Microsoft.Owin.Security": "3.0.1" - }, - "frameworks": { - "net451": { } - } + "description": "A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication.", + "tags": [ + "aspnetcore", + "katana", + "owin", + "security" + ], + "dependencies": { + "Microsoft.AspNetCore.DataProtection.Extensions": "1.0.0-*", + "Microsoft.Owin.Security": "3.0.1" + }, + "frameworks": { + "net451": { } + } } \ No newline at end of file diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index ef80b78e6e..3c08f58bd6 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -31,7 +31,7 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = new DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type CookieAuthenticationDefaults.AuthenticationType, "v2"); var interopServer = TestServer.Create(app => @@ -87,7 +87,7 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = new DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type CookieAuthenticationDefaults.AuthenticationType, "v2"); var builder = new WebHostBuilder() From 4bfeba2a3c2baf6ac74f9853a0388501c3931690 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Thu, 10 Mar 2016 15:16:54 -0800 Subject: [PATCH 493/900] Update project.json @tratcher said :shipit: --- src/Microsoft.AspNetCore.Authorization/project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index e75441dc84..9d65386a8f 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -1,6 +1,6 @@ { "version": "1.0.0-*", - "description": "ASP.NET 5 authorization classes.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Authorization.AllowAnonymousAttribute\r\nMicrosoft.AspNetCore.Authorization.AuthorizeAttribute", + "description": "ASP.NET Core authorization classes.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Authorization.AllowAnonymousAttribute\r\nMicrosoft.AspNetCore.Authorization.AuthorizeAttribute", "tags": [ "aspnetcore", "authorization" @@ -34,4 +34,4 @@ ] } } -} \ No newline at end of file +} From f5c1c45db20fd4592a3f49d4dc1d39dc5f62108c Mon Sep 17 00:00:00 2001 From: Dovydas Navickas Date: Sun, 6 Mar 2016 01:48:08 +0200 Subject: [PATCH 494/900] IClaimsTransofrmer updated to take ClaimsTransformationContext instead of ClaimsPrincipal in TransformAsync method. #718 --- .../ClaimsTransformationAppBuilderExtensions.cs | 6 +++--- .../ClaimsTransformationContext.cs | 15 +++++++++++++++ .../ClaimsTransformationHandler.cs | 11 +++++++++-- .../ClaimsTransformationMiddleware.cs | 8 ++++++-- .../ClaimsTransformer.cs | 6 +++--- .../IClaimsTransformer.cs | 4 ++-- .../Cookies/CookieMiddlewareTests.cs | 8 ++++---- .../Google/GoogleMiddlewareTests.cs | 10 +++++----- 8 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication/ClaimsTransformationContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs index 1cc76b946e..1edb4a0f4b 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs @@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Builder /// The to add the middleware to. /// A function that asynchronously transforms one to another. /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, Func> transform) + public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, Func> transform) { if (app == null) { @@ -46,12 +46,12 @@ namespace Microsoft.AspNetCore.Builder throw new ArgumentNullException(nameof(transform)); } - return app.UseClaimsTransformation(new ClaimsTransformationOptions + return app.UseClaimsTransformation(new ClaimsTransformationOptions { Transformer = new ClaimsTransformer { OnTransform = transform } }); } - + /// /// Adds the middleware to the specified , which enables claims transformation capabilities. /// diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationContext.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationContext.cs new file mode 100644 index 0000000000..3c363ca98f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationContext.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Http; +using System.Security.Claims; + +namespace Microsoft.AspNetCore.Authentication +{ + public class ClaimsTransformationContext + { + public ClaimsTransformationContext(HttpContext context) + { + Context = context; + } + public HttpContext Context { get; } + public ClaimsPrincipal Principal { get; set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs index 78d9a0845b..7a2c47e401 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features.Authentication; namespace Microsoft.AspNetCore.Authentication @@ -12,10 +13,12 @@ namespace Microsoft.AspNetCore.Authentication public class ClaimsTransformationHandler : IAuthenticationHandler { private readonly IClaimsTransformer _transform; + private readonly HttpContext _httpContext; - public ClaimsTransformationHandler(IClaimsTransformer transform) + public ClaimsTransformationHandler(IClaimsTransformer transform, HttpContext httpContext) { _transform = transform; + _httpContext = httpContext; } public IAuthenticationHandler PriorHandler { get; set; } @@ -27,8 +30,12 @@ namespace Microsoft.AspNetCore.Authentication await PriorHandler.AuthenticateAsync(context); if (_transform != null && context?.Principal != null) { + var transformationContext = new ClaimsTransformationContext(_httpContext) + { + Principal = context.Principal + }; context.Authenticated( - await _transform.TransformAsync(context.Principal), + await _transform.TransformAsync(transformationContext), context.Properties, context.Description); } diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs index 2e2216bc25..53f6a07a87 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs @@ -35,13 +35,17 @@ namespace Microsoft.AspNetCore.Authentication public async Task Invoke(HttpContext context) { - var handler = new ClaimsTransformationHandler(Options.Transformer); + var handler = new ClaimsTransformationHandler(Options.Transformer, context); handler.RegisterAuthenticationHandler(context.GetAuthentication()); try { if (Options.Transformer != null) { - context.User = await Options.Transformer.TransformAsync(context.User); + var transformationContext = new ClaimsTransformationContext(context) + { + Principal = context.User + }; + context.User = await Options.Transformer.TransformAsync(transformationContext); } await _next(context); } diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs index b8e7ea3e1c..db05db0e5b 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs @@ -9,11 +9,11 @@ namespace Microsoft.AspNetCore.Authentication { public class ClaimsTransformer : IClaimsTransformer { - public Func> OnTransform { get; set; } + public Func> OnTransform { get; set; } - public virtual Task TransformAsync(ClaimsPrincipal principal) + public virtual Task TransformAsync(ClaimsTransformationContext context) { - return OnTransform?.Invoke(principal) ?? Task.FromResult(principal); + return OnTransform?.Invoke(context) ?? Task.FromResult(context.Principal); } } } diff --git a/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs b/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs index 5111c79714..cd42915c0a 100644 --- a/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs +++ b/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs @@ -14,8 +14,8 @@ namespace Microsoft.AspNetCore.Authentication /// /// Provides a central transformation point to change the specified principal. /// - /// The principal to transform. + /// containing principal to transform and current HttpContext. /// The transformed principal. - Task TransformAsync(ClaimsPrincipal principal); + Task TransformAsync(ClaimsTransformationContext context); } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 785d5bfa62..5049f39e55 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -293,16 +293,16 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { Transformer = new ClaimsTransformer { - OnTransform = p => + OnTransform = context => { - if (!p.Identities.Any(i => i.AuthenticationType == "xform")) + if (!context.Principal.Identities.Any(i => i.AuthenticationType == "xform")) { // REVIEW: Xform runs twice, once on Authenticate, and then once from the middleware var id = new ClaimsIdentity("xform"); id.AddClaim(new Claim("xform", "yup")); - p.AddIdentity(id); + context.Principal.AddIdentity(id); } - return Task.FromResult(p); + return Task.FromResult(context.Principal); } } }); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 96bb574fb3..31fb9e3175 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -222,7 +222,7 @@ namespace Microsoft.AspNetCore.Authentication.Google ClientId = "Test Id", ClientSecret = "Test Secret" }, - async context => + async context => { var req = context.Request; var res = context.Response; @@ -273,7 +273,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { var transaction = await sendTask; Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal("/error?FailureMessage=OMG"+UrlEncoder.Default.Encode(";Description=SoBad;Uri=foobar"), transaction.Response.Headers.GetValues("Location").First()); + Assert.Equal("/error?FailureMessage=OMG" + UrlEncoder.Default.Encode(";Description=SoBad;Uri=foobar"), transaction.Response.Headers.GetValues("Location").First()); } else { @@ -774,12 +774,12 @@ namespace Microsoft.AspNetCore.Authentication.Google AutomaticAuthenticate = true }); app.UseGoogleAuthentication(options); - app.UseClaimsTransformation(p => + app.UseClaimsTransformation(context => { var id = new ClaimsIdentity("xform"); id.AddClaim(new Claim("xform", "yup")); - p.AddIdentity(id); - return Task.FromResult(p); + context.Principal.AddIdentity(id); + return Task.FromResult(context.Principal); }); app.Use(async (context, next) => { From 1a8d5317a90d478745d5a8532dfb313e897705de Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Mon, 14 Mar 2016 14:50:57 -0700 Subject: [PATCH 495/900] Updated Json.Net version --- src/Microsoft.AspNetCore.Authentication.OAuth/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index 978dea7cc7..c02bfe8972 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -18,7 +18,7 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", - "Newtonsoft.Json": "8.0.2" + "Newtonsoft.Json": "8.0.3" }, "frameworks": { "net451": { From 22f55d5937d310079b4b0c81e30666ce6725de12 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 15 Mar 2016 18:28:56 -0700 Subject: [PATCH 496/900] Reacting to DataProtection changes --- .../CookieInteropTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index 3c08f58bd6..2abb115e47 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -29,7 +29,7 @@ namespace Microsoft.Owin.Security.Interop var identity = new ClaimsIdentity("Cookies"); identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); - var dataProtection = new DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type CookieAuthenticationDefaults.AuthenticationType, "v2"); @@ -85,7 +85,7 @@ namespace Microsoft.Owin.Security.Interop identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); user.AddIdentity(identity); - var dataProtection = new DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type CookieAuthenticationDefaults.AuthenticationType, "v2"); From 81bf1c20961fe90849396ff3e69e5ad4f4269945 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 17 Mar 2016 15:33:17 -0700 Subject: [PATCH 497/900] Cleanup transitive dependencies --- samples/OpenIdConnect.AzureAdSample/project.json | 1 - .../project.json | 9 +-------- .../project.json | 9 +-------- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index dabb9262fc..a25fc16613 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -2,7 +2,6 @@ "dependencies": { "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", - "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index c02bfe8972..c6658208e5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -21,15 +21,8 @@ "Newtonsoft.Json": "8.0.3" }, "frameworks": { - "net451": { - "frameworkAssemblies": { - "System.Net.Http": "" - } - }, + "net451": { }, "netstandard1.3": { - "dependencies": { - "System.Net.Http": "4.0.1-*" - }, "imports": [ "dotnet5.4", "portable-net451+win8" diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 73e5c9b7af..718d51747f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -20,15 +20,8 @@ "Microsoft.AspNetCore.Authentication": "1.0.0-*" }, "frameworks": { - "net451": { - "frameworkAssemblies": { - "System.Net.Http": "" - } - }, + "net451": { }, "netstandard1.3": { - "dependencies": { - "System.Net.Http": "4.0.1-*" - }, "imports": [ "dotnet5.4" ] From 9361960b2f8aaf8bb329dd5dce0f9e7659179799 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 17 Mar 2016 22:26:02 -0700 Subject: [PATCH 498/900] React to HttpAbstractions change: No features in `.Internal` namespace - see issue aspnet/HttpAbstractions#561 and pull aspnet/HttpAbstractions#589 --- .../CookiePolicyMiddleware.cs | 1 + .../CookiePolicyTests.cs | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs index d9a65028c7..b8bb1264eb 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -5,6 +5,7 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features.Internal; using Microsoft.Extensions.Options; diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index fde6034974..307002d1f3 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Http.Features.Internal; using Microsoft.AspNetCore.TestHost; using Xunit; @@ -277,7 +276,7 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test } private async Task RunTest( - string path, + string path, CookiePolicyOptions cookiePolicy, RequestDelegate configureSetup, params RequestTest[] tests) From 22d133cefa20926b25eeb82779343b23a221117f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 22 Mar 2016 14:51:18 -0700 Subject: [PATCH 499/900] Reacting to CoreCLR package changes --- .../CookieAuthenticationDefaults.cs | 4 ---- .../CookieAuthenticationOptions.cs | 4 ---- .../Events/CookieRedirectContext.cs | 3 --- .../GoogleMiddleware.cs | 2 -- .../OAuthMiddleware.cs | 2 -- .../OpenIdConnectMiddleware.cs | 2 -- .../OpenIdConnectOptions.cs | 4 ---- .../Messages/RequestTokenSerializer.cs | 3 --- .../TwitterMiddleware.cs | 2 -- .../DataHandler/PropertiesSerializer.cs | 3 --- 10 files changed, 29 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs index 2baa9e45cd..ad0e17a096 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs @@ -1,7 +1,6 @@ // 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.Diagnostics.CodeAnalysis; using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.Cookies @@ -25,21 +24,18 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// The default value used by CookieAuthenticationMiddleware for the /// CookieAuthenticationOptions.LoginPath ///
- [SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Login", Justification = "By design")] public static readonly PathString LoginPath = new PathString("/Account/Login"); /// /// The default value used by CookieAuthenticationMiddleware for the /// CookieAuthenticationOptions.LogoutPath /// - [SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Logout", Justification = "By design")] public static readonly PathString LogoutPath = new PathString("/Account/Logout"); /// /// The default value used by CookieAuthenticationMiddleware for the /// CookieAuthenticationOptions.AccessDeniedPath /// - [SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Login", Justification = "By design")] public static readonly PathString AccessDeniedPath = new PathString("/Account/AccessDenied"); /// diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 51cf43a0f1..8a451c9c71 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -3,7 +3,6 @@ using System; using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.DataProtection; @@ -103,13 +102,11 @@ namespace Microsoft.AspNetCore.Builder /// LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect the browser back /// to the url which caused the original unauthorized status code. /// - [SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Login", Justification = "By design")] public PathString LoginPath { get; set; } /// /// If the LogoutPath is provided the middleware then a request to that path will redirect based on the ReturnUrlParameter. /// - [SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Logout", Justification = "By design")] public PathString LogoutPath { get; set; } /// @@ -124,7 +121,6 @@ namespace Microsoft.AspNetCore.Builder /// string parameter looked for when a request arrives on the login path or logout path, in order to return to the /// original url after the action is performed. /// - [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "ReturnUrl is the name of a querystring parameter")] public string ReturnUrlParameter { get; set; } /// diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs index c26cd5d662..2cbb5ff095 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs @@ -1,7 +1,6 @@ // 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.Diagnostics.CodeAnalysis; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; @@ -20,7 +19,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// The cookie middleware options /// The initial redirect URI /// The . - [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#", Justification = "Represents header value")] public CookieRedirectContext(HttpContext context, CookieAuthenticationOptions options, string redirectUri, AuthenticationProperties properties) : base(context, options) { @@ -31,7 +29,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Gets or Sets the URI used for the redirect operation. /// - [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "Represents header value")] public string RedirectUri { get; set; } public AuthenticationProperties Properties { get; } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs index ba6fb7d2ef..eb98e447b3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs @@ -2,7 +2,6 @@ // 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 System.Text.Encodings.Web; using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.AspNetCore.Builder; @@ -16,7 +15,6 @@ namespace Microsoft.AspNetCore.Authentication.Google /// /// An ASP.NET Core middleware for authenticating users using Google OAuth 2.0. /// - [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Middleware are not disposable.")] public class GoogleMiddleware : OAuthMiddleware { /// diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs index 7ef1863226..75139c1c80 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs @@ -2,7 +2,6 @@ // 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 System.Globalization; using System.Net.Http; using System.Text.Encodings.Web; @@ -17,7 +16,6 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// An ASP.NET Core middleware for authenticating users using OAuth services. /// - [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Middleware are not disposable.")] public class OAuthMiddleware : AuthenticationMiddleware where TOptions : OAuthOptions, new() { /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs index 76936e25a6..80f2ca2ba3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -2,7 +2,6 @@ // 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 System.Net.Http; using System.Text; using System.Text.Encodings.Web; @@ -32,7 +31,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// /// The . - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Managed by caller")] public OpenIdConnectMiddleware( RequestDelegate next, IDataProtectionProvider dataProtectionProvider, diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 1b179c3369..acf9d77e40 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; using System.IdentityModel.Tokens.Jwt; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OpenIdConnect; @@ -45,7 +44,6 @@ namespace Microsoft.AspNetCore.Builder /// UseTokenLifetime: false. /// /// will be used to when creating the for the AuthenticationScheme property. - [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectOptions.set_Caption(System.String)", Justification = "Not a LOC field")] public OpenIdConnectOptions(string authenticationScheme) { AuthenticationScheme = authenticationScheme; @@ -124,8 +122,6 @@ namespace Microsoft.AspNetCore.Builder /// Gets or sets the 'post_logout_redirect_uri' /// /// This is sent to the OP as the redirect for the user-agent. - [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "By design")] - [SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Logout", Justification = "This is the term used in the spec.")] public string PostLogoutRedirectUri { get; set; } /// diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs index a96a379c18..88b10d3d60 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs @@ -2,7 +2,6 @@ // 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 System.IO; using Microsoft.AspNetCore.Http.Authentication; @@ -20,7 +19,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// The token to serialize /// A byte array containing the serialized token - [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Dispose is idempotent")] public virtual byte[] Serialize(RequestToken model) { using (var memory = new MemoryStream()) @@ -39,7 +37,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// A byte array containing the serialized token /// The Twitter request token - [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Dispose is idempotent")] public virtual RequestToken Deserialize(byte[] data) { using (var memory = new MemoryStream(data)) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs index 542115117f..67fb903dd1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs @@ -2,7 +2,6 @@ // 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 System.Globalization; using System.Net.Http; using System.Text.Encodings.Web; @@ -17,7 +16,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// ASP.NET Core middleware for authenticating users using Twitter. /// - [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Middleware are not disposable.")] public class TwitterMiddleware : AuthenticationMiddleware { private readonly HttpClient _httpClient; diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs index 542553cf2b..dd30b45ae0 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.IO; using Microsoft.AspNetCore.Http.Authentication; @@ -15,7 +14,6 @@ namespace Microsoft.AspNetCore.Authentication public static PropertiesSerializer Default { get; } = new PropertiesSerializer(); - [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Dispose is idempotent")] public virtual byte[] Serialize(AuthenticationProperties model) { using (var memory = new MemoryStream()) @@ -29,7 +27,6 @@ namespace Microsoft.AspNetCore.Authentication } } - [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Dispose is idempotent")] public virtual AuthenticationProperties Deserialize(byte[] data) { using (var memory = new MemoryStream(data)) From 7ec3da701cebcd36df07367e06b321fb743fbf94 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 23 Mar 2016 16:15:16 -0700 Subject: [PATCH 500/900] Reacting to CoreFx package changes --- .../project.json | 4 ++-- .../project.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index e86e914152..3efa9c0647 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -22,9 +22,9 @@ }, "frameworks": { "net451": { }, - "netstandard1.3": { + "netstandard1.4": { "imports": [ - "dotnet5.4", + "dotnet5.5", "portable-net451+win8" ] } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index eee5f0942f..7be775cfe0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -22,9 +22,9 @@ }, "frameworks": { "net451": { }, - "netstandard1.3": { + "netstandard1.4": { "imports": [ - "dotnet5.4", + "dotnet5.5", "portable-net451+win8" ] } From 6d4a80e747b3fddf73cc7fb1ce6c75c235aaa7d7 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 11 Feb 2016 16:08:27 -0800 Subject: [PATCH 501/900] [Fixes #532] Replace hard-coded logging event ids with a class of consts --- .../JwtBearerHandler.cs | 6 +- .../LoggingExtensions.cs | 45 ++ .../LoggingExtensions.cs | 446 ++++++++++++++++++ .../OpenIdConnectHandler.cs | 93 ++-- .../LoggingExtensions.cs | 36 ++ .../TwitterHandler.cs | 4 +- .../AuthenticationHandler.cs | 20 +- .../LoggingExtensions.cs | 175 +++++++ .../RemoteAuthenticationHandler.cs | 12 +- .../DefaultAuthorizationService.cs | 4 +- .../LoggingExtensions.cs | 35 ++ 11 files changed, 809 insertions(+), 67 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 613dfbc152..b1d2d702eb 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } catch (Exception ex) { - Logger.LogInformation(0, ex, "Failed to validate the token: " + token); + Logger.TokenValidationFailed(token, ex); // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the event. if (Options.RefreshOnIssuerKeyNotFound && ex.GetType().Equals(typeof(SecurityTokenSignatureKeyNotFoundException))) @@ -135,7 +135,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer continue; } - Logger.LogInformation("Successfully validated the token"); + Logger.TokenValidationSucceeded(); var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Options.AuthenticationScheme); var validatedTokenContext = new ValidatedTokenContext(Context, Options) @@ -189,7 +189,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } catch (Exception ex) { - Logger.LogError(0, ex, "Exception occurred while processing message"); + Logger.ErrorProcessingMessage(ex); var authenticationFailedContext = new AuthenticationFailedContext(Context, Options) { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs new file mode 100644 index 0000000000..643da92906 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs @@ -0,0 +1,45 @@ +// 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.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _tokenValidationFailed; + private static Action _tokenValidationSucceeded; + private static Action _errorProcessingMessage; + + static LoggingExtensions() + { + _tokenValidationFailed = LoggerMessage.Define( + eventId: 1, + logLevel: LogLevel.Information, + formatString: "Failed to validate the token {Token}."); + _tokenValidationSucceeded = LoggerMessage.Define( + eventId: 2, + logLevel: LogLevel.Information, + formatString: "Successfully validated the token."); + _errorProcessingMessage = LoggerMessage.Define( + eventId: 3, + logLevel: LogLevel.Error, + formatString: "Exception occurred while processing message."); + } + + public static void TokenValidationFailed(this ILogger logger, string token, Exception ex) + { + _tokenValidationFailed(logger, token, ex); + } + + public static void TokenValidationSucceeded(this ILogger logger) + { + _tokenValidationSucceeded(logger, null, null); + } + + public static void ErrorProcessingMessage(this ILogger logger, Exception ex) + { + _errorProcessingMessage(logger, ex); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs new file mode 100644 index 0000000000..8d45c9918c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -0,0 +1,446 @@ +// 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.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _redirectToEndSessionEndpointHandledResponse; + private static Action _redirectToEndSessionEndpointSkipped; + private static Action _redirectToAuthenticationEndpointHandledResponse; + private static Action _redirectToAuthenticationEndpointSkipped; + private static Action _updatingConfiguration; + private static Action _receivedIdToken; + private static Action _redeemingCodeForTokens; + private static Action _enteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync; + private static Action _enteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync; + private static Action _messageReceived; + private static Action _messageReceivedContextHandledResponse; + private static Action _messageReceivedContextSkipped; + private static Action _authorizationResponseReceived; + private static Action _authorizationCodeReceived; + private static Action _configurationManagerRequestRefreshCalled; + private static Action _tokenResponseReceived; + private static Action _authorizationResponseReceivedHandledResponse; + private static Action _authorizationResponseReceivedSkipped; + private static Action _authenticationFailedContextHandledResponse; + private static Action _authenticationFailedContextSkipped; + private static Action _authorizationCodeReceivedContextHandledResponse; + private static Action _authorizationCodeReceivedContextSkipped; + private static Action _authorizationCodeRedeemedContextHandledResponse; + private static Action _authorizationCodeRedeemedContextSkipped; + private static Action _authenticationValidatedHandledResponse; + private static Action _authenticationValidatedtSkipped; + private static Action _userInformationReceived; + private static Action _userInformationReceivedHandledResponse; + private static Action _userInformationReceivedSkipped; + private static Action _invalidLogoutQueryStringRedirectUrl; + private static Action _nullOrEmptyAuthorizationResponseState; + private static Action _unableToReadAuthorizationResponseState; + private static Action _authorizationResponseError; + private static Action _exceptionProcessingMessage; + private static Action _accessTokenNotAvailable; + private static Action _retrievingClaims; + private static Action _userInfoEndpointNotSet; + private static Action _unableToProtectNonceCookie; + private static Action _invalidAuthenticationRequestUrl; + private static Action _unableToReadIdToken; + private static Action _invalidSecurityTokenType; + private static Action _unableToValidateIdToken; + private static Action _postAuthenticationLocalRedirect; + + static LoggingExtensions() + { + // Final + _redirectToEndSessionEndpointHandledResponse = LoggerMessage.Define( + eventId: 1, + logLevel: LogLevel.Debug, + formatString: "RedirectToEndSessionEndpoint.HandledResponse"); + _redirectToEndSessionEndpointSkipped = LoggerMessage.Define( + eventId: 2, + logLevel: LogLevel.Debug, + formatString: "RedirectToEndSessionEndpoint.Skipped"); + _invalidLogoutQueryStringRedirectUrl = LoggerMessage.Define( + eventId: 3, + logLevel: LogLevel.Warning, + formatString: "The query string for Logout is not a well-formed URI. Redirect URI: '{RedirectUrl}'."); + _enteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync = LoggerMessage.Define( + eventId: 4, + logLevel: LogLevel.Trace, + formatString: "Entering {OpenIdConnectHandlerType}'s HandleUnauthorizedAsync."); + _postAuthenticationLocalRedirect = LoggerMessage.Define( + eventId: 5, + logLevel: LogLevel.Trace, + formatString: "Using properties.RedirectUri for 'local redirect' post authentication: '{RedirectUri}'."); + _redirectToAuthenticationEndpointHandledResponse = LoggerMessage.Define( + eventId: 6, + logLevel: LogLevel.Debug, + formatString: "RedirectToAuthenticationEndpoint.HandledResponse"); + _redirectToAuthenticationEndpointSkipped = LoggerMessage.Define( + eventId: 7, + logLevel: LogLevel.Debug, + formatString: "RedirectToAuthenticationEndpoint.Skipped"); + _invalidAuthenticationRequestUrl = LoggerMessage.Define( + eventId: 8, + logLevel: LogLevel.Warning, + formatString: "The redirect URI is not well-formed. The URI is: '{AuthenticationRequestUrl}'."); + _enteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync = LoggerMessage.Define( + eventId: 9, + logLevel: LogLevel.Trace, + formatString: "Entering {OpenIdConnectHandlerType}'s HandleRemoteAuthenticateAsync."); + _nullOrEmptyAuthorizationResponseState = LoggerMessage.Define( + eventId: 10, + logLevel: LogLevel.Debug, + formatString: "message.State is null or empty."); + _unableToReadAuthorizationResponseState = LoggerMessage.Define( + eventId: 11, + logLevel: LogLevel.Debug, + formatString: "Unable to read the message.State."); + _authorizationResponseError = LoggerMessage.Define( + eventId: 12, + logLevel: LogLevel.Error, + formatString: "Message contains error: '{Error}', error_description: '{ErrorDescription}', error_uri: '{ErrorUri}'."); + _updatingConfiguration = LoggerMessage.Define( + eventId: 13, + logLevel: LogLevel.Debug, + formatString: "Updating configuration"); + _authorizationResponseReceived = LoggerMessage.Define( + eventId: 14, + logLevel: LogLevel.Trace, + formatString: "Authorization response received."); + _authorizationResponseReceivedHandledResponse = LoggerMessage.Define( + eventId: 15, + logLevel: LogLevel.Debug, + formatString: "AuthorizationResponseReceived.HandledResponse"); + _authorizationResponseReceivedSkipped = LoggerMessage.Define( + eventId: 16, + logLevel: LogLevel.Debug, + formatString: "AuthorizationResponseReceived.Skipped"); + _exceptionProcessingMessage = LoggerMessage.Define( + eventId: 17, + logLevel: LogLevel.Error, + formatString: "Exception occurred while processing message."); + _configurationManagerRequestRefreshCalled = LoggerMessage.Define( + eventId: 18, + logLevel: LogLevel.Debug, + formatString: "Exception of type 'SecurityTokenSignatureKeyNotFoundException' thrown, Options.ConfigurationManager.RequestRefresh() called."); + _redeemingCodeForTokens = LoggerMessage.Define( + eventId: 19, + logLevel: LogLevel.Debug, + formatString: "Redeeming code for tokens."); + _retrievingClaims = LoggerMessage.Define( + eventId: 20, + logLevel: LogLevel.Trace, + formatString: "Retrieving claims from the user info endpoint."); + _receivedIdToken = LoggerMessage.Define( + eventId: 21, + logLevel: LogLevel.Debug, + formatString: "Received 'id_token'"); + _userInfoEndpointNotSet = LoggerMessage.Define( + eventId: 22, + logLevel: LogLevel.Debug, + formatString: "UserInfoEndpoint is not set. Claims cannot be retrieved."); + _unableToProtectNonceCookie = LoggerMessage.Define( + eventId: 23, + logLevel: LogLevel.Warning, + formatString: "Failed to un-protect the nonce cookie."); + _messageReceived = LoggerMessage.Define( + eventId: 24, + logLevel: LogLevel.Trace, + formatString: "MessageReceived: '{RedirectUrl}'."); + _messageReceivedContextHandledResponse = LoggerMessage.Define( + eventId: 25, + logLevel: LogLevel.Debug, + formatString: "MessageReceivedContext.HandledResponse"); + _messageReceivedContextSkipped = LoggerMessage.Define( + eventId: 26, + logLevel: LogLevel.Debug, + formatString: "MessageReceivedContext.Skipped"); + _authorizationCodeReceived = LoggerMessage.Define( + eventId: 27, + logLevel: LogLevel.Trace, + formatString: "Authorization code received."); + _authorizationCodeReceivedContextHandledResponse = LoggerMessage.Define( + eventId: 28, + logLevel: LogLevel.Debug, + formatString: "AuthorizationCodeReceivedContext.HandledResponse"); + _authorizationCodeReceivedContextSkipped = LoggerMessage.Define( + eventId: 29, + logLevel: LogLevel.Debug, + formatString: "AuthorizationCodeReceivedContext.Skipped"); + _tokenResponseReceived = LoggerMessage.Define( + eventId: 30, + logLevel: LogLevel.Trace, + formatString: "Token response received."); + _authorizationCodeRedeemedContextHandledResponse = LoggerMessage.Define( + eventId: 31, + logLevel: LogLevel.Debug, + formatString: "AuthorizationCodeRedeemedContext.HandledResponse"); + _authorizationCodeRedeemedContextSkipped = LoggerMessage.Define( + eventId: 32, + logLevel: LogLevel.Debug, + formatString: "AuthorizationCodeRedeemedContext.Skipped"); + _authenticationValidatedHandledResponse = LoggerMessage.Define( + eventId: 33, + logLevel: LogLevel.Debug, + formatString: "AuthenticationFailedContext.HandledResponse"); + _authenticationValidatedtSkipped = LoggerMessage.Define( + eventId: 34, + logLevel: LogLevel.Debug, + formatString: "AuthenticationFailedContext.Skipped"); + _userInformationReceived = LoggerMessage.Define( + eventId: 35, + logLevel: LogLevel.Trace, + formatString: "User information received: {User}"); + _userInformationReceivedHandledResponse = LoggerMessage.Define( + eventId: 36, + logLevel: LogLevel.Debug, + formatString: "The UserInformationReceived event returned Handled."); + _userInformationReceivedSkipped = LoggerMessage.Define( + eventId: 37, + logLevel: LogLevel.Debug, + formatString: "The UserInformationReceived event returned Skipped."); + _authenticationFailedContextHandledResponse = LoggerMessage.Define( + eventId: 38, + logLevel: LogLevel.Debug, + formatString: "AuthenticationFailedContext.HandledResponse"); + _authenticationFailedContextSkipped = LoggerMessage.Define( + eventId: 39, + logLevel: LogLevel.Debug, + formatString: "AuthenticationFailedContext.Skipped"); + _invalidSecurityTokenType = LoggerMessage.Define( + eventId: 40, + logLevel: LogLevel.Error, + formatString: "The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{SecurityTokenType}'"); + _unableToValidateIdToken = LoggerMessage.Define( + eventId: 41, + logLevel: LogLevel.Error, + formatString: "Unable to validate the 'id_token', no suitable ISecurityTokenValidator was found for: '{IdToken}'."); + _accessTokenNotAvailable = LoggerMessage.Define( + eventId: 42, + logLevel: LogLevel.Debug, + formatString: "The access_token is not available. Claims cannot be retrieved."); + _unableToReadIdToken = LoggerMessage.Define( + eventId: 43, + logLevel: LogLevel.Error, + formatString: "Unable to read the 'id_token', no suitable ISecurityTokenValidator was found for: '{IdToken}'."); + } + + public static void UpdatingConfiguration(this ILogger logger) + { + _updatingConfiguration(logger, null); + } + + public static void ConfigurationManagerRequestRefreshCalled(this ILogger logger) + { + _configurationManagerRequestRefreshCalled(logger, null); + } + + public static void AuthorizationCodeReceived(this ILogger logger) + { + _authorizationCodeReceived(logger, null); + } + + public static void TokenResponseReceived(this ILogger logger) + { + _tokenResponseReceived(logger, null); + } + + public static void ReceivedIdToken(this ILogger logger) + { + _receivedIdToken(logger, null); + } + + public static void RedeemingCodeForTokens(this ILogger logger) + { + _redeemingCodeForTokens(logger, null); + } + + public static void AuthorizationResponseReceived(this ILogger logger) + { + _authorizationResponseReceived(logger, null); + } + + public static void AuthorizationResponseReceivedHandledResponse(this ILogger logger) + { + _authorizationResponseReceivedHandledResponse(logger, null); + } + + public static void AuthorizationResponseReceivedSkipped(this ILogger logger) + { + _authorizationResponseReceivedSkipped(logger, null); + } + + public static void AuthorizationCodeReceivedContextHandledResponse(this ILogger logger) + { + _authorizationCodeReceivedContextHandledResponse(logger, null); + } + + public static void AuthorizationCodeReceivedContextSkipped(this ILogger logger) + { + _authorizationCodeReceivedContextSkipped(logger, null); + } + + public static void AuthorizationCodeRedeemedContextHandledResponse(this ILogger logger) + { + _authorizationCodeRedeemedContextHandledResponse(logger, null); + } + + public static void AuthorizationCodeRedeemedContextSkipped(this ILogger logger) + { + _authorizationCodeRedeemedContextSkipped(logger, null); + } + + public static void AuthenticationValidatedHandledResponse(this ILogger logger) + { + _authenticationValidatedHandledResponse(logger, null); + } + + public static void AuthenticationValidatedSkipped(this ILogger logger) + { + _authenticationValidatedtSkipped(logger, null); + } + + public static void AuthenticationFailedContextHandledResponse(this ILogger logger) + { + _authenticationFailedContextHandledResponse(logger, null); + } + + public static void AuthenticationFailedContextSkipped(this ILogger logger) + { + _authenticationFailedContextSkipped(logger, null); + } + + public static void MessageReceived(this ILogger logger, string redirectUrl) + { + _messageReceived(logger, redirectUrl, null); + } + + public static void MessageReceivedContextHandledResponse(this ILogger logger) + { + _messageReceivedContextHandledResponse(logger, null); + } + + public static void MessageReceivedContextSkipped(this ILogger logger) + { + _messageReceivedContextSkipped(logger, null); + } + + public static void RedirectToEndSessionEndpointHandledResponse(this ILogger logger) + { + _redirectToEndSessionEndpointHandledResponse(logger, null); + } + + public static void RedirectToEndSessionEndpointSkipped(this ILogger logger) + { + _redirectToEndSessionEndpointSkipped(logger, null); + } + + public static void RedirectToAuthenticationEndpointHandledResponse(this ILogger logger) + { + _redirectToAuthenticationEndpointHandledResponse(logger, null); + } + + public static void RedirectToAuthenticationEndpointSkipped(this ILogger logger) + { + _redirectToAuthenticationEndpointSkipped(logger, null); + } + + public static void UserInformationReceivedHandledResponse(this ILogger logger) + { + _userInformationReceivedHandledResponse(logger, null); + } + + public static void UserInformationReceivedSkipped(this ILogger logger) + { + _userInformationReceivedSkipped(logger, null); + } + + public static void InvalidLogoutQueryStringRedirectUrl(this ILogger logger, string redirectUrl) + { + _invalidLogoutQueryStringRedirectUrl(logger, redirectUrl, null); + } + + public static void NullOrEmptyAuthorizationResponseState(this ILogger logger) + { + _nullOrEmptyAuthorizationResponseState(logger, null); + } + + public static void UnableToReadAuthorizationResponseState(this ILogger logger) + { + _unableToReadAuthorizationResponseState(logger, null); + } + + public static void AuthorizationResponseError(this ILogger logger, string error, string errorDescription, string errorUri) + { + _authorizationResponseError(logger, error, errorDescription, errorUri, null); + } + + public static void ExceptionProcessingMessage(this ILogger logger, Exception ex) + { + _exceptionProcessingMessage(logger, ex); + } + + public static void AccessTokenNotAvailable(this ILogger logger) + { + _accessTokenNotAvailable(logger, null); + } + + public static void RetrievingClaims(this ILogger logger) + { + _retrievingClaims(logger, null); + } + + public static void UserInfoEndpointNotSet(this ILogger logger) + { + _userInfoEndpointNotSet(logger, null); + } + + public static void UnableToProtectNonceCookie(this ILogger logger, Exception ex) + { + _unableToProtectNonceCookie(logger, ex); + } + + public static void InvalidAuthenticationRequestUrl(this ILogger logger, string redirectUri) + { + _invalidAuthenticationRequestUrl(logger, redirectUri, null); + } + + public static void UnableToReadIdToken(this ILogger logger, string idToken) + { + _unableToReadIdToken(logger, idToken, null); + } + + public static void InvalidSecurityTokenType(this ILogger logger, string tokenType) + { + _invalidSecurityTokenType(logger, tokenType, null); + } + + public static void UnableToValidateIdToken(this ILogger logger, string idToken) + { + _unableToValidateIdToken(logger, idToken, null); + } + + public static void EnteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync(this ILogger logger, string openIdConnectHandlerTypeName) + { + _enteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync(logger, openIdConnectHandlerTypeName, null); + } + + public static void EnteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync(this ILogger logger, string openIdConnectHandlerTypeName) + { + _enteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync(logger, openIdConnectHandlerTypeName, null); + } + + public static void UserInformationReceived(this ILogger logger, string user) + { + _userInformationReceived(logger, user, null); + } + + public static void PostAuthenticationLocalRedirect(this ILogger logger, string redirectUri) + { + _postAuthenticationLocalRedirect(logger, redirectUri, null); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 9c157e57bf..5c534696b8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -114,12 +114,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect await Options.Events.RedirectToEndSessionEndpoint(redirectContext); if (redirectContext.HandledResponse) { - Logger.LogDebug(1, "RedirectToEndSessionEndpoint.HandledResponse"); + Logger.RedirectToEndSessionEndpointHandledResponse(); return; } else if (redirectContext.Skipped) { - Logger.LogDebug(2, "RedirectToEndSessionEndpoint.Skipped"); + Logger.RedirectToEndSessionEndpointSkipped(); return; } @@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var redirectUri = message.CreateLogoutRequestUrl(); if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) { - Logger.LogWarning(3, "The query string for Logout is not a well-formed URI. Redirect URI: '{0}'.", redirectUri); + Logger.InvalidLogoutQueryStringRedirectUrl(redirectUri); } Response.Redirect(redirectUri); @@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect throw new ArgumentNullException(nameof(context)); } - Logger.LogTrace(4, "Entering {0}." + nameof(HandleUnauthorizedAsync), GetType()); + Logger.EnteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync(GetType().FullName); // order for local RedirectUri // 1. challenge.Properties.RedirectUri @@ -191,7 +191,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { properties.RedirectUri = CurrentUri; } - Logger.LogTrace(5, "Using properties.RedirectUri for 'local redirect' post authentication: '{0}'.", properties.RedirectUri); + Logger.PostAuthenticationLocalRedirect(properties.RedirectUri); if (_configuration == null && Options.ConfigurationManager != null) { @@ -233,12 +233,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect await Options.Events.RedirectToAuthenticationEndpoint(redirectContext); if (redirectContext.HandledResponse) { - Logger.LogDebug(6, "RedirectToAuthenticationEndpoint.HandledResponse"); + Logger.RedirectToAuthenticationEndpointHandledResponse(); return true; } else if (redirectContext.Skipped) { - Logger.LogDebug(7, "RedirectToAuthenticationEndpoint.Skipped"); + Logger.RedirectToAuthenticationEndpointSkipped(); return false; } @@ -259,7 +259,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var redirectUri = message.CreateAuthenticationRequestUrl(); if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) { - Logger.LogWarning(9, "The redirect URI is not well-formed. The URI is: '{0}'.", redirectUri); + Logger.InvalidAuthenticationRequestUrl(redirectUri); } Response.Redirect(redirectUri); @@ -303,7 +303,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// An if successful. protected override async Task HandleRemoteAuthenticateAsync() { - Logger.LogTrace(10, "Entering: {0}." + nameof(HandleRemoteAuthenticateAsync), GetType()); + Logger.EnteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync(GetType().FullName); OpenIdConnectMessage authorizationResponse = null; @@ -361,7 +361,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (string.IsNullOrEmpty(authorizationResponse.State)) { // This wasn't a valid OIDC message, it may not have been intended for us. - Logger.LogDebug(11, "message.State is null or empty."); + Logger.NullOrEmptyAuthorizationResponseState(); if (Options.SkipUnrecognizedRequests) { return AuthenticateResult.Skip(); @@ -373,7 +373,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var properties = Options.StateDataFormat.Unprotect(Uri.UnescapeDataString(authorizationResponse.State)); if (properties == null) { - Logger.LogDebug(12, "Unable to read the message.State."); + Logger.UnableToReadAuthorizationResponseState(); if (Options.SkipUnrecognizedRequests) { // Not for us? @@ -385,7 +385,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // if any of the error fields are set, throw error null if (!string.IsNullOrEmpty(authorizationResponse.Error)) { - Logger.LogError(13, "Message contains error: '{0}', error_description: '{1}', error_uri: '{2}'.", authorizationResponse.Error, authorizationResponse.ErrorDescription ?? "ErrorDecription null", authorizationResponse.ErrorUri ?? "ErrorUri null"); + Logger.AuthorizationResponseError( + authorizationResponse.Error, + authorizationResponse.ErrorDescription ?? "ErrorDecription null", + authorizationResponse.ErrorUri ?? "ErrorUri null"); + return AuthenticateResult.Fail(new OpenIdConnectProtocolException(string.Format(CultureInfo.InvariantCulture, Resources.MessageContainsError, authorizationResponse.Error, authorizationResponse.ErrorDescription ?? "ErrorDecription null", authorizationResponse.ErrorUri ?? "ErrorUri null"))); } @@ -400,7 +404,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (_configuration == null && Options.ConfigurationManager != null) { - Logger.LogDebug(14, "Updating configuration"); + Logger.UpdatingConfiguration(); _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); } @@ -422,7 +426,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // Hybrid or Implicit flow if (!string.IsNullOrEmpty(authorizationResponse.IdToken)) { - Logger.LogDebug(23, "'id_token' received."); + Logger.ReceivedIdToken(); ticket = ValidateToken(authorizationResponse.IdToken, properties, validationParameters, out jwt); nonce = jwt?.Payload.Nonce; @@ -525,14 +529,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } catch (Exception exception) { - Logger.LogError(19, "Exception occurred while processing message.", exception); + Logger.ExceptionProcessingMessage(exception); // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the event. if (Options.RefreshOnIssuerKeyNotFound && exception.GetType().Equals(typeof(SecurityTokenSignatureKeyNotFoundException))) { if (Options.ConfigurationManager != null) { - Logger.LogDebug(20, "exception of type 'SecurityTokenSignatureKeyNotFoundException' thrown, Options.ConfigurationManager.RequestRefresh() called."); + Logger.ConfigurationManagerRequestRefreshCalled(); Options.ConfigurationManager.RequestRefresh(); } } @@ -583,7 +587,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// OpenIdConnect message that has tokens inside it. protected virtual async Task RedeemAuthorizationCodeAsync(OpenIdConnectMessage tokenEndpointRequest) { - Logger.LogDebug(21, "Redeeming code for tokens."); + Logger.RedeemingCodeForTokens(); var requestMessage = new HttpRequestMessage(HttpMethod.Post, _configuration.TokenEndpoint); requestMessage.Content = new FormUrlEncodedContent(tokenEndpointRequest.Parameters); var responseMessage = await Backchannel.SendAsync(requestMessage); @@ -606,16 +610,15 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (string.IsNullOrEmpty(userInfoEndpoint)) { - Logger.LogDebug(24, $"{nameof(_configuration.UserInfoEndpoint)} is not set. Claims cannot be retrieved."); + Logger.UserInfoEndpointNotSet(); return AuthenticateResult.Success(ticket); } if (string.IsNullOrEmpty(message.AccessToken)) { - Logger.LogDebug(47, "The access_token is not available. Claims cannot be retrieved."); + Logger.AccessTokenNotAvailable(); return AuthenticateResult.Success(ticket); } - Logger.LogTrace(22, "Retrieving claims from the user info endpoint."); - + Logger.RetrievingClaims(); var requestMessage = new HttpRequestMessage(HttpMethod.Get, userInfoEndpoint); requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", message.AccessToken); var responseMessage = await Backchannel.SendAsync(requestMessage); @@ -789,7 +792,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } catch (Exception ex) { - Logger.LogWarning(25, "Failed to un-protect the nonce cookie.", ex); + Logger.UnableToProtectNonceCookie(ex); } } } @@ -829,7 +832,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private async Task RunMessageReceivedEventAsync(OpenIdConnectMessage message) { - Logger.LogTrace(29, "MessageReceived: '{0}'", message.BuildRedirectUrl()); + Logger.MessageReceived(message.BuildRedirectUrl()); var messageReceivedContext = new MessageReceivedContext(Context, Options) { ProtocolMessage = message @@ -838,11 +841,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect await Options.Events.MessageReceived(messageReceivedContext); if (messageReceivedContext.HandledResponse) { - Logger.LogDebug(30, "MessageReceivedContext.HandledResponse"); + Logger.MessageReceivedContextHandledResponse(); } else if (messageReceivedContext.Skipped) { - Logger.LogDebug(31, "MessageReceivedContext.Skipped"); + Logger.MessageReceivedContextSkipped(); } return messageReceivedContext; @@ -850,7 +853,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private async Task RunAuthorizationResponseReceivedEventAsync(OpenIdConnectMessage message, AuthenticationProperties properties) { - Logger.LogTrace(15, "Authorization response received."); + Logger.AuthorizationResponseReceived(); var authorizationResponseReceivedContext = new AuthorizationResponseReceivedContext(Context, Options, properties) { ProtocolMessage = message @@ -858,18 +861,18 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect await Options.Events.AuthorizationResponseReceived(authorizationResponseReceivedContext); if (authorizationResponseReceivedContext.HandledResponse) { - Logger.LogDebug(16, "AuthorizationResponseReceived.HandledResponse"); + Logger.AuthorizationResponseReceivedHandledResponse(); } else if (authorizationResponseReceivedContext.Skipped) { - Logger.LogDebug(17, "AuthorizationResponseReceived.Skipped"); + Logger.AuthorizationResponseReceivedSkipped(); } return authorizationResponseReceivedContext; } private async Task RunAuthorizationCodeReceivedEventAsync(OpenIdConnectMessage authorizationResponse, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt) { - Logger.LogTrace(32, "AuthorizationCode received"); + Logger.AuthorizationCodeReceived(); var tokenEndpointRequest = new OpenIdConnectMessage() { @@ -893,11 +896,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect await Options.Events.AuthorizationCodeReceived(authorizationCodeReceivedContext); if (authorizationCodeReceivedContext.HandledResponse) { - Logger.LogDebug(33, "AuthorizationCodeReceivedContext.HandledResponse"); + Logger.AuthorizationCodeReceivedContextHandledResponse(); } else if (authorizationCodeReceivedContext.Skipped) { - Logger.LogDebug(34, "AuthorizationCodeReceivedContext.Skipped"); + Logger.AuthorizationCodeReceivedContextSkipped(); } return authorizationCodeReceivedContext; @@ -905,7 +908,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private async Task RunTokenResponseReceivedEventAsync(OpenIdConnectMessage message, OpenIdConnectMessage tokenEndpointResponse, AuthenticationProperties properties) { - Logger.LogTrace(35, "Token response received."); + Logger.TokenResponseReceived(); + var tokenResponseReceivedContext = new TokenResponseReceivedContext(Context, Options, properties) { ProtocolMessage = message, @@ -915,12 +919,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect await Options.Events.TokenResponseReceived(tokenResponseReceivedContext); if (tokenResponseReceivedContext.HandledResponse) { - Logger.LogDebug(36, "AuthorizationCodeRedeemedContext.HandledResponse"); + Logger.AuthorizationCodeRedeemedContextHandledResponse(); } else if (tokenResponseReceivedContext.Skipped) { - Logger.LogDebug(37, "AuthorizationCodeRedeemedContext.Skipped"); + Logger.AuthorizationCodeRedeemedContextSkipped(); } + return tokenResponseReceivedContext; } @@ -936,11 +941,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect await Options.Events.AuthenticationValidated(authenticationValidatedContext); if (authenticationValidatedContext.HandledResponse) { - Logger.LogDebug(38, "AuthenticationValidated.HandledResponse"); + Logger.AuthenticationValidatedHandledResponse(); } else if (authenticationValidatedContext.Skipped) { - Logger.LogDebug(39, "AuthenticationValidated.Skipped"); + Logger.AuthenticationValidatedSkipped(); } return authenticationValidatedContext; @@ -948,7 +953,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private async Task RunUserInformationReceivedEventAsync(AuthenticationTicket ticket, OpenIdConnectMessage message, JObject user) { - Logger.LogTrace(40, "User information received: {0}", user.ToString()); + Logger.UserInformationReceived(user.ToString()); var userInformationReceivedContext = new UserInformationReceivedContext(Context, Options) { @@ -960,11 +965,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect await Options.Events.UserInformationReceived(userInformationReceivedContext); if (userInformationReceivedContext.HandledResponse) { - Logger.LogDebug(41, "The UserInformationReceived event returned Handled."); + Logger.UserInformationReceivedHandledResponse(); } else if (userInformationReceivedContext.Skipped) { - Logger.LogDebug(42, "The UserInformationReceived event returned Skipped."); + Logger.UserInformationReceivedSkipped(); } return userInformationReceivedContext; @@ -981,11 +986,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect await Options.Events.AuthenticationFailed(authenticationFailedContext); if (authenticationFailedContext.HandledResponse) { - Logger.LogDebug(43, "AuthenticationFailedContext.HandledResponse"); + Logger.AuthenticationFailedContextHandledResponse(); } else if (authenticationFailedContext.Skipped) { - Logger.LogDebug(44, "AuthenticationFailedContext.Skipped"); + Logger.AuthenticationFailedContextSkipped(); } return authenticationFailedContext; @@ -995,7 +1000,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { if (!Options.SecurityTokenValidator.CanReadToken(idToken)) { - Logger.LogError(48, "Unable to read the 'id_token', no suitable ISecurityTokenValidator was found for: '{0}'.", idToken); + Logger.UnableToReadIdToken(idToken); throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.UnableToValidateToken, idToken)); } @@ -1018,13 +1023,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect jwt = validatedToken as JwtSecurityToken; if (jwt == null) { - Logger.LogError(45, "The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{0}'", validatedToken?.GetType()); + Logger.InvalidSecurityTokenType(validatedToken?.GetType().ToString()); throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.ValidatedSecurityTokenNotJwt, validatedToken?.GetType())); } if (validatedToken == null) { - Logger.LogError(46, "Unable to validate the 'id_token', no suitable ISecurityTokenValidator was found for: '{0}'.", idToken); + Logger.UnableToValidateIdToken(idToken); throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.UnableToValidateToken, idToken)); } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs new file mode 100644 index 0000000000..21a4ac541d --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _obtainRequestToken; + private static Action _obtainAccessToken; + + static LoggingExtensions() + { + _obtainRequestToken = LoggerMessage.Define( + eventId: 1, + logLevel: LogLevel.Debug, + formatString: "ObtainRequestToken"); + _obtainAccessToken = LoggerMessage.Define( + eventId: 2, + logLevel: LogLevel.Debug, + formatString: "ObtainAccessToken"); + + } + + public static void ObtainAccessToken(this ILogger logger) + { + _obtainAccessToken(logger, null); + } + + public static void ObtainRequestToken(this ILogger logger) + { + _obtainRequestToken(logger, null); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index d856a9b845..d7383e9393 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter private async Task ObtainRequestTokenAsync(string consumerKey, string consumerSecret, string callBackUri, AuthenticationProperties properties) { - Logger.LogDebug("ObtainRequestToken"); + Logger.ObtainRequestToken(); var nonce = Guid.NewGuid().ToString("N"); @@ -216,7 +216,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { // https://dev.twitter.com/docs/api/1/post/oauth/access_token - Logger.LogDebug("ObtainAccessToken"); + Logger.ObtainAccessToken(); var nonce = Guid.NewGuid().ToString("N"); diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index f50fd3dbbd..ebb25af212 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -104,13 +104,13 @@ namespace Microsoft.AspNetCore.Authentication var result = await HandleAuthenticateOnceAsync(); if (result.Failure != null) { - Logger.LogInformation(0, $"{Options.AuthenticationScheme} not authenticated: " + result.Failure.Message); + Logger.AuthenticationSchemeNotAuthenticatedWithFailure(Options.AuthenticationScheme, result.Failure.Message); } var ticket = result?.Ticket; if (ticket?.Principal != null) { Context.User = SecurityHelper.MergeUserPrincipal(Context.User, ticket.Principal); - Logger.LogInformation(0, "HttpContext.User merged via AutomaticAuthentication from authenticationScheme: {scheme}.", Options.AuthenticationScheme); + Logger.UserPrinicpalMerged(Options.AuthenticationScheme); } } } @@ -171,7 +171,7 @@ namespace Microsoft.AspNetCore.Authentication /// /// Called once by common code after initialization. If an authentication middleware responds directly to - /// specifically known paths it must override this virtual, compare the request path to it's known paths, + /// specifically known paths it must override this virtual, compare the request path to it's known paths, /// provide any response information as appropriate, and true to stop further processing. /// /// Returning false will cause the common code to call the next middleware in line. Returning true will @@ -203,7 +203,7 @@ namespace Microsoft.AspNetCore.Authentication var handled = false; if (ShouldHandleScheme(context.AuthenticationScheme, Options.AutomaticAuthenticate)) { - // Calling Authenticate more than once should always return the original value. + // Calling Authenticate more than once should always return the original value. var result = await HandleAuthenticateOnceAsync(); if (result?.Failure != null) @@ -216,13 +216,13 @@ namespace Microsoft.AspNetCore.Authentication if (ticket?.Principal != null) { context.Authenticated(ticket.Principal, ticket.Properties.Items, Options.Description.Items); - Logger.LogInformation(1, "AuthenticationScheme: {scheme} was successfully authenticated.", Options.AuthenticationScheme); + Logger.AuthenticationSchemeAuthenticated(Options.AuthenticationScheme); handled = true; } else { context.NotAuthenticated(); - Logger.LogDebug(2, "AuthenticationScheme: {scheme} was not authenticated.", Options.AuthenticationScheme); + Logger.AuthenticationSchemeNotAuthenticated(Options.AuthenticationScheme); } } } @@ -250,7 +250,7 @@ namespace Microsoft.AspNetCore.Authentication { SignInAccepted = true; await HandleSignInAsync(context); - Logger.LogInformation(3, "AuthenticationScheme: {scheme} signed in.", Options.AuthenticationScheme); + Logger.AuthenticationSchemeSignedIn(Options.AuthenticationScheme); context.Accept(); } else if (PriorHandler != null) @@ -270,7 +270,7 @@ namespace Microsoft.AspNetCore.Authentication { SignOutAccepted = true; await HandleSignOutAsync(context); - Logger.LogInformation(4, "AuthenticationScheme: {scheme} signed out.", Options.AuthenticationScheme); + Logger.AuthenticationSchemeSignedOut(Options.AuthenticationScheme); context.Accept(); } else if (PriorHandler != null) @@ -321,11 +321,11 @@ namespace Microsoft.AspNetCore.Authentication goto case ChallengeBehavior.Unauthorized; case ChallengeBehavior.Unauthorized: handled = await HandleUnauthorizedAsync(context); - Logger.LogInformation(5, "AuthenticationScheme: {scheme} was challenged.", Options.AuthenticationScheme); + Logger.AuthenticationSchemeChallenged(Options.AuthenticationScheme); break; case ChallengeBehavior.Forbidden: handled = await HandleForbiddenAsync(context); - Logger.LogInformation(6, "AuthenticationScheme: {scheme} was forbidden.", Options.AuthenticationScheme); + Logger.AuthenticationSchemeForbidden(Options.AuthenticationScheme); break; } context.Accept(); diff --git a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs new file mode 100644 index 0000000000..49fc8db050 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -0,0 +1,175 @@ +// 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.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _authSchemeAuthenticated; + private static Action _authSchemeNotAuthenticated; + private static Action _authSchemeNotAuthenticatedWithFailure; + private static Action _authSchemeSignedIn; + private static Action _authSchemeSignedOut; + private static Action _authSchemeChallenged; + private static Action _authSchemeForbidden; + private static Action _userAuthorizationFailed; + private static Action _userAuthorizationSucceeded; + private static Action _userPrincipalMerged; + private static Action _remoteAuthenticationError; + private static Action _signInHandled; + private static Action _signInSkipped; + private static Action _correlationPropertyNotFound; + private static Action _correlationCookieNotFound; + private static Action _unexpectedCorrelationCookieValue; + + static LoggingExtensions() + { + _userAuthorizationSucceeded = LoggerMessage.Define( + eventId: 1, + logLevel: LogLevel.Information, + formatString: "Authorization was successful for user: {UserName}."); + _userAuthorizationFailed = LoggerMessage.Define( + eventId: 2, + logLevel: LogLevel.Information, + formatString: "Authorization failed for user: {UserName}."); + _userPrincipalMerged = LoggerMessage.Define( + eventId: 3, + logLevel: LogLevel.Information, + formatString: "HttpContext.User merged via AutomaticAuthentication from authenticationScheme: {AuthenticationScheme}."); + _remoteAuthenticationError = LoggerMessage.Define( + eventId: 4, + logLevel: LogLevel.Information, + formatString: "Error from RemoteAuthentication: {ErrorMessage}."); + _signInHandled = LoggerMessage.Define( + eventId: 5, + logLevel: LogLevel.Debug, + formatString: "The SigningIn event returned Handled."); + _signInSkipped = LoggerMessage.Define( + eventId: 6, + logLevel: LogLevel.Debug, + formatString: "The SigningIn event returned Skipped."); + _authSchemeNotAuthenticatedWithFailure = LoggerMessage.Define( + eventId: 7, + logLevel: LogLevel.Information, + formatString: "{AuthenticationScheme} was not authenticated. Failure message: {FailureMessage}"); + _authSchemeAuthenticated = LoggerMessage.Define( + eventId: 8, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} was successfully authenticated."); + _authSchemeNotAuthenticated = LoggerMessage.Define( + eventId: 9, + logLevel: LogLevel.Debug, + formatString: "AuthenticationScheme: {AuthenticationScheme} was not authenticated."); + _authSchemeSignedIn = LoggerMessage.Define( + eventId: 10, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} signed in."); + _authSchemeSignedOut = LoggerMessage.Define( + eventId: 11, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); + _authSchemeChallenged = LoggerMessage.Define( + eventId: 12, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} was challenged."); + _authSchemeForbidden = LoggerMessage.Define( + eventId: 13, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} was forbidden."); + _correlationPropertyNotFound = LoggerMessage.Define( + eventId: 14, + logLevel: LogLevel.Warning, + formatString: "{CorrelationProperty} state property not found."); + _correlationCookieNotFound = LoggerMessage.Define( + eventId: 15, + logLevel: LogLevel.Warning, + formatString: "'{CorrelationCookieName}' cookie not found."); + _unexpectedCorrelationCookieValue = LoggerMessage.Define( + eventId: 16, + logLevel: LogLevel.Warning, + formatString: "The correlation cookie value '{CorrelationCookieName}' did not match the expected value '{CorrelationCookieValue}'."); + } + + public static void AuthenticationSchemeAuthenticated(this ILogger logger, string authenticationScheme) + { + _authSchemeAuthenticated(logger, authenticationScheme, null); + } + + public static void AuthenticationSchemeNotAuthenticated(this ILogger logger, string authenticationScheme) + { + _authSchemeNotAuthenticated(logger, authenticationScheme, null); + } + + public static void AuthenticationSchemeNotAuthenticatedWithFailure(this ILogger logger, string authenticationScheme, string failureMessage) + { + _authSchemeNotAuthenticatedWithFailure(logger, authenticationScheme, failureMessage, null); + } + + public static void AuthenticationSchemeSignedIn(this ILogger logger, string authenticationScheme) + { + _authSchemeSignedIn(logger, authenticationScheme, null); + } + + public static void AuthenticationSchemeSignedOut(this ILogger logger, string authenticationScheme) + { + _authSchemeSignedOut(logger, authenticationScheme, null); + } + + public static void AuthenticationSchemeChallenged(this ILogger logger, string authenticationScheme) + { + _authSchemeChallenged(logger, authenticationScheme, null); + } + + public static void AuthenticationSchemeForbidden(this ILogger logger, string authenticationScheme) + { + _authSchemeForbidden(logger, authenticationScheme, null); + } + + public static void UserAuthorizationSucceeded(this ILogger logger, string userName) + { + _userAuthorizationSucceeded(logger, userName, null); + } + + public static void UserAuthorizationFailed(this ILogger logger, string userName) + { + _userAuthorizationFailed(logger, userName, null); + } + + public static void UserPrinicpalMerged(this ILogger logger, string authenticationScheme) + { + _userPrincipalMerged(logger, authenticationScheme, null); + } + + public static void RemoteAuthenticationError(this ILogger logger, string errorMessage) + { + _remoteAuthenticationError(logger, errorMessage, null); + } + + public static void SigninHandled(this ILogger logger) + { + _signInHandled(logger, null); + } + + public static void SigninSkipped(this ILogger logger) + { + _signInSkipped(logger, null); + } + + public static void CorrelationPropertyNotFound(this ILogger logger, string correlationPrefix) + { + _correlationPropertyNotFound(logger, correlationPrefix, null); + } + + public static void CorrelationCookieNotFound(this ILogger logger, string cookieName) + { + _correlationCookieNotFound(logger, cookieName, null); + } + + public static void UnexpectedCorrelationCookieValue(this ILogger logger, string cookieName, string cookieValue) + { + _unexpectedCorrelationCookieValue(logger, cookieName, cookieValue, null); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index bf64109a2c..d6cc4ce7fc 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Authentication if (authResult == null || !authResult.Succeeded) { var errorContext = new FailureContext(Context, authResult?.Failure ?? new Exception("Invalid return state, unable to redirect.")); - Logger.LogInformation("Error from RemoteAuthentication: " + errorContext.Failure.Message); + Logger.RemoteAuthenticationError(errorContext.Failure.Message); await Options.Events.RemoteFailure(errorContext); if (errorContext.HandledResponse) { @@ -66,12 +66,12 @@ namespace Microsoft.AspNetCore.Authentication if (context.HandledResponse) { - Logger.LogDebug("The SigningIn event returned Handled."); + Logger.SigninHandled(); return true; } else if (context.Skipped) { - Logger.LogDebug("The SigningIn event returned Skipped."); + Logger.SigninSkipped(); return false; } @@ -144,7 +144,7 @@ namespace Microsoft.AspNetCore.Authentication string correlationId; if (!properties.Items.TryGetValue(CorrelationProperty, out correlationId)) { - Logger.LogWarning(26, "{0} state property not found.", CorrelationPrefix); + Logger.CorrelationPropertyNotFound(CorrelationPrefix); return false; } @@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.Authentication var correlationCookie = Request.Cookies[cookieName]; if (string.IsNullOrEmpty(correlationCookie)) { - Logger.LogWarning(27, "'{0}' cookie not found.", cookieName); + Logger.CorrelationCookieNotFound(cookieName); return false; } @@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Authentication if (!string.Equals(correlationCookie, CorrelationMarker, StringComparison.Ordinal)) { - Logger.LogWarning(28, "The correlation cookie value '{0}' did not match the expected value '{1}'.", cookieName); + Logger.UnexpectedCorrelationCookieValue(cookieName, correlationCookie); return false; } diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index c5bdcc7a76..7d46ac8b82 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -51,12 +51,12 @@ namespace Microsoft.AspNetCore.Authorization if (authContext.HasSucceeded) { - _logger.LogInformation(0, "Authorization was successful for user: {userName}.", user?.Identity?.Name); + _logger.UserAuthorizationSucceeded(user?.Identity?.Name); return true; } else { - _logger.LogInformation(1, "Authorization failed for user: {userName}.", user?.Identity?.Name); + _logger.UserAuthorizationFailed(user?.Identity?.Name); return false; } } diff --git a/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs new file mode 100644 index 0000000000..1d524dd74e --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs @@ -0,0 +1,35 @@ +// 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.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _userAuthorizationFailed; + private static Action _userAuthorizationSucceeded; + + static LoggingExtensions() + { + _userAuthorizationSucceeded = LoggerMessage.Define( + eventId: 1, + logLevel: LogLevel.Information, + formatString: "Authorization was successful for user: {UserName}."); + _userAuthorizationFailed = LoggerMessage.Define( + eventId: 2, + logLevel: LogLevel.Information, + formatString: "Authorization failed for user: {UserName}."); + } + + public static void UserAuthorizationSucceeded(this ILogger logger, string userName) + { + _userAuthorizationSucceeded(logger, userName, null); + } + + public static void UserAuthorizationFailed(this ILogger logger, string userName) + { + _userAuthorizationFailed(logger, userName, null); + } + } +} From a2aa94c4240607d982d6e8e94145f74756ffe662 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 22 Mar 2016 11:53:20 -0700 Subject: [PATCH 502/900] Reacting to Hosting changes --- samples/CookieSample/Startup.cs | 2 +- samples/CookieSessionSample/Startup.cs | 2 +- samples/JwtBearerSample/Startup.cs | 2 +- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- samples/OpenIdConnectSample/Startup.cs | 2 +- samples/SocialSample/Startup.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 8b0568b313..043664f1dc 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -45,7 +45,7 @@ namespace CookieSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultConfiguration(args) + .UseDefaultHostingConfiguration(args) .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 3db8f11556..71da6aa1f5 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -55,7 +55,7 @@ namespace CookieSessionSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultConfiguration(args) + .UseDefaultHostingConfiguration(args) .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 3a4ecfba6c..1df7e11a39 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -115,7 +115,7 @@ namespace JwtBearerSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultConfiguration(args) + .UseDefaultHostingConfiguration(args) .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index c5ddafd5ff..f2f9489bf5 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -159,7 +159,7 @@ namespace OpenIdConnect.AzureAdSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultConfiguration(args) + .UseDefaultHostingConfiguration(args) .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index ddcf9fa2b2..ff156a77fb 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -105,7 +105,7 @@ namespace OpenIdConnectSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultConfiguration(args) + .UseDefaultHostingConfiguration(args) .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 358a031cd3..e9c7f6141d 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -342,7 +342,7 @@ namespace SocialSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultConfiguration(args) + .UseDefaultHostingConfiguration(args) .UseServer("Microsoft.AspNetCore.Server.Kestrel") .UseIISPlatformHandlerUrl() .UseStartup() From 6a0e58e3ffba30096f64eecba51ca6650ba0e6ae Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 25 Mar 2016 02:46:34 -0700 Subject: [PATCH 503/900] Fixed build --- test/Microsoft.AspNetCore.Authentication.Test/project.json | 5 +++-- test/Microsoft.AspNetCore.Authorization.Test/project.json | 5 +++-- test/Microsoft.AspNetCore.CookiePolicy.Test/project.json | 5 +++-- test/Microsoft.Owin.Security.Interop.Test/project.json | 1 - 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index c05a8963b7..07137861a4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -12,13 +12,14 @@ "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.AspNetCore.Testing": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0" }, "frameworks": { "netstandardapp1.5": { "dependencies": { - "dotnet-test-xunit": "1.0.0-dev-*" + "dotnet-test-xunit": "1.0.0-dev-*", + "NETStandard.Library": "1.5.0-*", + "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ "dnxcore50", diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 560766c038..0bc8910ce9 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -7,13 +7,14 @@ "Microsoft.AspNetCore.Testing": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", "Microsoft.Extensions.Logging": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0" }, "frameworks": { "netstandardapp1.5": { "dependencies": { - "dotnet-test-xunit": "1.0.0-dev-*" + "dotnet-test-xunit": "1.0.0-dev-*", + "NETStandard.Library": "1.5.0-*", + "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ "dnxcore50", diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index f6dad148ab..8d529ea87c 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -6,13 +6,14 @@ "Microsoft.AspNetCore.CookiePolicy": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0" }, "frameworks": { "netstandardapp1.5": { "dependencies": { - "dotnet-test-xunit": "1.0.0-dev-*" + "dotnet-test-xunit": "1.0.0-dev-*", + "NETStandard.Library": "1.5.0-*", + "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ "dnxcore50", diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index ae53f6e2f7..0f156822df 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -8,7 +8,6 @@ "Microsoft.Owin.Security.Cookies": "3.0.1", "Microsoft.Owin.Security.Interop": "1.0.0-*", "Microsoft.Owin.Testing": "3.0.1", - "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0", "xunit.runner.console": "2.1.0" }, From 3f596108aac3d8fc7fb40d39e19a7f897a90c198 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 15 Mar 2016 15:19:25 -0700 Subject: [PATCH 504/900] #690 OIDC & JWT event refactoring. --- .../Properties/launchSettings.json | 2 +- samples/JwtBearerSample/Startup.cs | 6 +- samples/JwtBearerSample/project.json | 6 +- .../Properties/launchSettings.json | 2 +- .../OpenIdConnect.AzureAdSample/Startup.cs | 5 +- .../OpenIdConnect.AzureAdSample/project.json | 3 + .../Properties/launchSettings.json | 2 +- samples/OpenIdConnectSample/Startup.cs | 5 +- samples/OpenIdConnectSample/project.json | 5 +- .../Events/IJwtBearerEvents.cs | 9 +- .../Events/JwtBearerEvents.cs | 15 +- ...enContext.cs => MessageReceivedContext.cs} | 4 +- .../Events/ReceivedTokenContext.cs | 18 -- .../Events/TokenValidatedContext.cs | 7 +- .../JwtBearerHandler.cs | 63 ++---- .../JwtBearerOptions.cs | 2 + .../AuthorizationResponseReceivedContext.cs | 20 -- .../Events/IOpenIdConnectEvents.cs | 19 +- .../Events/MessageReceivedContext.cs | 3 + .../Events/OpenIdConnectEvents.cs | 29 +-- ...tedContext.cs => TokenValidatedContext.cs} | 18 +- .../LoggingExtensions.cs | 110 ++++----- .../OpenIdConnectHandler.cs | 210 ++++++++---------- .../Events/BaseControlContext.cs | 16 ++ .../JwtBearer/JwtBearerMiddlewareTests.cs | 181 +++------------ .../OpenIdConnectMiddlewareTests.cs | 8 +- 26 files changed, 278 insertions(+), 490 deletions(-) rename src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/{ReceivingTokenContext.cs => MessageReceivedContext.cs} (79%) delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivedTokenContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs rename src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/{AuthenticationValidatedContext.cs => TokenValidatedContext.cs} (52%) diff --git a/samples/JwtBearerSample/Properties/launchSettings.json b/samples/JwtBearerSample/Properties/launchSettings.json index af63bba52f..49cbac543a 100644 --- a/samples/JwtBearerSample/Properties/launchSettings.json +++ b/samples/JwtBearerSample/Properties/launchSettings.json @@ -12,7 +12,7 @@ "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { - "ASPNET_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development" } }, "web": { diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 1df7e11a39..78e6d0f406 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -61,8 +61,6 @@ namespace JwtBearerSample app.UseJwtBearerAuthentication(new JwtBearerOptions { - AutomaticAuthenticate = true, - AutomaticChallenge = true, // You also need to update /wwwroot/app/scripts/app.js Authority = Configuration["jwt:authority"], Audience = Configuration["jwt:audience"] @@ -74,14 +72,14 @@ namespace JwtBearerSample // Use this if options.AutomaticAuthenticate = false // var user = await context.Authentication.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme); - var user = context.User; // We can do this because of options.AutomaticAuthenticate = true; above. + var user = context.User; // We can do this because of options.AutomaticAuthenticate = true; if (user?.Identity?.IsAuthenticated ?? false) { await next(); } else { - // We can do this because of options.AutomaticChallenge = true; above + // We can do this because of options.AutomaticChallenge = true; await context.Authentication.ChallengeAsync(); } }); diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 0f6a6c9df5..a271c2b5c7 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -15,7 +15,7 @@ "web": "JwtBearerSample" }, "frameworks": { - "dnx451": {}, + "dnx451": { }, "netstandardapp1.5": { "imports": [ "dnxcore50" @@ -30,5 +30,9 @@ "**.user", "**.vspscc" ], + "content": [ + "project.json", + "wwwroot" + ], "userSecretsId": "aspnet5-JwtBearerSample-20151210102827" } \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json index 22d7eec72e..49cbac543a 100644 --- a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json +++ b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json @@ -12,7 +12,7 @@ "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { - "Hosting:Environment": "Development" + "ASPNETCORE_ENVIRONMENT": "Development" } }, "web": { diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index f2f9489bf5..3bbae57b4a 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -64,10 +64,7 @@ namespace OpenIdConnect.AzureAdSample app.UseIISPlatformHandler(); - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AutomaticAuthenticate = true - }); + app.UseCookieAuthentication(new CookieAuthenticationOptions()); var clientId = Configuration["oidc:clientid"]; var clientSecret = Configuration["oidc:clientsecret"]; diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index a25fc16613..fd74610190 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -18,5 +18,8 @@ "commands": { "web": "OpenIdConnect.AzureAdSample" }, + "content": [ + "project.json" + ], "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" } \ No newline at end of file diff --git a/samples/OpenIdConnectSample/Properties/launchSettings.json b/samples/OpenIdConnectSample/Properties/launchSettings.json index c75dba9f49..5a0163016a 100644 --- a/samples/OpenIdConnectSample/Properties/launchSettings.json +++ b/samples/OpenIdConnectSample/Properties/launchSettings.json @@ -12,7 +12,7 @@ "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { - "ASPNET_ENV": "Development" + "ASPNETCORE_ENVIRONMENT": "Development" } }, "web": { diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index ff156a77fb..bad559aa22 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -59,10 +59,7 @@ namespace OpenIdConnectSample app.UseIISPlatformHandler(); - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AutomaticAuthenticate = true - }); + app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions { diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 12d88dfed1..4fd829a22c 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -9,7 +9,7 @@ "Microsoft.NETCore.Platforms": "1.0.1-*" }, "frameworks": { - "dnx451": {}, + "dnx451": { }, "netstandardapp1.5": { "imports": [ "dnxcore50" @@ -22,5 +22,8 @@ "commands": { "web": "OpenIdConnectSample" }, + "content": [ + "project.json" + ], "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs index 2e023db130..a7b8aeb552 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs @@ -18,17 +18,12 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// /// Invoked when a protocol message is first received. /// - Task ReceivingToken(ReceivingTokenContext context); - - /// - /// Invoked with the security token that has been extracted from the protocol message. - /// - Task ReceivedToken(ReceivedTokenContext context); + Task MessageReceived(MessageReceivedContext context); /// /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. /// - Task ValidatedToken(ValidatedTokenContext context); + Task TokenValidated(TokenValidatedContext context); /// /// Invoked to apply a challenge sent back to the caller. diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs index a14f238078..38a877f668 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -19,17 +19,12 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// /// Invoked when a protocol message is first received. /// - public Func OnReceivingToken { get; set; } = context => Task.FromResult(0); - - /// - /// Invoked with the security token that has been extracted from the protocol message. - /// - public Func OnReceivedToken { get; set; } = context => Task.FromResult(0); + public Func OnMessageReceived { get; set; } = context => Task.FromResult(0); /// /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. /// - public Func OnValidatedToken { get; set; } = context => Task.FromResult(0); + public Func OnTokenValidated { get; set; } = context => Task.FromResult(0); /// /// Invoked before a challenge is sent back to the caller. @@ -38,11 +33,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); - public virtual Task ReceivingToken(ReceivingTokenContext context) => OnReceivingToken(context); + public virtual Task MessageReceived(MessageReceivedContext context) => OnMessageReceived(context); - public virtual Task ReceivedToken(ReceivedTokenContext context) => OnReceivedToken(context); - - public virtual Task ValidatedToken(ValidatedTokenContext context) => OnValidatedToken(context); + public virtual Task TokenValidated(TokenValidatedContext context) => OnTokenValidated(context); public virtual Task Challenge(JwtBearerChallengeContext context) => OnChallenge(context); } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivingTokenContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs similarity index 79% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivingTokenContext.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs index e93ad824ad..a23f8356da 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivingTokenContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs @@ -6,9 +6,9 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class ReceivingTokenContext : BaseJwtBearerContext + public class MessageReceivedContext : BaseJwtBearerContext { - public ReceivingTokenContext(HttpContext context, JwtBearerOptions options) + public MessageReceivedContext(HttpContext context, JwtBearerOptions options) : base(context, options) { } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivedTokenContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivedTokenContext.cs deleted file mode 100644 index e38c49cf15..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/ReceivedTokenContext.cs +++ /dev/null @@ -1,18 +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.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.JwtBearer -{ - public class ReceivedTokenContext : BaseJwtBearerContext - { - public ReceivedTokenContext(HttpContext context, JwtBearerOptions options) - : base(context, options) - { - } - - public string Token { get; set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs index 3a1dad812f..d6de5ca873 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs @@ -3,14 +3,17 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Tokens; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class ValidatedTokenContext : BaseJwtBearerContext + public class TokenValidatedContext : BaseJwtBearerContext { - public ValidatedTokenContext(HttpContext context, JwtBearerOptions options) + public TokenValidatedContext(HttpContext context, JwtBearerOptions options) : base(context, options) { } + + public SecurityToken SecurityToken { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index b1d2d702eb..40a0b2efd7 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -28,24 +28,21 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer protected override async Task HandleAuthenticateAsync() { string token = null; + AuthenticateResult result = null; try { // Give application opportunity to find from a different location, adjust, or reject token - var receivingTokenContext = new ReceivingTokenContext(Context, Options); + var messageReceivedContext = new MessageReceivedContext(Context, Options); // event can set the token - await Options.Events.ReceivingToken(receivingTokenContext); - if (receivingTokenContext.HandledResponse) + await Options.Events.MessageReceived(messageReceivedContext); + if (messageReceivedContext.CheckEventResult(out result)) { - return AuthenticateResult.Success(receivingTokenContext.Ticket); - } - if (receivingTokenContext.Skipped) - { - return AuthenticateResult.Skip(); + return result; } // If application retrieved token from somewhere else, use that. - token = receivingTokenContext.Token; + token = messageReceivedContext.Token; if (string.IsNullOrEmpty(token)) { @@ -69,22 +66,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } } - // notify user token was received - var receivedTokenContext = new ReceivedTokenContext(Context, Options) - { - Token = token, - }; - - await Options.Events.ReceivedToken(receivedTokenContext); - if (receivedTokenContext.HandledResponse) - { - return AuthenticateResult.Success(receivedTokenContext.Ticket); - } - if (receivedTokenContext.Skipped) - { - return AuthenticateResult.Skip(); - } - if (_configuration == null && Options.ConfigurationManager != null) { _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); @@ -138,20 +119,18 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Logger.TokenValidationSucceeded(); var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Options.AuthenticationScheme); - var validatedTokenContext = new ValidatedTokenContext(Context, Options) + var tokenValidatedContext = new TokenValidatedContext(Context, Options) { - Ticket = ticket + Ticket = ticket, + SecurityToken = validatedToken, }; - await Options.Events.ValidatedToken(validatedTokenContext); - if (validatedTokenContext.HandledResponse) + await Options.Events.TokenValidated(tokenValidatedContext); + if (tokenValidatedContext.CheckEventResult(out result)) { - return AuthenticateResult.Success(validatedTokenContext.Ticket); - } - if (validatedTokenContext.Skipped) - { - return AuthenticateResult.Skip(); + return result; } + ticket = tokenValidatedContext.Ticket; if (Options.SaveToken) { @@ -173,13 +152,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer }; await Options.Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.HandledResponse) + if (authenticationFailedContext.CheckEventResult(out result)) { - return AuthenticateResult.Success(authenticationFailedContext.Ticket); - } - if (authenticationFailedContext.Skipped) - { - return AuthenticateResult.Skip(); + return result; } return AuthenticateResult.Fail(authenticationFailedContext.Exception); @@ -197,13 +172,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer }; await Options.Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.HandledResponse) + if (authenticationFailedContext.CheckEventResult(out result)) { - return AuthenticateResult.Success(authenticationFailedContext.Ticket); - } - if (authenticationFailedContext.Skipped) - { - return AuthenticateResult.Skip(); + return result; } throw; diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs index c350c38baf..837928e777 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -25,6 +25,8 @@ namespace Microsoft.AspNetCore.Builder public JwtBearerOptions() : base() { AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme; + AutomaticAuthenticate = true; + AutomaticChallenge = true; } /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.cs deleted file mode 100644 index 7d17d3cf80..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationResponseReceivedContext.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.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; - -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect -{ - public class AuthorizationResponseReceivedContext : BaseOpenIdConnectContext - { - public AuthorizationResponseReceivedContext(HttpContext context, OpenIdConnectOptions options, AuthenticationProperties properties) - : base(context, options) - { - Properties = properties; - } - - public AuthenticationProperties Properties { get; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs index da956acf82..57600cee8d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs @@ -15,21 +15,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Task AuthenticationFailed(AuthenticationFailedContext context); - /// - /// Invoked after the id token has passed validation and a ClaimsIdentity has been generated. - /// - Task AuthenticationValidated(AuthenticationValidatedContext context); - /// /// Invoked after security token validation if an authorization code is present in the protocol message. /// Task AuthorizationCodeReceived(AuthorizationCodeReceivedContext context); - /// - /// Invoked when an authorization response is received. - /// - Task AuthorizationResponseReceived(AuthorizationResponseReceivedContext context); - /// /// Invoked when a protocol message is first received. /// @@ -38,18 +28,23 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Invoked before redirecting to the identity provider to authenticate. /// - Task RedirectToAuthenticationEndpoint(RedirectContext context); + Task RedirectToIdentityProvider(RedirectContext context); /// /// Invoked before redirecting to the identity provider to sign out. /// - Task RedirectToEndSessionEndpoint(RedirectContext context); + Task RedirectToIdentityProviderForSignOut(RedirectContext context); /// /// Invoked after "authorization code" is redeemed for tokens at the token endpoint. /// Task TokenResponseReceived(TokenResponseReceivedContext context); + /// + /// Invoked when an IdToken has been validated and produced an AuthenticationTicket. + /// + Task TokenValidated(TokenValidatedContext context); + /// /// Invoked when user information is retrieved from the UserInfoEndpoint. /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs index d535f35f92..b2554969c1 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { @@ -17,5 +18,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Bearer Token. This will give application an opportunity to retrieve token from an alternation location. /// public string Token { get; set; } + + public AuthenticationProperties Properties { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index 249342eecf..9893b72072 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -16,21 +16,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// public Func OnAuthenticationFailed { get; set; } = context => Task.FromResult(0); - /// - /// Invoked after the id token has passed validation and a ClaimsIdentity has been generated. - /// - public Func OnAuthenticationValidated { get; set; } = context => Task.FromResult(0); - /// /// Invoked after security token validation if an authorization code is present in the protocol message. /// public Func OnAuthorizationCodeReceived { get; set; } = context => Task.FromResult(0); - /// - /// Invoked when an authorization response is received. - /// - public Func OnAuthorizationResponseReceived { get; set; } = context => Task.FromResult(0); - /// /// Invoked when a protocol message is first received. /// @@ -39,18 +29,23 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Invoked before redirecting to the identity provider to authenticate. /// - public Func OnRedirectToAuthenticationEndpoint { get; set; } = context => Task.FromResult(0); + public Func OnRedirectToIdentityProvider { get; set; } = context => Task.FromResult(0); /// /// Invoked before redirecting to the identity provider to sign out. /// - public Func OnRedirectToEndSessionEndpoint { get; set; } = context => Task.FromResult(0); + public Func OnRedirectToIdentityProviderForSignOut { get; set; } = context => Task.FromResult(0); /// /// Invoked after "authorization code" is redeemed for tokens at the token endpoint. /// public Func OnTokenResponseReceived { get; set; } = context => Task.FromResult(0); + /// + /// Invoked when an IdToken has been validated and produced an AuthenticationTicket. + /// + public Func OnTokenValidated { get; set; } = context => Task.FromResult(0); + /// /// Invoked when user information is retrieved from the UserInfoEndpoint. /// @@ -58,20 +53,18 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); - public virtual Task AuthenticationValidated(AuthenticationValidatedContext context) => OnAuthenticationValidated(context); - public virtual Task AuthorizationCodeReceived(AuthorizationCodeReceivedContext context) => OnAuthorizationCodeReceived(context); - public virtual Task AuthorizationResponseReceived(AuthorizationResponseReceivedContext context) => OnAuthorizationResponseReceived(context); - public virtual Task MessageReceived(MessageReceivedContext context) => OnMessageReceived(context); - public virtual Task RedirectToAuthenticationEndpoint(RedirectContext context) => OnRedirectToAuthenticationEndpoint(context); + public virtual Task RedirectToIdentityProvider(RedirectContext context) => OnRedirectToIdentityProvider(context); - public virtual Task RedirectToEndSessionEndpoint(RedirectContext context) => OnRedirectToEndSessionEndpoint(context); + public virtual Task RedirectToIdentityProviderForSignOut(RedirectContext context) => OnRedirectToIdentityProviderForSignOut(context); public virtual Task TokenResponseReceived(TokenResponseReceivedContext context) => OnTokenResponseReceived(context); + public virtual Task TokenValidated(TokenValidatedContext context) => OnTokenValidated(context); + public virtual Task UserInformationReceived(UserInformationReceivedContext context) => OnUserInformationReceived(context); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs similarity index 52% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs index 4e19796457..130a4d9873 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs @@ -1,6 +1,8 @@ // 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.IdentityModel.Tokens.Jwt; +using System.Net.Http; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; @@ -8,16 +10,22 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class AuthenticationValidatedContext : BaseOpenIdConnectContext + public class TokenValidatedContext : BaseOpenIdConnectContext { - public AuthenticationValidatedContext(HttpContext context, OpenIdConnectOptions options, AuthenticationProperties properties) + /// + /// Creates a + /// + public TokenValidatedContext(HttpContext context, OpenIdConnectOptions options) : base(context, options) { - Properties = properties; } - public AuthenticationProperties Properties { get; } + public AuthenticationProperties Properties { get; set; } + + public JwtSecurityToken SecurityToken { get; set; } public OpenIdConnectMessage TokenEndpointResponse { get; set; } + + public string Nonce { get; set; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs index 8d45c9918c..ff580ff266 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -7,10 +7,10 @@ namespace Microsoft.Extensions.Logging { internal static class LoggingExtensions { - private static Action _redirectToEndSessionEndpointHandledResponse; - private static Action _redirectToEndSessionEndpointSkipped; - private static Action _redirectToAuthenticationEndpointHandledResponse; - private static Action _redirectToAuthenticationEndpointSkipped; + private static Action _redirectToIdentityProviderForSignOutHandledResponse; + private static Action _redirectToIdentityProviderForSignOutSkipped; + private static Action _redirectToIdentityProviderHandledResponse; + private static Action _redirectToIdentityProviderSkipped; private static Action _updatingConfiguration; private static Action _receivedIdToken; private static Action _redeemingCodeForTokens; @@ -19,20 +19,17 @@ namespace Microsoft.Extensions.Logging private static Action _messageReceived; private static Action _messageReceivedContextHandledResponse; private static Action _messageReceivedContextSkipped; - private static Action _authorizationResponseReceived; private static Action _authorizationCodeReceived; private static Action _configurationManagerRequestRefreshCalled; private static Action _tokenResponseReceived; - private static Action _authorizationResponseReceivedHandledResponse; - private static Action _authorizationResponseReceivedSkipped; + private static Action _tokenValidatedHandledResponse; + private static Action _tokenValidatedSkipped; private static Action _authenticationFailedContextHandledResponse; private static Action _authenticationFailedContextSkipped; private static Action _authorizationCodeReceivedContextHandledResponse; private static Action _authorizationCodeReceivedContextSkipped; - private static Action _authorizationCodeRedeemedContextHandledResponse; - private static Action _authorizationCodeRedeemedContextSkipped; - private static Action _authenticationValidatedHandledResponse; - private static Action _authenticationValidatedtSkipped; + private static Action _tokenResponseReceivedHandledResponse; + private static Action _tokenResponseReceivedSkipped; private static Action _userInformationReceived; private static Action _userInformationReceivedHandledResponse; private static Action _userInformationReceivedSkipped; @@ -54,14 +51,14 @@ namespace Microsoft.Extensions.Logging static LoggingExtensions() { // Final - _redirectToEndSessionEndpointHandledResponse = LoggerMessage.Define( + _redirectToIdentityProviderForSignOutHandledResponse = LoggerMessage.Define( eventId: 1, logLevel: LogLevel.Debug, - formatString: "RedirectToEndSessionEndpoint.HandledResponse"); - _redirectToEndSessionEndpointSkipped = LoggerMessage.Define( + formatString: "RedirectToIdentityProviderForSignOut.HandledResponse"); + _redirectToIdentityProviderForSignOutSkipped = LoggerMessage.Define( eventId: 2, logLevel: LogLevel.Debug, - formatString: "RedirectToEndSessionEndpoint.Skipped"); + formatString: "RedirectToIdentityProviderForSignOut.Skipped"); _invalidLogoutQueryStringRedirectUrl = LoggerMessage.Define( eventId: 3, logLevel: LogLevel.Warning, @@ -74,14 +71,14 @@ namespace Microsoft.Extensions.Logging eventId: 5, logLevel: LogLevel.Trace, formatString: "Using properties.RedirectUri for 'local redirect' post authentication: '{RedirectUri}'."); - _redirectToAuthenticationEndpointHandledResponse = LoggerMessage.Define( + _redirectToIdentityProviderHandledResponse = LoggerMessage.Define( eventId: 6, logLevel: LogLevel.Debug, - formatString: "RedirectToAuthenticationEndpoint.HandledResponse"); - _redirectToAuthenticationEndpointSkipped = LoggerMessage.Define( + formatString: "RedirectToIdentityProvider.HandledResponse"); + _redirectToIdentityProviderSkipped = LoggerMessage.Define( eventId: 7, logLevel: LogLevel.Debug, - formatString: "RedirectToAuthenticationEndpoint.Skipped"); + formatString: "RedirectToIdentityProvider.Skipped"); _invalidAuthenticationRequestUrl = LoggerMessage.Define( eventId: 8, logLevel: LogLevel.Warning, @@ -106,18 +103,14 @@ namespace Microsoft.Extensions.Logging eventId: 13, logLevel: LogLevel.Debug, formatString: "Updating configuration"); - _authorizationResponseReceived = LoggerMessage.Define( - eventId: 14, - logLevel: LogLevel.Trace, - formatString: "Authorization response received."); - _authorizationResponseReceivedHandledResponse = LoggerMessage.Define( + _tokenValidatedHandledResponse = LoggerMessage.Define( eventId: 15, logLevel: LogLevel.Debug, - formatString: "AuthorizationResponseReceived.HandledResponse"); - _authorizationResponseReceivedSkipped = LoggerMessage.Define( + formatString: "TokenValidated.HandledResponse"); + _tokenValidatedSkipped = LoggerMessage.Define( eventId: 16, logLevel: LogLevel.Debug, - formatString: "AuthorizationResponseReceived.Skipped"); + formatString: "TokenValidated.Skipped"); _exceptionProcessingMessage = LoggerMessage.Define( eventId: 17, logLevel: LogLevel.Error, @@ -174,22 +167,14 @@ namespace Microsoft.Extensions.Logging eventId: 30, logLevel: LogLevel.Trace, formatString: "Token response received."); - _authorizationCodeRedeemedContextHandledResponse = LoggerMessage.Define( + _tokenResponseReceivedHandledResponse = LoggerMessage.Define( eventId: 31, logLevel: LogLevel.Debug, - formatString: "AuthorizationCodeRedeemedContext.HandledResponse"); - _authorizationCodeRedeemedContextSkipped = LoggerMessage.Define( + formatString: "TokenResponseReceived.HandledResponse"); + _tokenResponseReceivedSkipped = LoggerMessage.Define( eventId: 32, logLevel: LogLevel.Debug, - formatString: "AuthorizationCodeRedeemedContext.Skipped"); - _authenticationValidatedHandledResponse = LoggerMessage.Define( - eventId: 33, - logLevel: LogLevel.Debug, - formatString: "AuthenticationFailedContext.HandledResponse"); - _authenticationValidatedtSkipped = LoggerMessage.Define( - eventId: 34, - logLevel: LogLevel.Debug, - formatString: "AuthenticationFailedContext.Skipped"); + formatString: "TokenResponseReceived.Skipped"); _userInformationReceived = LoggerMessage.Define( eventId: 35, logLevel: LogLevel.Trace, @@ -258,19 +243,14 @@ namespace Microsoft.Extensions.Logging _redeemingCodeForTokens(logger, null); } - public static void AuthorizationResponseReceived(this ILogger logger) + public static void TokenValidatedHandledResponse(this ILogger logger) { - _authorizationResponseReceived(logger, null); + _tokenValidatedHandledResponse(logger, null); } - public static void AuthorizationResponseReceivedHandledResponse(this ILogger logger) + public static void TokenValidatedSkipped(this ILogger logger) { - _authorizationResponseReceivedHandledResponse(logger, null); - } - - public static void AuthorizationResponseReceivedSkipped(this ILogger logger) - { - _authorizationResponseReceivedSkipped(logger, null); + _tokenValidatedSkipped(logger, null); } public static void AuthorizationCodeReceivedContextHandledResponse(this ILogger logger) @@ -283,24 +263,14 @@ namespace Microsoft.Extensions.Logging _authorizationCodeReceivedContextSkipped(logger, null); } - public static void AuthorizationCodeRedeemedContextHandledResponse(this ILogger logger) + public static void TokenResponseReceivedHandledResponse(this ILogger logger) { - _authorizationCodeRedeemedContextHandledResponse(logger, null); + _tokenResponseReceivedHandledResponse(logger, null); } - public static void AuthorizationCodeRedeemedContextSkipped(this ILogger logger) + public static void TokenResponseReceivedSkipped(this ILogger logger) { - _authorizationCodeRedeemedContextSkipped(logger, null); - } - - public static void AuthenticationValidatedHandledResponse(this ILogger logger) - { - _authenticationValidatedHandledResponse(logger, null); - } - - public static void AuthenticationValidatedSkipped(this ILogger logger) - { - _authenticationValidatedtSkipped(logger, null); + _tokenResponseReceivedSkipped(logger, null); } public static void AuthenticationFailedContextHandledResponse(this ILogger logger) @@ -328,24 +298,24 @@ namespace Microsoft.Extensions.Logging _messageReceivedContextSkipped(logger, null); } - public static void RedirectToEndSessionEndpointHandledResponse(this ILogger logger) + public static void RedirectToIdentityProviderForSignOutHandledResponse(this ILogger logger) { - _redirectToEndSessionEndpointHandledResponse(logger, null); + _redirectToIdentityProviderForSignOutHandledResponse(logger, null); } - public static void RedirectToEndSessionEndpointSkipped(this ILogger logger) + public static void RedirectToIdentityProviderForSignOutSkipped(this ILogger logger) { - _redirectToEndSessionEndpointSkipped(logger, null); + _redirectToIdentityProviderForSignOutSkipped(logger, null); } - public static void RedirectToAuthenticationEndpointHandledResponse(this ILogger logger) + public static void RedirectToIdentityProviderHandledResponse(this ILogger logger) { - _redirectToAuthenticationEndpointHandledResponse(logger, null); + _redirectToIdentityProviderHandledResponse(logger, null); } - public static void RedirectToAuthenticationEndpointSkipped(this ILogger logger) + public static void RedirectToIdentityProviderSkipped(this ILogger logger) { - _redirectToAuthenticationEndpointSkipped(logger, null); + _redirectToIdentityProviderSkipped(logger, null); } public static void UserInformationReceivedHandledResponse(this ILogger logger) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 5c534696b8..f85ba9c146 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -111,15 +111,15 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect ProtocolMessage = message }; - await Options.Events.RedirectToEndSessionEndpoint(redirectContext); + await Options.Events.RedirectToIdentityProviderForSignOut(redirectContext); if (redirectContext.HandledResponse) { - Logger.RedirectToEndSessionEndpointHandledResponse(); + Logger.RedirectToIdentityProviderForSignOutHandledResponse(); return; } else if (redirectContext.Skipped) { - Logger.RedirectToEndSessionEndpointSkipped(); + Logger.RedirectToIdentityProviderForSignOutSkipped(); return; } @@ -169,7 +169,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Responds to a 401 Challenge. Sends an OpenIdConnect message to the 'identity authority' to obtain an identity. /// /// - /// Uses log id's OIDCH-0026 - OIDCH-0050, next num: 37 protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { if (context == null) @@ -230,15 +229,15 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect ProtocolMessage = message }; - await Options.Events.RedirectToAuthenticationEndpoint(redirectContext); + await Options.Events.RedirectToIdentityProvider(redirectContext); if (redirectContext.HandledResponse) { - Logger.RedirectToAuthenticationEndpointHandledResponse(); + Logger.RedirectToIdentityProviderHandledResponse(); return true; } else if (redirectContext.Skipped) { - Logger.RedirectToAuthenticationEndpointSkipped(); + Logger.RedirectToIdentityProviderSkipped(); return false; } @@ -350,27 +349,38 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect try { - var messageReceivedContext = await RunMessageReceivedEventAsync(authorizationResponse); - if (CheckEventResult(messageReceivedContext, out result)) + AuthenticationProperties properties = null; + if (!string.IsNullOrEmpty(authorizationResponse.State)) + { + properties = Options.StateDataFormat.Unprotect(authorizationResponse.State); + } + + var messageReceivedContext = await RunMessageReceivedEventAsync(authorizationResponse, properties); + if (messageReceivedContext.CheckEventResult(out result)) { return result; } authorizationResponse = messageReceivedContext.ProtocolMessage; + properties = messageReceivedContext.Properties; - // Fail if state is missing, it's required for the correlation id. - if (string.IsNullOrEmpty(authorizationResponse.State)) + if (properties == null) { - // This wasn't a valid OIDC message, it may not have been intended for us. - Logger.NullOrEmptyAuthorizationResponseState(); - if (Options.SkipUnrecognizedRequests) + // Fail if state is missing, it's required for the correlation id. + if (string.IsNullOrEmpty(authorizationResponse.State)) { - return AuthenticateResult.Skip(); + // This wasn't a valid OIDC message, it may not have been intended for us. + Logger.NullOrEmptyAuthorizationResponseState(); + if (Options.SkipUnrecognizedRequests) + { + return AuthenticateResult.Skip(); + } + return AuthenticateResult.Fail(Resources.MessageStateIsNullOrEmpty); } - return AuthenticateResult.Fail(Resources.MessageStateIsNullOrEmpty); + + // if state exists and we failed to 'unprotect' this is not a message we should process. + properties = Options.StateDataFormat.Unprotect(authorizationResponse.State); } - // if state exists and we failed to 'unprotect' this is not a message we should process. - var properties = Options.StateDataFormat.Unprotect(Uri.UnescapeDataString(authorizationResponse.State)); if (properties == null) { Logger.UnableToReadAuthorizationResponseState(); @@ -382,17 +392,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return AuthenticateResult.Fail(Resources.MessageStateIsInvalid); } - // if any of the error fields are set, throw error null - if (!string.IsNullOrEmpty(authorizationResponse.Error)) - { - Logger.AuthorizationResponseError( - authorizationResponse.Error, - authorizationResponse.ErrorDescription ?? "ErrorDecription null", - authorizationResponse.ErrorUri ?? "ErrorUri null"); - - return AuthenticateResult.Fail(new OpenIdConnectProtocolException(string.Format(CultureInfo.InvariantCulture, Resources.MessageContainsError, authorizationResponse.Error, authorizationResponse.ErrorDescription ?? "ErrorDecription null", authorizationResponse.ErrorUri ?? "ErrorUri null"))); - } - string userstate = null; properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out userstate); authorizationResponse.State = userstate; @@ -402,20 +401,25 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return AuthenticateResult.Fail("Correlation failed."); } + // if any of the error fields are set, throw error null + if (!string.IsNullOrEmpty(authorizationResponse.Error)) + { + Logger.AuthorizationResponseError( + authorizationResponse.Error, + authorizationResponse.ErrorDescription ?? "ErrorDecription null", + authorizationResponse.ErrorUri ?? "ErrorUri null"); + + return AuthenticateResult.Fail(new OpenIdConnectProtocolException( + string.Format(CultureInfo.InvariantCulture, Resources.MessageContainsError, authorizationResponse.Error, + authorizationResponse.ErrorDescription ?? "ErrorDecription null", authorizationResponse.ErrorUri ?? "ErrorUri null"))); + } + if (_configuration == null && Options.ConfigurationManager != null) { Logger.UpdatingConfiguration(); _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); } - var authorizationResponseReceivedContext = await RunAuthorizationResponseReceivedEventAsync(authorizationResponse, properties); - if (CheckEventResult(authorizationResponseReceivedContext, out result)) - { - return result; - } - authorizationResponse = authorizationResponseReceivedContext.ProtocolMessage; - properties = authorizationResponseReceivedContext.Properties; - PopulateSessionProperties(authorizationResponse, properties); AuthenticationTicket ticket = null; @@ -434,6 +438,17 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { nonce = ReadNonceCookie(nonce); } + + var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, null, properties, ticket, jwt, nonce); + if (tokenValidatedContext.CheckEventResult(out result)) + { + return result; + } + authorizationResponse = tokenValidatedContext.ProtocolMessage; + properties = tokenValidatedContext.Properties; + ticket = tokenValidatedContext.Ticket; + jwt = tokenValidatedContext.SecurityToken; + nonce = tokenValidatedContext.Nonce; } Options.ProtocolValidator.ValidateAuthenticationResponse(new OpenIdConnectProtocolValidationContext() @@ -444,15 +459,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Nonce = nonce }); - // TODO: AuthorizationResponseValidated event? - OpenIdConnectMessage tokenEndpointResponse = null; // Authorization Code or Hybrid flow if (!string.IsNullOrEmpty(authorizationResponse.Code)) { var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(authorizationResponse, properties, ticket, jwt); - if (CheckEventResult(authorizationCodeReceivedContext, out result)) + if (authorizationCodeReceivedContext.CheckEventResult(out result)) { return result; } @@ -469,13 +482,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect tokenEndpointResponse = await RedeemAuthorizationCodeAsync(tokenEndpointRequest); } - var authorizationCodeRedeemedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties); - if (CheckEventResult(authorizationCodeRedeemedContext, out result)) + var tokenResponseReceivedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties); + if (tokenResponseReceivedContext.CheckEventResult(out result)) { return result; } - authorizationResponse = authorizationCodeRedeemedContext.ProtocolMessage; - tokenEndpointResponse = authorizationCodeRedeemedContext.TokenEndpointResponse; + authorizationResponse = tokenResponseReceivedContext.ProtocolMessage; + tokenEndpointResponse = tokenResponseReceivedContext.TokenEndpointResponse; // We only have to process the IdToken if we didn't already get one in the AuthorizationResponse if (ticket == null) @@ -491,6 +504,18 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { nonce = ReadNonceCookie(nonce); } + + var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, tokenEndpointResponse, properties, ticket, jwt, nonce); + if (tokenValidatedContext.CheckEventResult(out result)) + { + return result; + } + authorizationResponse = tokenValidatedContext.ProtocolMessage; + tokenEndpointResponse = tokenValidatedContext.TokenEndpointResponse; + properties = tokenValidatedContext.Properties; + ticket = tokenValidatedContext.Ticket; + jwt = tokenValidatedContext.SecurityToken; + nonce = tokenValidatedContext.Nonce; } // Validate the token response if it wasn't provided manually @@ -506,15 +531,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } } - var authenticationValidatedContext = await RunAuthenticationValidatedEventAsync(authorizationResponse, ticket, properties, tokenEndpointResponse); - if (CheckEventResult(authenticationValidatedContext, out result)) - { - return result; - } - authorizationResponse = authenticationValidatedContext.ProtocolMessage; - tokenEndpointResponse = authenticationValidatedContext.TokenEndpointResponse; - ticket = authenticationValidatedContext.Ticket; - if (Options.SaveTokens) { SaveTokens(ticket.Properties, tokenEndpointResponse ?? authorizationResponse); @@ -542,7 +558,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } var authenticationFailedContext = await RunAuthenticationFailedEventAsync(authorizationResponse, exception); - if (CheckEventResult(authenticationFailedContext, out result)) + if (authenticationFailedContext.CheckEventResult(out result)) { return result; } @@ -551,22 +567,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } } - private bool CheckEventResult(BaseControlContext context, out AuthenticateResult result) - { - if (context.HandledResponse) - { - result = AuthenticateResult.Success(context.Ticket); - return true; - } - else if (context.Skipped) - { - result = AuthenticateResult.Skip(); - return true; - } - result = null; - return false; - } - private void PopulateSessionProperties(OpenIdConnectMessage message, AuthenticationProperties properties) { if (!string.IsNullOrEmpty(message.SessionState)) @@ -643,7 +643,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(ticket, message, user); AuthenticateResult result; - if (CheckEventResult(userInformationReceivedContext, out result)) + if (userInformationReceivedContext.CheckEventResult(out result)) { return result; } @@ -830,12 +830,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } } - private async Task RunMessageReceivedEventAsync(OpenIdConnectMessage message) + private async Task RunMessageReceivedEventAsync(OpenIdConnectMessage message, AuthenticationProperties properties) { Logger.MessageReceived(message.BuildRedirectUrl()); var messageReceivedContext = new MessageReceivedContext(Context, Options) { - ProtocolMessage = message + ProtocolMessage = message, + Properties = properties, }; await Options.Events.MessageReceived(messageReceivedContext); @@ -851,23 +852,29 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return messageReceivedContext; } - private async Task RunAuthorizationResponseReceivedEventAsync(OpenIdConnectMessage message, AuthenticationProperties properties) + private async Task RunTokenValidatedEventAsync(OpenIdConnectMessage authorizationResponse, OpenIdConnectMessage tokenEndpointResponse, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt, string nonce) { - Logger.AuthorizationResponseReceived(); - var authorizationResponseReceivedContext = new AuthorizationResponseReceivedContext(Context, Options, properties) + var tokenValidatedContext = new TokenValidatedContext(Context, Options) { - ProtocolMessage = message + ProtocolMessage = authorizationResponse, + TokenEndpointResponse = tokenEndpointResponse, + Properties = properties, + Ticket = ticket, + SecurityToken = jwt, + Nonce = nonce, }; - await Options.Events.AuthorizationResponseReceived(authorizationResponseReceivedContext); - if (authorizationResponseReceivedContext.HandledResponse) + + await Options.Events.TokenValidated(tokenValidatedContext); + if (tokenValidatedContext.HandledResponse) { - Logger.AuthorizationResponseReceivedHandledResponse(); + Logger.TokenValidatedHandledResponse(); } - else if (authorizationResponseReceivedContext.Skipped) + else if (tokenValidatedContext.Skipped) { - Logger.AuthorizationResponseReceivedSkipped(); + Logger.TokenValidatedSkipped(); } - return authorizationResponseReceivedContext; + + return tokenValidatedContext; } private async Task RunAuthorizationCodeReceivedEventAsync(OpenIdConnectMessage authorizationResponse, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt) @@ -909,46 +916,23 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private async Task RunTokenResponseReceivedEventAsync(OpenIdConnectMessage message, OpenIdConnectMessage tokenEndpointResponse, AuthenticationProperties properties) { Logger.TokenResponseReceived(); - - var tokenResponseReceivedContext = new TokenResponseReceivedContext(Context, Options, properties) + var eventContext = new TokenResponseReceivedContext(Context, Options, properties) { ProtocolMessage = message, TokenEndpointResponse = tokenEndpointResponse }; - await Options.Events.TokenResponseReceived(tokenResponseReceivedContext); - if (tokenResponseReceivedContext.HandledResponse) + await Options.Events.TokenResponseReceived(eventContext); + if (eventContext.HandledResponse) { - Logger.AuthorizationCodeRedeemedContextHandledResponse(); + Logger.TokenResponseReceivedHandledResponse(); } - else if (tokenResponseReceivedContext.Skipped) + else if (eventContext.Skipped) { - Logger.AuthorizationCodeRedeemedContextSkipped(); + Logger.TokenResponseReceivedSkipped(); } - return tokenResponseReceivedContext; - } - - private async Task RunAuthenticationValidatedEventAsync(OpenIdConnectMessage message, AuthenticationTicket ticket, AuthenticationProperties properties, OpenIdConnectMessage tokenResponse) - { - var authenticationValidatedContext = new AuthenticationValidatedContext(Context, Options, properties) - { - Ticket = ticket, - ProtocolMessage = message, - TokenEndpointResponse = tokenResponse, - }; - - await Options.Events.AuthenticationValidated(authenticationValidatedContext); - if (authenticationValidatedContext.HandledResponse) - { - Logger.AuthenticationValidatedHandledResponse(); - } - else if (authenticationValidatedContext.Skipped) - { - Logger.AuthenticationValidatedSkipped(); - } - - return authenticationValidatedContext; + return eventContext; } private async Task RunUserInformationReceivedEventAsync(AuthenticationTicket ticket, OpenIdConnectMessage message, JObject user) diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs index db81ad704c..24f3ba8e53 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs @@ -46,5 +46,21 @@ namespace Microsoft.AspNetCore.Authentication /// Gets or set the to return if this event signals it handled the event. ///
public AuthenticationTicket Ticket { get; set; } + + public bool CheckEventResult(out AuthenticateResult result) + { + if (HandledResponse) + { + result = AuthenticateResult.Success(Ticket); + return true; + } + else if (Skipped) + { + result = AuthenticateResult.Skip(); + return true; + } + result = null; + return false; + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 72d13a4c9e..81c03dc83a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer AutomaticAuthenticate = true, Events = new JwtBearerEvents() { - OnReceivingToken = context => + OnMessageReceived = context => { var claims = new[] { @@ -143,39 +143,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal("", response.ResponseText); } - [Fact] - public async Task CustomTokenReceived() - { - var server = CreateServer(new JwtBearerOptions - { - AutomaticAuthenticate = true, - Events = new JwtBearerEvents() - { - OnReceivedToken = context => - { - var claims = new[] - { - new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), - new Claim(ClaimTypes.Email, "bob@contoso.com"), - new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") - }; - - context.Ticket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), - new AuthenticationProperties(), context.Options.AuthenticationScheme); - - context.HandleResponse(); - - return Task.FromResult(null); - } - } - }); - - var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); - Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); - Assert.Equal("Bob le Magnifique", response.ResponseText); - } - [Fact] public async Task CustomTokenValidated() { @@ -184,7 +151,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer AutomaticAuthenticate = true, Events = new JwtBearerEvents() { - OnValidatedToken = context => + OnTokenValidated = context => { // Retrieve the NameIdentifier claim from the identity // returned by the custom security token validator. @@ -204,6 +171,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } } }; + options.SecurityTokenValidators.Clear(); options.SecurityTokenValidators.Add(new BlobTokenValidator(options.AuthenticationScheme)); var server = CreateServer(options); @@ -215,67 +183,37 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task RetrievingTokenFromAlternateLocation() { - var server = CreateServer(new JwtBearerOptions + var options = new JwtBearerOptions() { AutomaticAuthenticate = true, Events = new JwtBearerEvents() { - OnReceivingToken = context => + OnMessageReceived = context => { context.Token = "CustomToken"; - return Task.FromResult(null); - }, - OnReceivedToken = context => - { - var claims = new[] - { - new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), - new Claim(ClaimTypes.Email, "bob@contoso.com"), - new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") - }; - - context.Ticket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), - new AuthenticationProperties(), context.Options.AuthenticationScheme); - - context.HandleResponse(); - return Task.FromResult(null); } } - }); + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT", token => + { + Assert.Equal("CustomToken", token); + })); + var server = CreateServer(options); var response = await SendAsync(server, "http://example.com/oauth", "Bearer Token"); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); - Assert.Equal("Bob le Magnifique", response.ResponseText); + Assert.Equal("Bob le Tout Puissant", response.ResponseText); } [Fact] public async Task BearerTurns401To403IfAuthenticated() { - var server = CreateServer(new JwtBearerOptions - { - Events = new JwtBearerEvents() - { - OnReceivedToken = context => - { - var claims = new[] - { - new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), - new Claim(ClaimTypes.Email, "bob@contoso.com"), - new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") - }; - - context.Ticket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), - new AuthenticationProperties(), context.Options.AuthenticationScheme); - - context.HandleResponse(); - - return Task.FromResult(null); - } - } - }); + var options = new JwtBearerOptions(); + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + var server = CreateServer(options); var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); Assert.Equal(HttpStatusCode.Forbidden, response.Response.StatusCode); @@ -284,52 +222,26 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task BearerDoesNothingTo401IfNotAuthenticated() { - var server = CreateServer(new JwtBearerOptions - { - Events = new JwtBearerEvents() - { - OnReceivedToken = context => - { - var claims = new[] - { - new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), - new Claim(ClaimTypes.Email, "bob@contoso.com"), - new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") - }; - - context.Ticket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), - new AuthenticationProperties(), context.Options.AuthenticationScheme); - - context.HandleResponse(); - - return Task.FromResult(null); - } - } - }); + var server = CreateServer(new JwtBearerOptions()); var response = await SendAsync(server, "http://example.com/unauthorized"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); } [Fact] - public async Task EventOnReceivingTokenSkipped_NoMoreEventsExecuted() + public async Task EventOnMessageReceivedSkipped_NoMoreEventsExecuted() { var server = CreateServer(new JwtBearerOptions { AutomaticAuthenticate = true, Events = new JwtBearerEvents() { - OnReceivingToken = context => + OnMessageReceived = context => { context.SkipToNextMiddleware(); return Task.FromResult(0); }, - OnReceivedToken = context => - { - throw new NotImplementedException(); - }, - OnValidatedToken = context => + OnTokenValidated = context => { throw new NotImplementedException(); }, @@ -350,47 +262,14 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } [Fact] - public async Task EventOnReceivedTokenSkipped_NoMoreEventsExecuted() - { - var server = CreateServer(new JwtBearerOptions - { - AutomaticAuthenticate = true, - Events = new JwtBearerEvents() - { - OnReceivedToken = context => - { - context.SkipToNextMiddleware(); - return Task.FromResult(0); - }, - OnValidatedToken = context => - { - throw new NotImplementedException(); - }, - OnAuthenticationFailed = context => - { - throw new NotImplementedException(context.Exception.ToString()); - }, - OnChallenge = context => - { - throw new NotImplementedException(); - }, - } - }); - - var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); - Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); - Assert.Equal(string.Empty, response.ResponseText); - } - - [Fact] - public async Task EventOnValidatedTokenSkipped_NoMoreEventsExecuted() + public async Task EventOnTokenValidatedSkipped_NoMoreEventsExecuted() { var options = new JwtBearerOptions { AutomaticAuthenticate = true, Events = new JwtBearerEvents() { - OnValidatedToken = context => + OnTokenValidated = context => { context.SkipToNextMiddleware(); return Task.FromResult(0); @@ -422,7 +301,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer AutomaticAuthenticate = true, Events = new JwtBearerEvents() { - OnValidatedToken = context => + OnTokenValidated = context => { throw new Exception("Test Exception"); }, @@ -493,9 +372,17 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer class BlobTokenValidator : ISecurityTokenValidator { + private Action _tokenValidator; + public BlobTokenValidator(string authenticationScheme) { AuthenticationScheme = authenticationScheme; + + } + public BlobTokenValidator(string authenticationScheme, Action tokenValidator) + { + AuthenticationScheme = authenticationScheme; + _tokenValidator = tokenValidator; } public string AuthenticationScheme { get; } @@ -519,6 +406,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParameters validationParameters, out SecurityToken validatedToken) { validatedToken = null; + if (_tokenValidator != null) + { + _tokenValidator(securityToken); + } var claims = new[] { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index cadcf80884..ebc59b9ee8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -150,12 +150,12 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect options.AutomaticChallenge = true; options.Events = new OpenIdConnectEvents() { - OnRedirectToAuthenticationEndpoint = (context) => + OnRedirectToIdentityProvider = (context) => { context.ProtocolMessage = fakeOpenIdRequestMessage; return Task.FromResult(0); }, - OnRedirectToEndSessionEndpoint = (context) => + OnRedirectToIdentityProviderForSignOut = (context) => { context.ProtocolMessage = fakeOpenIdRequestMessage; return Task.FromResult(0); @@ -208,7 +208,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect options.AutomaticChallenge = challenge.Equals(ChallengeWithOutContext); options.Events = new OpenIdConnectEvents() { - OnRedirectToAuthenticationEndpoint = context => + OnRedirectToIdentityProvider = context => { context.ProtocolMessage.State = userState; context.ProtocolMessage.RedirectUri = queryValues.RedirectUri; @@ -258,7 +258,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var options = GetOptions(DefaultParameters(), queryValues); options.Events = new OpenIdConnectEvents() { - OnRedirectToAuthenticationEndpoint = context => + OnRedirectToIdentityProvider = context => { context.ProtocolMessage.ClientId = queryValuesSetInEvent.ClientId; context.ProtocolMessage.RedirectUri = queryValuesSetInEvent.RedirectUri; From 4086d706284e0973f7e7ababa1da045697ad85be Mon Sep 17 00:00:00 2001 From: jacalvar Date: Mon, 28 Mar 2016 15:43:22 -0700 Subject: [PATCH 505/900] Add comments to AddAuthentication extension methods --- .../AuthenticationServiceCollectionExtensions.cs | 4 ++-- .../AuthorizationServiceCollectionExtensions.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 9ce76d7e62..2aa320ae21 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.Extensions.DependencyInjection /// Adds authentication services to the specified . /// /// The to add services to. - /// A reference to this instance after the operation has completed. + /// The so that additional calls can be chained. public static IServiceCollection AddAuthentication(this IServiceCollection services) { if (services == null) @@ -33,7 +33,7 @@ namespace Microsoft.Extensions.DependencyInjection /// /// The to add services to. /// An action delegate to configure the provided . - /// A reference to this instance after the operation has completed. + /// The so that additional calls can be chained. public static IServiceCollection AddAuthentication(this IServiceCollection services, Action configureOptions) { if (services == null) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs index d03f9ed746..c92be6232e 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -17,7 +17,7 @@ namespace Microsoft.Extensions.DependencyInjection /// Adds authorization services to the specified . /// /// The to add services to. - /// A reference to this instance after the operation has completed. + /// The so that additional calls can be chained. public static IServiceCollection AddAuthorization(this IServiceCollection services) { if (services == null) @@ -36,7 +36,7 @@ namespace Microsoft.Extensions.DependencyInjection /// /// The to add services to. /// An action delegate to configure the provided . - /// A reference to this instance after the operation has completed. + /// The so that additional calls can be chained. public static IServiceCollection AddAuthorization(this IServiceCollection services, Action configure) { if (services == null) From babd83cf287e4cf5b33106b5df87a084f6d8d044 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 30 Mar 2016 15:51:02 -0700 Subject: [PATCH 506/900] Reacting to Kestrel extensions --- samples/CookieSample/Startup.cs | 4 ++-- samples/CookieSessionSample/Startup.cs | 4 ++-- samples/JwtBearerSample/Startup.cs | 3 ++- samples/OpenIdConnect.AzureAdSample/Startup.cs | 5 +++-- samples/OpenIdConnectSample/Startup.cs | 3 ++- samples/SocialSample/Startup.cs | 3 ++- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 043664f1dc..4ad27b180b 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -46,7 +46,7 @@ namespace CookieSample { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -54,4 +54,4 @@ namespace CookieSample host.Run(); } } -} \ No newline at end of file +} diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 71da6aa1f5..7843f66a1f 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -56,7 +56,7 @@ namespace CookieSessionSample { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -64,4 +64,4 @@ namespace CookieSessionSample host.Run(); } } -} \ No newline at end of file +} diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 78e6d0f406..b0c2464f87 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -114,7 +114,7 @@ namespace JwtBearerSample { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -123,3 +123,4 @@ namespace JwtBearerSample } } } + diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 3bbae57b4a..3a73a090ac 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; @@ -157,7 +157,7 @@ namespace OpenIdConnect.AzureAdSample { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -166,3 +166,4 @@ namespace OpenIdConnect.AzureAdSample } } } + diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index bad559aa22..76ac7c7120 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -103,7 +103,7 @@ namespace OpenIdConnectSample { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -112,3 +112,4 @@ namespace OpenIdConnectSample } } } + diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index e9c7f6141d..0e13b78e92 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -343,7 +343,7 @@ namespace SocialSample { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseServer("Microsoft.AspNetCore.Server.Kestrel") + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); @@ -370,3 +370,4 @@ namespace SocialSample } } } + From 16a0482238bde951dbba981aaf8e80345a32a23c Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Sun, 27 Mar 2016 21:46:45 -0700 Subject: [PATCH 507/900] React to HttpAbstractions namespace changes - aspnet/HttpAbstractions#549 and aspnet/HttpAbstractions#592 - clean up `using`s --- .../TwitterHandler.cs | 1 - .../HttpContextExtensions.cs | 2 -- .../CookiePolicyMiddleware.cs | 1 - .../AuthenticationHandlerFacts.cs | 1 - .../Cookies/Infrastructure/CookieChunkingTests.cs | 2 -- .../TokenExtensionTests.cs | 4 +--- 6 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index d7383e9393..18aa0abcb2 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; diff --git a/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs b/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs index eea17bcc3c..0d245cf0a7 100644 --- a/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication.Internal; namespace Microsoft.AspNetCore.Authentication { diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs index b8bb1264eb..7b52a58804 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Http.Features.Internal; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.CookiePolicy diff --git a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs index 431c35bdb5..aa9aef07c2 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.AspNetCore.Http.Internal; using Microsoft.Extensions.Logging; using Xunit; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs index 71590727cb..4b92f08c8d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Internal; using Xunit; namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs index ef030d1154..e8f2c16578 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -3,14 +3,12 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication.Internal; -using Microsoft.AspNetCore.Http.Internal; using Xunit; namespace Microsoft.AspNetCore.Authentication From 4d6ad51f8a9354d8e62cf8d66db97bd991b7d93c Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 31 Mar 2016 13:09:32 -0700 Subject: [PATCH 508/900] Add fallback logging for username in AuthZ --- .../DefaultAuthorizationService.cs | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 7d46ac8b82..39d35d0ddf 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; +using System.Security.Principal; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -51,16 +52,38 @@ namespace Microsoft.AspNetCore.Authorization if (authContext.HasSucceeded) { - _logger.UserAuthorizationSucceeded(user?.Identity?.Name); + _logger.UserAuthorizationSucceeded(GetUserNameForLogging(user)); return true; } else { - _logger.UserAuthorizationFailed(user?.Identity?.Name); + _logger.UserAuthorizationFailed(GetUserNameForLogging(user)); return false; } } + private string GetUserNameForLogging(ClaimsPrincipal user) + { + var identity = user?.Identity; + if (identity != null) + { + var name = identity.Name; + if (name != null) + { + return name; + } + return GetClaimValue(identity, "sub") + ?? GetClaimValue(identity, ClaimTypes.Name) + ?? GetClaimValue(identity, ClaimTypes.NameIdentifier); + } + return null; + } + + private static string GetClaimValue(IIdentity identity, string claimsType) + { + return (identity as ClaimsIdentity)?.FindFirst(claimsType)?.Value; + } + public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) { if (policyName == null) From 5cd236c1b069cebecf53dbe6380e39933986eb47 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 1 Apr 2016 14:16:49 -0700 Subject: [PATCH 509/900] Guard against null ref --- .../AuthenticationHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index ebb25af212..639be0103a 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Authentication if (ShouldHandleScheme(AuthenticationManager.AutomaticScheme, Options.AutomaticAuthenticate)) { var result = await HandleAuthenticateOnceAsync(); - if (result.Failure != null) + if (result?.Failure != null) { Logger.AuthenticationSchemeNotAuthenticatedWithFailure(Options.AuthenticationScheme, result.Failure.Message); } From 4c51e87971ec24d2ff43d92fa6a9101620e6afa1 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 6 Apr 2016 09:47:38 -0700 Subject: [PATCH 510/900] Updating to release. --- NuGet.config | 4 ++-- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 5500f6d507..71b9724a09 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..cf8bff13bb 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..f88fe4052e 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From a41c578d887f77c027e00a916085968d88e8cee7 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 7 Apr 2016 15:47:09 -0700 Subject: [PATCH 511/900] Removing imports from src projects --- .../project.json | 12 +++++------- .../project.json | 7 ++++--- .../project.json | 7 ++++--- .../project.json | 7 ++++--- .../project.json | 7 ++++--- .../project.json | 7 ++++--- .../project.json | 7 ++++--- .../project.json | 12 +++++------- .../project.json | 5 +++-- .../project.json | 15 ++++++++------- .../project.json | 12 +++++------- 11 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index b1148ce00c..82438e4025 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -13,7 +13,9 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { @@ -22,11 +24,7 @@ "Microsoft.Extensions.WebEncoders": "1.0.0-*" }, "frameworks": { - "net451": { }, - "netstandard1.3": { - "imports": [ - "dotnet5.4" - ] - } + "net451": {}, + "netstandard1.3": {} } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 2fe5040003..6639914657 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -13,17 +13,18 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" }, "frameworks": { - "net451": { }, + "net451": {}, "netstandard1.3": { "imports": [ - "dotnet5.4", "portable-net451+win8" ] } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index ed29e86ae4..9740543ec5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -13,17 +13,18 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" }, "frameworks": { - "net451": { }, + "net451": {}, "netstandard1.3": { "imports": [ - "dotnet5.4", "portable-net451+win8" ] } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 3efa9c0647..204ad1aced 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -13,7 +13,9 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { @@ -21,10 +23,9 @@ "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { - "net451": { }, + "net451": {}, "netstandard1.4": { "imports": [ - "dotnet5.5", "portable-net451+win8" ] } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index 7507e1eb4c..be1c9099e6 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -13,17 +13,18 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" }, "frameworks": { - "net451": { }, + "net451": {}, "netstandard1.3": { "imports": [ - "dotnet5.4", "portable-net451+win8" ] } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index c6658208e5..30a5c489e4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -13,7 +13,9 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { @@ -21,10 +23,9 @@ "Newtonsoft.Json": "8.0.3" }, "frameworks": { - "net451": { }, + "net451": {}, "netstandard1.3": { "imports": [ - "dotnet5.4", "portable-net451+win8" ] } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 7be775cfe0..581abf9ce1 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -13,7 +13,9 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { @@ -21,10 +23,9 @@ "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { - "net451": { }, + "net451": {}, "netstandard1.4": { "imports": [ - "dotnet5.5", "portable-net451+win8" ] } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 718d51747f..23ca0cf313 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -13,18 +13,16 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*" }, "frameworks": { - "net451": { }, - "netstandard1.3": { - "imports": [ - "dotnet5.4" - ] - } + "net451": {}, + "netstandard1.3": {} } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index f02351c2cd..ec5ff479c8 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -13,7 +13,9 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { @@ -39,7 +41,6 @@ "System.Net.Http": "4.0.1-*" }, "imports": [ - "dotnet5.4", "portable-net451" ] } diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 9d65386a8f..0d14ab8ad8 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -12,7 +12,9 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { @@ -22,16 +24,15 @@ "frameworks": { "net451": { "frameworkAssemblies": { - "System.Runtime": { "type": "build" } + "System.Runtime": { + "type": "build" + } } }, "netstandard1.3": { "dependencies": { "System.Security.Claims": "4.0.1-*" - }, - "imports": [ - "dotnet5.4" - ] + } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json index f1c7b77b91..72a86bf802 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/project.json @@ -11,7 +11,9 @@ "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { @@ -19,11 +21,7 @@ "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { - "net451": { }, - "netstandard1.3": { - "imports": [ - "dotnet5.4" - ] - } + "net451": {}, + "netstandard1.3": {} } } \ No newline at end of file From ff536cc868d8e45a62689e1d61f81328417c33e5 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 7 Apr 2016 15:23:39 -0700 Subject: [PATCH 512/900] Move web.config and use ANCM --- samples/CookieSample/Startup.cs | 2 +- samples/CookieSample/project.json | 17 ++++++++------ samples/CookieSample/web.config | 9 ++++++++ samples/CookieSample/wwwroot/.gitkeep | 0 samples/CookieSample/wwwroot/web.config | 9 -------- samples/CookieSessionSample/Startup.cs | 2 +- samples/CookieSessionSample/project.json | 17 ++++++++------ samples/CookieSessionSample/web.config | 9 ++++++++ samples/CookieSessionSample/wwwroot/.gitkeep | 0 .../CookieSessionSample/wwwroot/web.config | 9 -------- samples/JwtBearerSample/Startup.cs | 4 +--- samples/JwtBearerSample/project.json | 23 +++++++------------ samples/JwtBearerSample/web.config | 9 ++++++++ samples/JwtBearerSample/wwwroot/web.config | 9 -------- .../OpenIdConnect.AzureAdSample/Startup.cs | 4 +--- .../OpenIdConnect.AzureAdSample/project.json | 10 ++++---- .../OpenIdConnect.AzureAdSample/web.config | 9 ++++++++ .../wwwroot/web.config | 9 -------- samples/OpenIdConnectSample/Startup.cs | 4 +--- samples/OpenIdConnectSample/project.json | 15 ++++++------ samples/OpenIdConnectSample/web.config | 9 ++++++++ .../wwwroot/placeholder.html | 10 -------- .../OpenIdConnectSample/wwwroot/web.config | 9 -------- samples/SocialSample/Startup.cs | 8 +------ samples/SocialSample/project.json | 16 ++++++------- samples/SocialSample/web.config | 9 ++++++++ samples/SocialSample/wwwroot/web.config | 9 -------- 27 files changed, 108 insertions(+), 132 deletions(-) create mode 100644 samples/CookieSample/web.config delete mode 100644 samples/CookieSample/wwwroot/.gitkeep delete mode 100644 samples/CookieSample/wwwroot/web.config create mode 100644 samples/CookieSessionSample/web.config delete mode 100644 samples/CookieSessionSample/wwwroot/.gitkeep delete mode 100644 samples/CookieSessionSample/wwwroot/web.config create mode 100644 samples/JwtBearerSample/web.config delete mode 100644 samples/JwtBearerSample/wwwroot/web.config create mode 100644 samples/OpenIdConnect.AzureAdSample/web.config delete mode 100644 samples/OpenIdConnect.AzureAdSample/wwwroot/web.config create mode 100644 samples/OpenIdConnectSample/web.config delete mode 100644 samples/OpenIdConnectSample/wwwroot/placeholder.html delete mode 100644 samples/OpenIdConnectSample/wwwroot/web.config create mode 100644 samples/SocialSample/web.config delete mode 100644 samples/SocialSample/wwwroot/web.config diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 4ad27b180b..49ac74a7fa 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -47,7 +47,7 @@ namespace CookieSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index a3e9f4556d..f61695c213 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -2,7 +2,7 @@ "dependencies": { "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.DataProtection": "1.0.0-*", - "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*" @@ -10,15 +10,18 @@ "compilationOptions": { "emitEntryPoint": true }, - "commands": { - "web": "CookieSample" - }, "frameworks": { - "dnx451": {}, + "net451": {}, "netstandardapp1.5": { "imports": [ "dnxcore50" - ] + ], + "dependencies": { + "NETStandard.Library": "1.5.0-*" + } } - } + }, + "content": [ + "web.config" + ] } \ No newline at end of file diff --git a/samples/CookieSample/web.config b/samples/CookieSample/web.config new file mode 100644 index 0000000000..8d61177619 --- /dev/null +++ b/samples/CookieSample/web.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/samples/CookieSample/wwwroot/.gitkeep b/samples/CookieSample/wwwroot/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/samples/CookieSample/wwwroot/web.config b/samples/CookieSample/wwwroot/web.config deleted file mode 100644 index 9a0d90abf8..0000000000 --- a/samples/CookieSample/wwwroot/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 7843f66a1f..d3b72bae20 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -57,7 +57,7 @@ namespace CookieSessionSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index e60b1b355c..deff15e38d 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -2,7 +2,7 @@ "dependencies": { "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.DataProtection": "1.0.0-*", - "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Caching.Memory": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", @@ -11,15 +11,18 @@ "compilationOptions": { "emitEntryPoint": true }, - "commands": { - "web": "CookieSessionSample" - }, "frameworks": { - "dnx451": {}, + "net451": {}, "netstandardapp1.5": { "imports": [ "dnxcore50" - ] + ], + "dependencies": { + "NETStandard.Library": "1.5.0-*" + } } - } + }, + "content": [ + "web.config" + ] } \ No newline at end of file diff --git a/samples/CookieSessionSample/web.config b/samples/CookieSessionSample/web.config new file mode 100644 index 0000000000..fb7e915bfd --- /dev/null +++ b/samples/CookieSessionSample/web.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/samples/CookieSessionSample/wwwroot/.gitkeep b/samples/CookieSessionSample/wwwroot/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/samples/CookieSessionSample/wwwroot/web.config b/samples/CookieSessionSample/wwwroot/web.config deleted file mode 100644 index 9a0d90abf8..0000000000 --- a/samples/CookieSessionSample/wwwroot/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index b0c2464f87..9916955c36 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -54,8 +54,6 @@ namespace JwtBearerSample } }); - app.UseIISPlatformHandler(); - app.UseDefaultFiles(); app.UseStaticFiles(); @@ -115,7 +113,7 @@ namespace JwtBearerSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index a271c2b5c7..f940b1b103 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -5,34 +5,27 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*", - "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*" }, - "commands": { - "web": "JwtBearerSample" - }, "frameworks": { - "dnx451": { }, + "net451": { }, "netstandardapp1.5": { "imports": [ "dnxcore50" - ] + ], + "dependencies": { + "NETStandard.Library": "1.5.0-*" + } } }, - "exclude": [ - "wwwroot", - "node_modules" - ], - "publishExclude": [ - "**.user", - "**.vspscc" - ], "content": [ "project.json", - "wwwroot" + "wwwroot", + "web.config" ], "userSecretsId": "aspnet5-JwtBearerSample-20151210102827" } \ No newline at end of file diff --git a/samples/JwtBearerSample/web.config b/samples/JwtBearerSample/web.config new file mode 100644 index 0000000000..801dbfd85b --- /dev/null +++ b/samples/JwtBearerSample/web.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/samples/JwtBearerSample/wwwroot/web.config b/samples/JwtBearerSample/wwwroot/web.config deleted file mode 100644 index 8485f6719f..0000000000 --- a/samples/JwtBearerSample/wwwroot/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 3a73a090ac..5841d6f2eb 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -62,8 +62,6 @@ namespace OpenIdConnect.AzureAdSample } }); - app.UseIISPlatformHandler(); - app.UseCookieAuthentication(new CookieAuthenticationOptions()); var clientId = Configuration["oidc:clientid"]; @@ -158,7 +156,7 @@ namespace OpenIdConnect.AzureAdSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index fd74610190..6c7adf7f2d 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -2,7 +2,7 @@ "dependencies": { "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", - "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", @@ -10,16 +10,14 @@ "Microsoft.NETCore.Platforms": "1.0.1-*" }, "frameworks": { - "dnx451": { } + "net451": { } }, "compilationOptions": { "emitEntryPoint": true }, - "commands": { - "web": "OpenIdConnect.AzureAdSample" - }, "content": [ - "project.json" + "project.json", + "web.config" ], "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" } \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/web.config b/samples/OpenIdConnect.AzureAdSample/web.config new file mode 100644 index 0000000000..cdcb5a6149 --- /dev/null +++ b/samples/OpenIdConnect.AzureAdSample/web.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/wwwroot/web.config b/samples/OpenIdConnect.AzureAdSample/wwwroot/web.config deleted file mode 100644 index 8485f6719f..0000000000 --- a/samples/OpenIdConnect.AzureAdSample/wwwroot/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 76ac7c7120..1591ac1196 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -57,8 +57,6 @@ namespace OpenIdConnectSample } }); - app.UseIISPlatformHandler(); - app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions @@ -104,7 +102,7 @@ namespace OpenIdConnectSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 4fd829a22c..cd923e7e01 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -2,28 +2,29 @@ "dependencies": { "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", - "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*" }, "frameworks": { - "dnx451": { }, + "net451": { }, "netstandardapp1.5": { "imports": [ "dnxcore50" - ] + ], + "dependencies": { + "NETStandard.Library": "1.5.0-*" + } } }, "compilationOptions": { "emitEntryPoint": true }, - "commands": { - "web": "OpenIdConnectSample" - }, "content": [ - "project.json" + "project.json", + "web.config" ], "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" } \ No newline at end of file diff --git a/samples/OpenIdConnectSample/web.config b/samples/OpenIdConnectSample/web.config new file mode 100644 index 0000000000..b1b731ccef --- /dev/null +++ b/samples/OpenIdConnectSample/web.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/samples/OpenIdConnectSample/wwwroot/placeholder.html b/samples/OpenIdConnectSample/wwwroot/placeholder.html deleted file mode 100644 index 125a5a8cf1..0000000000 --- a/samples/OpenIdConnectSample/wwwroot/placeholder.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/samples/OpenIdConnectSample/wwwroot/web.config b/samples/OpenIdConnectSample/wwwroot/web.config deleted file mode 100644 index 9a0d90abf8..0000000000 --- a/samples/OpenIdConnectSample/wwwroot/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 0e13b78e92..156af2a5c7 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -73,12 +73,6 @@ namespace SocialSample } }); - // Forward the scheme from IISPlatformHandler - app.UseForwardedHeaders(new ForwardedHeadersOptions() - { - ForwardedHeaders = ForwardedHeaders.XForwardedProto, - }); - app.UseCookieAuthentication(new CookieAuthenticationOptions { AutomaticAuthenticate = true, @@ -344,7 +338,7 @@ namespace SocialSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration()() .UseStartup() .Build(); diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 1d02230294..edf9129fd8 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -6,8 +6,7 @@ "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-*", "Microsoft.AspNetCore.DataProtection": "1.0.0-*", - "Microsoft.AspNetCore.HttpOverrides": "1.0.0-*", - "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", @@ -18,20 +17,21 @@ "compilationOptions": { "emitEntryPoint": true }, - "commands": { - "web": "SocialSample" - }, "frameworks": { - "dnx451": {}, + "net451": {}, "netstandardapp1.5": { "imports": [ "dnxcore50" - ] + ], + "dependencies": { + "NETStandard.Library": "1.5.0-*" + } } }, "userSecretsId": "aspnet5-SocialSample-20151210111056", "content": [ "config.json", - "project.json" + "project.json", + "web.config" ] } diff --git a/samples/SocialSample/web.config b/samples/SocialSample/web.config new file mode 100644 index 0000000000..5611f93f11 --- /dev/null +++ b/samples/SocialSample/web.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/samples/SocialSample/wwwroot/web.config b/samples/SocialSample/wwwroot/web.config deleted file mode 100644 index 9a0d90abf8..0000000000 --- a/samples/SocialSample/wwwroot/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file From 300b9cd90f7e32095355fcb3d4d0a3a5b0fa8aa0 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 11 Apr 2016 11:48:44 -0700 Subject: [PATCH 513/900] Fix typo when migrating to ANCM --- samples/CookieSample/Startup.cs | 2 +- samples/CookieSessionSample/Startup.cs | 2 +- samples/JwtBearerSample/Startup.cs | 2 +- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- samples/OpenIdConnectSample/Startup.cs | 2 +- samples/SocialSample/Startup.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 49ac74a7fa..c2593c9090 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -47,7 +47,7 @@ namespace CookieSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISIntegration()() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index d3b72bae20..423c961206 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -57,7 +57,7 @@ namespace CookieSessionSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISIntegration()() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 9916955c36..c2dbfb7a9d 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -113,7 +113,7 @@ namespace JwtBearerSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISIntegration()() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 5841d6f2eb..938a19c201 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -156,7 +156,7 @@ namespace OpenIdConnect.AzureAdSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISIntegration()() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 1591ac1196..097ce771bc 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -102,7 +102,7 @@ namespace OpenIdConnectSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISIntegration()() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 156af2a5c7..e002894ce0 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -338,7 +338,7 @@ namespace SocialSample var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISIntegration()() + .UseIISIntegration() .UseStartup() .Build(); From 669c06098b387c32786cd1bbdb312e18620cea5c Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Wed, 13 Apr 2016 17:57:25 -0700 Subject: [PATCH 514/900] React to Kestrel config changes - aspnet/KestrelHttpServer#720 --- samples/SocialSample/Startup.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index e002894ce0..f109d65feb 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -51,10 +51,6 @@ namespace SocialSample { loggerfactory.AddConsole(LogLevel.Information); - //Configure SSL - var serverCertificate = LoadCertificate(); - app.UseKestrelHttps(serverCertificate); - // Simple error page to avoid a repo dependency. app.Use(async (context, next) => { @@ -337,7 +333,12 @@ namespace SocialSample { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) - .UseKestrel() + .UseKestrel(options => + { + //Configure SSL + var serverCertificate = LoadCertificate(); + options.UseHttps(serverCertificate); + }) .UseIISIntegration() .UseStartup() .Build(); @@ -345,9 +346,9 @@ namespace SocialSample host.Run(); } - private X509Certificate2 LoadCertificate() + private static X509Certificate2 LoadCertificate() { - var socialSampleAssembly = GetType().GetTypeInfo().Assembly; + var socialSampleAssembly = typeof(Startup).GetTypeInfo().Assembly; var embeddedFileProvider = new EmbeddedFileProvider(socialSampleAssembly, "SocialSample"); var certificateFileInfo = embeddedFileProvider.GetFileInfo("compiler/resources/cert.pfx"); using (var certificateStream = certificateFileInfo.CreateReadStream()) From 8023d1eb027efa890d931a26ad29668821e2a05f Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Thu, 14 Apr 2016 13:52:39 -0700 Subject: [PATCH 515/900] Add serialization.primitives for Newtonsoft.Json --- src/Microsoft.AspNetCore.Authentication.OAuth/project.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index 30a5c489e4..a3b553c5d1 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -20,7 +20,8 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", - "Newtonsoft.Json": "8.0.3" + "Newtonsoft.Json": "8.0.3", + "System.Runtime.Serialization.Primitives": "4.1.1-*" }, "frameworks": { "net451": {}, From 3db1f1e9fd40fbdf1a283f17e1d6f1eb69331a0f Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Thu, 14 Apr 2016 15:41:40 -0700 Subject: [PATCH 516/900] Move dependency to netstandard only --- src/Microsoft.AspNetCore.Authentication.OAuth/project.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index a3b553c5d1..a4ee111667 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -20,12 +20,14 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", - "Newtonsoft.Json": "8.0.3", - "System.Runtime.Serialization.Primitives": "4.1.1-*" + "Newtonsoft.Json": "8.0.3" }, "frameworks": { "net451": {}, "netstandard1.3": { + "dependencies": { + "System.Runtime.Serialization.Primitives": "4.1.1-*" + }, "imports": [ "portable-net451+win8" ] From f6557c821d9c7750f13a64a7cd73063b642af16e Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 15 Apr 2016 09:48:24 -0700 Subject: [PATCH 517/900] Migrate tests, tools and samples to portable --- samples/CookieSample/project.json | 10 ++++++---- samples/CookieSessionSample/project.json | 10 ++++++---- samples/JwtBearerSample/project.json | 12 +++++++----- samples/OpenIdConnectSample/project.json | 12 +++++++----- samples/SocialSample/project.json | 14 ++++++++------ .../project.json | 7 +++++-- .../project.json | 7 +++++-- .../project.json | 7 +++++-- 8 files changed, 49 insertions(+), 30 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index f61695c213..45bf301882 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -4,20 +4,22 @@ "Microsoft.AspNetCore.DataProtection": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "compilationOptions": { "emitEntryPoint": true }, "frameworks": { "net451": {}, - "netstandardapp1.5": { + "netcoreapp1.0": { "imports": [ "dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-*" + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } } } }, diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index deff15e38d..47ed4e9192 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -5,20 +5,22 @@ "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Caching.Memory": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "compilationOptions": { "emitEntryPoint": true }, "frameworks": { "net451": {}, - "netstandardapp1.5": { + "netcoreapp1.0": { "imports": [ "dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-*" + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } } } }, diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index f940b1b103..829ec7fa8b 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -8,17 +8,19 @@ "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*" + "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*" }, "frameworks": { - "net451": { }, - "netstandardapp1.5": { + "net451": {}, + "netcoreapp1.0": { "imports": [ "dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-*" + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } } } }, diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index cd923e7e01..faeb6a0ee6 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -5,17 +5,19 @@ "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "frameworks": { - "net451": { }, - "netstandardapp1.5": { + "net451": {}, + "netcoreapp1.0": { "imports": [ "dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-*" + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } } } }, diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index edf9129fd8..66ab3ede66 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -10,21 +10,23 @@ "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", - "Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*" + "Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*", + "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "compilationOptions": { "emitEntryPoint": true }, "frameworks": { "net451": {}, - "netstandardapp1.5": { + "netcoreapp1.0": { "imports": [ "dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-*" + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } } } }, @@ -34,4 +36,4 @@ "project.json", "web.config" ] -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 07137861a4..79219ed228 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -15,10 +15,13 @@ "xunit": "2.1.0" }, "frameworks": { - "netstandardapp1.5": { + "netcoreapp1.0": { "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + }, "dotnet-test-xunit": "1.0.0-dev-*", - "NETStandard.Library": "1.5.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 0bc8910ce9..3002b7368c 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -10,10 +10,13 @@ "xunit": "2.1.0" }, "frameworks": { - "netstandardapp1.5": { + "netcoreapp1.0": { "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + }, "dotnet-test-xunit": "1.0.0-dev-*", - "NETStandard.Library": "1.5.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 8d529ea87c..66b67c062b 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -9,10 +9,13 @@ "xunit": "2.1.0" }, "frameworks": { - "netstandardapp1.5": { + "netcoreapp1.0": { "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + }, "dotnet-test-xunit": "1.0.0-dev-*", - "NETStandard.Library": "1.5.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ From e3667f7c26c90ab277fe472aca070e21befc2f49 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 18 Apr 2016 17:05:20 -0700 Subject: [PATCH 518/900] Bring Microsoft.NETCore.Platforms dependency back --- samples/CookieSample/project.json | 1 + samples/CookieSessionSample/project.json | 1 + samples/JwtBearerSample/project.json | 1 + samples/OpenIdConnect.AzureAdSample/project.json | 8 ++++---- samples/OpenIdConnectSample/project.json | 1 + samples/SocialSample/project.json | 1 + .../Microsoft.AspNetCore.Authentication.Test/project.json | 1 + test/Microsoft.AspNetCore.Authorization.Test/project.json | 1 + test/Microsoft.AspNetCore.CookiePolicy.Test/project.json | 1 + test/Microsoft.Owin.Security.Interop.Test/project.json | 6 +++--- 10 files changed, 15 insertions(+), 7 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 45bf301882..531ea474cd 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.DataProtection": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index 47ed4e9192..c1aee49c15 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.DataProtection": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 829ec7fa8b..29ecf01579 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -4,6 +4,7 @@ "emitEntryPoint": true }, "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 6c7adf7f2d..b6879e5775 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -1,16 +1,16 @@ -{ +{ "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", - "Microsoft.IdentityModel.Clients.ActiveDirectory": "2.22.302111727", - "Microsoft.NETCore.Platforms": "1.0.1-*" + "Microsoft.IdentityModel.Clients.ActiveDirectory": "2.22.302111727" }, "frameworks": { - "net451": { } + "net451": {} }, "compilationOptions": { "emitEntryPoint": true diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index faeb6a0ee6..553e170fc5 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 66ab3ede66..fe1d2bfdc5 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*", diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 79219ed228..b1ac8e97cc 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -3,6 +3,7 @@ "warningsAsErrors": true }, "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*", diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 3002b7368c..721986616a 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -3,6 +3,7 @@ "warningsAsErrors": true }, "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authorization": "1.0.0-*", "Microsoft.AspNetCore.Testing": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 66b67c062b..f2283ce4f3 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -3,6 +3,7 @@ "warningsAsErrors": true }, "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.CookiePolicy": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index 0f156822df..dac3f8185e 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -3,6 +3,7 @@ "warningsAsErrors": true }, "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Owin.Security.Cookies": "3.0.1", @@ -13,12 +14,11 @@ }, "frameworks": { "net451": { - "frameworkAssemblies": { + "frameworkAssemblies": { "System.Runtime": "", "System.Threading.Tasks": "" } } }, "testRunner": "xunit" -} - +} \ No newline at end of file From 85b5eb28a04517167141650eda6427bfa466ccbc Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 19 Apr 2016 14:54:11 -0700 Subject: [PATCH 519/900] Use latest build of dotnet-test-xunit --- test/Microsoft.AspNetCore.Authentication.Test/project.json | 2 +- test/Microsoft.AspNetCore.Authorization.Test/project.json | 2 +- test/Microsoft.AspNetCore.CookiePolicy.Test/project.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index b1ac8e97cc..931b20be10 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -22,7 +22,7 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-dev-*", + "dotnet-test-xunit": "1.0.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 721986616a..a16a0ba374 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -17,7 +17,7 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-dev-*", + "dotnet-test-xunit": "1.0.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index f2283ce4f3..bb388af16f 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -16,7 +16,7 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-dev-*", + "dotnet-test-xunit": "1.0.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ From c06cac5d307ab6cc2904bccb9591b6cd0748a1af Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 21 Apr 2016 14:46:40 -0700 Subject: [PATCH 520/900] #744 Change OIDC's default ResponseType to IdToken. --- .../OpenIdConnectOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index acf9d77e40..cdbc9e0f0d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -148,7 +148,7 @@ namespace Microsoft.AspNetCore.Builder /// /// Gets or sets the 'response_type'. /// - public string ResponseType { get; set; } = OpenIdConnectResponseTypes.CodeIdToken; + public string ResponseType { get; set; } = OpenIdConnectResponseTypes.IdToken; /// /// Gets the list of permissions to request. From 6e3ff403d4981cc276e3a262dc4263c74cfe2fdc Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Fri, 22 Apr 2016 09:32:34 -0700 Subject: [PATCH 521/900] [Fixes #794] Exception thrown when 'Microsoft.AspNetCore.Authentication.JwtBearer' tries to log a message --- .../LoggingExtensions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs index 643da92906..008190f516 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs @@ -8,7 +8,7 @@ namespace Microsoft.Extensions.Logging internal static class LoggingExtensions { private static Action _tokenValidationFailed; - private static Action _tokenValidationSucceeded; + private static Action _tokenValidationSucceeded; private static Action _errorProcessingMessage; static LoggingExtensions() @@ -17,7 +17,7 @@ namespace Microsoft.Extensions.Logging eventId: 1, logLevel: LogLevel.Information, formatString: "Failed to validate the token {Token}."); - _tokenValidationSucceeded = LoggerMessage.Define( + _tokenValidationSucceeded = LoggerMessage.Define( eventId: 2, logLevel: LogLevel.Information, formatString: "Successfully validated the token."); @@ -34,7 +34,7 @@ namespace Microsoft.Extensions.Logging public static void TokenValidationSucceeded(this ILogger logger) { - _tokenValidationSucceeded(logger, null, null); + _tokenValidationSucceeded(logger, null); } public static void ErrorProcessingMessage(this ILogger logger, Exception ex) From 0cd7c7236bd2e3132378df4fe17862dd9ee1d9ab Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 25 Apr 2016 12:15:04 -0700 Subject: [PATCH 522/900] React to FormReader api change. --- .../TwitterHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 18aa0abcb2..fdb7e3e077 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -202,7 +202,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter response.EnsureSuccessStatusCode(); string responseText = await response.Content.ReadAsStringAsync(); - var responseParameters = new FormCollection(FormReader.ReadForm(responseText)); + var responseParameters = new FormCollection(new FormReader(responseText).ReadForm()); if (!string.Equals(responseParameters["oauth_callback_confirmed"], "true", StringComparison.Ordinal)) { throw new Exception("Twitter oauth_callback_confirmed is not true."); @@ -277,7 +277,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter } var responseText = await response.Content.ReadAsStringAsync(); - var responseParameters = new FormCollection(FormReader.ReadForm(responseText)); + var responseParameters = new FormCollection(new FormReader(responseText).ReadForm()); return new AccessToken { From 32cb95c3eedc13333976a8f38b18665987f80796 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Mon, 25 Apr 2016 13:07:00 -0700 Subject: [PATCH 523/900] Update web.config and add publish tool --- samples/CookieSample/project.json | 11 ++++++++++- samples/CookieSample/web.config | 2 +- samples/CookieSessionSample/project.json | 11 ++++++++++- samples/CookieSessionSample/web.config | 2 +- samples/JwtBearerSample/project.json | 11 ++++++++++- samples/JwtBearerSample/web.config | 2 +- samples/OpenIdConnect.AzureAdSample/project.json | 11 ++++++++++- samples/OpenIdConnect.AzureAdSample/web.config | 2 +- samples/OpenIdConnectSample/project.json | 11 ++++++++++- samples/OpenIdConnectSample/web.config | 2 +- samples/SocialSample/project.json | 11 ++++++++++- samples/SocialSample/web.config | 2 +- 12 files changed, 66 insertions(+), 12 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 531ea474cd..6da446848e 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -26,5 +26,14 @@ }, "content": [ "web.config" - ] + ], + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": { + "version": "1.0.0-*", + "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" + } + }, + "scripts": { + "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" + } } \ No newline at end of file diff --git a/samples/CookieSample/web.config b/samples/CookieSample/web.config index 8d61177619..f7ac679334 100644 --- a/samples/CookieSample/web.config +++ b/samples/CookieSample/web.config @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index c1aee49c15..3c83173804 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -27,5 +27,14 @@ }, "content": [ "web.config" - ] + ], + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": { + "version": "1.0.0-*", + "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" + } + }, + "scripts": { + "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" + } } \ No newline at end of file diff --git a/samples/CookieSessionSample/web.config b/samples/CookieSessionSample/web.config index fb7e915bfd..f7ac679334 100644 --- a/samples/CookieSessionSample/web.config +++ b/samples/CookieSessionSample/web.config @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 29ecf01579..c0b448b72c 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -30,5 +30,14 @@ "wwwroot", "web.config" ], - "userSecretsId": "aspnet5-JwtBearerSample-20151210102827" + "userSecretsId": "aspnet5-JwtBearerSample-20151210102827", + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": { + "version": "1.0.0-*", + "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" + } + }, + "scripts": { + "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" + } } \ No newline at end of file diff --git a/samples/JwtBearerSample/web.config b/samples/JwtBearerSample/web.config index 801dbfd85b..f7ac679334 100644 --- a/samples/JwtBearerSample/web.config +++ b/samples/JwtBearerSample/web.config @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index b6879e5775..da801b5c2d 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -19,5 +19,14 @@ "project.json", "web.config" ], - "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" + "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318", + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": { + "version": "1.0.0-*", + "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" + } + }, + "scripts": { + "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" + } } \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/web.config b/samples/OpenIdConnect.AzureAdSample/web.config index cdcb5a6149..f7ac679334 100644 --- a/samples/OpenIdConnect.AzureAdSample/web.config +++ b/samples/OpenIdConnect.AzureAdSample/web.config @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 553e170fc5..b907b68f98 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -29,5 +29,14 @@ "project.json", "web.config" ], - "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" + "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318", + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": { + "version": "1.0.0-*", + "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" + } + }, + "scripts": { + "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" + } } \ No newline at end of file diff --git a/samples/OpenIdConnectSample/web.config b/samples/OpenIdConnectSample/web.config index b1b731ccef..f7ac679334 100644 --- a/samples/OpenIdConnectSample/web.config +++ b/samples/OpenIdConnectSample/web.config @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index fe1d2bfdc5..c37c5f2b16 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -36,5 +36,14 @@ "config.json", "project.json", "web.config" - ] + ], + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": { + "version": "1.0.0-*", + "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" + } + }, + "scripts": { + "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" + } } \ No newline at end of file diff --git a/samples/SocialSample/web.config b/samples/SocialSample/web.config index 5611f93f11..f7ac679334 100644 --- a/samples/SocialSample/web.config +++ b/samples/SocialSample/web.config @@ -4,6 +4,6 @@ - + \ No newline at end of file From bb7290e9e1ce3552c47c4e4ed41e0f330a780cc2 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 27 Apr 2016 15:28:21 -0700 Subject: [PATCH 524/900] Remove references to UseDefaultConfiguration --- samples/CookieSample/Startup.cs | 1 - samples/CookieSessionSample/Startup.cs | 1 - samples/JwtBearerSample/Startup.cs | 1 - samples/OpenIdConnect.AzureAdSample/Startup.cs | 1 - samples/OpenIdConnectSample/Startup.cs | 1 - samples/SocialSample/Startup.cs | 1 - 6 files changed, 6 deletions(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index c2593c9090..768415f0ce 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -45,7 +45,6 @@ namespace CookieSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultHostingConfiguration(args) .UseKestrel() .UseIISIntegration() .UseStartup() diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 423c961206..4d3ea3aa67 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -55,7 +55,6 @@ namespace CookieSessionSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultHostingConfiguration(args) .UseKestrel() .UseIISIntegration() .UseStartup() diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index c2dbfb7a9d..b2df5033e4 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -111,7 +111,6 @@ namespace JwtBearerSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultHostingConfiguration(args) .UseKestrel() .UseIISIntegration() .UseStartup() diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 938a19c201..7d8cf23461 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -154,7 +154,6 @@ namespace OpenIdConnect.AzureAdSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultHostingConfiguration(args) .UseKestrel() .UseIISIntegration() .UseStartup() diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 097ce771bc..ff68b471fa 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -100,7 +100,6 @@ namespace OpenIdConnectSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultHostingConfiguration(args) .UseKestrel() .UseIISIntegration() .UseStartup() diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index f109d65feb..bf09b3f6f2 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -332,7 +332,6 @@ namespace SocialSample public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultHostingConfiguration(args) .UseKestrel(options => { //Configure SSL From 0bce133ee4c267484e36cc98f9ccf25f698761d7 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 28 Apr 2016 10:18:01 -0700 Subject: [PATCH 525/900] #765 Retrieve the email address from Twitter. --- samples/SocialSample/Startup.cs | 19 +++- samples/SocialSample/config.json | 4 +- .../Events/TwitterCreatingTicketContext.cs | 20 +++- .../LoggingExtensions.cs | 10 ++ .../TwitterHandler.cs | 102 +++++++++++++++--- .../TwitterOptions.cs | 8 ++ .../project.json | 9 +- 7 files changed, 150 insertions(+), 22 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index bf09b3f6f2..474e43ae75 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -125,9 +125,18 @@ namespace SocialSample { ConsumerKey = Configuration["twitter:consumerkey"], ConsumerSecret = Configuration["twitter:consumersecret"], + // http://stackoverflow.com/questions/22627083/can-we-get-email-id-from-twitter-oauth-api/32852370#32852370 + // http://stackoverflow.com/questions/36330675/get-users-email-from-twitter-api-for-external-login-authentication-asp-net-mvc?lq=1 + RetrieveUserDetails = true, SaveTokens = true, Events = new TwitterEvents() { + OnCreatingTicket = ctx => + { + var profilePic = ctx.User.Value("profile_image_url"); + ctx.Principal.Identities.First().AddClaim(new Claim("urn:twitter:profilepicture", profilePic, ClaimTypes.Uri, ctx.Options.ClaimsIssuer)); + return Task.FromResult(0); + }, OnRemoteFailure = ctx => { ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); @@ -139,7 +148,7 @@ namespace SocialSample /* Azure AD app model v2 has restrictions that prevent the use of plain HTTP for redirect URLs. Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL: - https://localhost:54541/ + https://localhost:44318/ */ // See config.json // https://apps.dev.microsoft.com/ @@ -232,6 +241,14 @@ namespace SocialSample ClaimValueTypes.String, context.Options.ClaimsIssuer)); } + var email = user.Value("email"); + if (!string.IsNullOrEmpty(email)) + { + context.Identity.AddClaim(new Claim( + ClaimTypes.Email, email, + ClaimValueTypes.Email, context.Options.ClaimsIssuer)); + } + var link = user.Value("url"); if (!string.IsNullOrEmpty(link)) { diff --git a/samples/SocialSample/config.json b/samples/SocialSample/config.json index 5c1453e39f..11477998c0 100644 --- a/samples/SocialSample/config.json +++ b/samples/SocialSample/config.json @@ -1,8 +1,8 @@ { "google:clientid": "560027070069-37ldt4kfuohhu3m495hk2j4pjp92d382.apps.googleusercontent.com", "google:clientsecret": "n2Q-GEw9RQjzcRbU3qhfTj8f", - "twitter:consumerkey": "6XaCTaLbMqfj6ww3zvZ5g", - "twitter:consumersecret": "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI", + "twitter:consumerkey": "VvNJRyGeqYBByN694UHudI2cv", + "twitter:consumersecret": "V2xEqWgmphPdlUXX4ARWsozl9lfbvr5wbAYw2LN8m6kZV7pt20", "github:clientid": "49e302895d8b09ea5656", "github:clientsecret": "98f1bf028608901e9df91d64ee61536fe562064b", "github-token:clientid": "8c0c5a572abe8fe89588", diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs index 04a45ac6d8..435196a1e5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs @@ -5,6 +5,7 @@ using System.Security.Claims; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; +using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.Twitter { @@ -22,40 +23,49 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// Twitter screen name /// Twitter access token /// Twitter access token secret + /// User details public TwitterCreatingTicketContext( HttpContext context, TwitterOptions options, string userId, string screenName, string accessToken, - string accessTokenSecret) + string accessTokenSecret, + JObject user) : base(context, options) { UserId = userId; ScreenName = screenName; AccessToken = accessToken; AccessTokenSecret = accessTokenSecret; + User = user ?? new JObject(); } /// /// Gets the Twitter user ID /// - public string UserId { get; private set; } + public string UserId { get; } /// /// Gets the Twitter screen name /// - public string ScreenName { get; private set; } + public string ScreenName { get; } /// /// Gets the Twitter access token /// - public string AccessToken { get; private set; } + public string AccessToken { get; } /// /// Gets the Twitter access token secret /// - public string AccessTokenSecret { get; private set; } + public string AccessTokenSecret { get; } + + /// + /// Gets the JSON-serialized user or an empty + /// if it is not available. + /// + public JObject User { get; } /// /// Gets the representing the user diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs index 21a4ac541d..2a2cd5da79 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs @@ -9,6 +9,7 @@ namespace Microsoft.Extensions.Logging { private static Action _obtainRequestToken; private static Action _obtainAccessToken; + private static Action _retrieveUserDetails; static LoggingExtensions() { @@ -20,6 +21,10 @@ namespace Microsoft.Extensions.Logging eventId: 2, logLevel: LogLevel.Debug, formatString: "ObtainAccessToken"); + _retrieveUserDetails = LoggerMessage.Define( + eventId: 3, + logLevel: LogLevel.Debug, + formatString: "RetrieveUserDetails"); } @@ -32,5 +37,10 @@ namespace Microsoft.Extensions.Logging { _obtainRequestToken(logger, null); } + + public static void RetrieveUserDetails(this ILogger logger) + { + _retrieveUserDetails(logger, null); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index fdb7e3e077..4fbf35aaa1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; +using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.Twitter { @@ -76,7 +77,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter Response.Cookies.Delete(StateCookie, cookieOptions); - var accessToken = await ObtainAccessTokenAsync(Options.ConsumerKey, Options.ConsumerSecret, requestToken, oauthVerifier); + var accessToken = await ObtainAccessTokenAsync(requestToken, oauthVerifier); var identity = new ClaimsIdentity(new[] { @@ -87,6 +88,12 @@ namespace Microsoft.AspNetCore.Authentication.Twitter }, Options.ClaimsIssuer); + JObject user = null; + if (Options.RetrieveUserDetails) + { + user = await RetrieveUserDetailsAsync(accessToken, identity); + } + if (Options.SaveTokens) { properties.StoreTokens(new [] { @@ -95,12 +102,13 @@ namespace Microsoft.AspNetCore.Authentication.Twitter }); } - return AuthenticateResult.Success(await CreateTicketAsync(identity, properties, accessToken)); + return AuthenticateResult.Success(await CreateTicketAsync(identity, properties, accessToken, user)); } - protected virtual async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, AccessToken token) + protected virtual async Task CreateTicketAsync( + ClaimsIdentity identity, AuthenticationProperties properties, AccessToken token, JObject user) { - var context = new TwitterCreatingTicketContext(Context, Options, token.UserId, token.ScreenName, token.Token, token.TokenSecret) + var context = new TwitterCreatingTicketContext(Context, Options, token.UserId, token.ScreenName, token.Token, token.TokenSecret, user) { Principal = new ClaimsPrincipal(identity), Properties = properties @@ -134,7 +142,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter } // If CallbackConfirmed is false, this will throw - var requestToken = await ObtainRequestTokenAsync(Options.ConsumerKey, Options.ConsumerSecret, BuildRedirectUri(Options.CallbackPath), properties); + var requestToken = await ObtainRequestTokenAsync(BuildRedirectUri(Options.CallbackPath), properties); var twitterAuthenticationEndpoint = AuthenticationEndpoint + requestToken.Token; var cookieOptions = new CookieOptions @@ -152,7 +160,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter return true; } - private async Task ObtainRequestTokenAsync(string consumerKey, string consumerSecret, string callBackUri, AuthenticationProperties properties) + private async Task ObtainRequestTokenAsync(string callBackUri, AuthenticationProperties properties) { Logger.ObtainRequestToken(); @@ -161,7 +169,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var authorizationParts = new SortedDictionary { { "oauth_callback", callBackUri }, - { "oauth_consumer_key", consumerKey }, + { "oauth_consumer_key", Options.ConsumerKey }, { "oauth_nonce", nonce }, { "oauth_signature_method", "HMAC-SHA1" }, { "oauth_timestamp", GenerateTimeStamp() }, @@ -183,7 +191,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter canonicalizedRequestBuilder.Append("&"); canonicalizedRequestBuilder.Append(UrlEncoder.Encode(parameterString)); - var signature = ComputeSignature(consumerSecret, null, canonicalizedRequestBuilder.ToString()); + var signature = ComputeSignature(Options.ConsumerSecret, null, canonicalizedRequestBuilder.ToString()); authorizationParts.Add("oauth_signature", signature); var authorizationHeaderBuilder = new StringBuilder(); @@ -200,7 +208,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var response = await _httpClient.SendAsync(request, Context.RequestAborted); response.EnsureSuccessStatusCode(); - string responseText = await response.Content.ReadAsStringAsync(); + var responseText = await response.Content.ReadAsStringAsync(); var responseParameters = new FormCollection(new FormReader(responseText).ReadForm()); if (!string.Equals(responseParameters["oauth_callback_confirmed"], "true", StringComparison.Ordinal)) @@ -211,7 +219,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter return new RequestToken { Token = Uri.UnescapeDataString(responseParameters["oauth_token"]), TokenSecret = Uri.UnescapeDataString(responseParameters["oauth_token_secret"]), CallbackConfirmed = true, Properties = properties }; } - private async Task ObtainAccessTokenAsync(string consumerKey, string consumerSecret, RequestToken token, string verifier) + private async Task ObtainAccessTokenAsync(RequestToken token, string verifier) { // https://dev.twitter.com/docs/api/1/post/oauth/access_token @@ -221,7 +229,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var authorizationParts = new SortedDictionary { - { "oauth_consumer_key", consumerKey }, + { "oauth_consumer_key", Options.ConsumerKey }, { "oauth_nonce", nonce }, { "oauth_signature_method", "HMAC-SHA1" }, { "oauth_token", token.Token }, @@ -245,7 +253,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter canonicalizedRequestBuilder.Append("&"); canonicalizedRequestBuilder.Append(UrlEncoder.Encode(parameterString)); - var signature = ComputeSignature(consumerSecret, token.TokenSecret, canonicalizedRequestBuilder.ToString()); + var signature = ComputeSignature(Options.ConsumerSecret, token.TokenSecret, canonicalizedRequestBuilder.ToString()); authorizationParts.Add("oauth_signature", signature); authorizationParts.Remove("oauth_verifier"); @@ -288,6 +296,76 @@ namespace Microsoft.AspNetCore.Authentication.Twitter }; } + // https://dev.twitter.com/rest/reference/get/account/verify_credentials + private async Task RetrieveUserDetailsAsync(AccessToken accessToken, ClaimsIdentity identity) + { + Logger.RetrieveUserDetails(); + + var nonce = Guid.NewGuid().ToString("N"); + + var authorizationParts = new SortedDictionary + { + { "oauth_consumer_key", Options.ConsumerKey }, + { "oauth_nonce", nonce }, + { "oauth_signature_method", "HMAC-SHA1" }, + { "oauth_timestamp", GenerateTimeStamp() }, + { "oauth_token", accessToken.Token }, + { "oauth_version", "1.0" } + }; + + var parameterBuilder = new StringBuilder(); + foreach (var authorizationKey in authorizationParts) + { + parameterBuilder.AppendFormat("{0}={1}&", UrlEncoder.Encode(authorizationKey.Key), UrlEncoder.Encode(authorizationKey.Value)); + } + parameterBuilder.Length--; + var parameterString = parameterBuilder.ToString(); + + var resource_url = "https://api.twitter.com/1.1/account/verify_credentials.json"; + var resource_query = "include_email=true"; + var canonicalizedRequestBuilder = new StringBuilder(); + canonicalizedRequestBuilder.Append(HttpMethod.Get.Method); + canonicalizedRequestBuilder.Append("&"); + canonicalizedRequestBuilder.Append(UrlEncoder.Encode(resource_url)); + canonicalizedRequestBuilder.Append("&"); + canonicalizedRequestBuilder.Append(UrlEncoder.Encode(resource_query)); + canonicalizedRequestBuilder.Append("%26"); + canonicalizedRequestBuilder.Append(UrlEncoder.Encode(parameterString)); + + var signature = ComputeSignature(Options.ConsumerSecret, accessToken.TokenSecret, canonicalizedRequestBuilder.ToString()); + authorizationParts.Add("oauth_signature", signature); + + var authorizationHeaderBuilder = new StringBuilder(); + authorizationHeaderBuilder.Append("OAuth "); + foreach (var authorizationPart in authorizationParts) + { + authorizationHeaderBuilder.AppendFormat( + "{0}=\"{1}\", ", authorizationPart.Key, UrlEncoder.Encode(authorizationPart.Value)); + } + authorizationHeaderBuilder.Length = authorizationHeaderBuilder.Length - 2; + + var request = new HttpRequestMessage(HttpMethod.Get, resource_url + "?include_email=true"); + request.Headers.Add("Authorization", authorizationHeaderBuilder.ToString()); + + var response = await _httpClient.SendAsync(request, Context.RequestAborted); + if (!response.IsSuccessStatusCode) + { + Logger.LogError("Email request failed with a status code of " + response.StatusCode); + response.EnsureSuccessStatusCode(); // throw + } + var responseText = await response.Content.ReadAsStringAsync(); + + var result = JObject.Parse(responseText); + + var email = result.Value("email"); + if (!string.IsNullOrEmpty(email)) + { + identity.AddClaim(new Claim(ClaimTypes.Email, email, ClaimValueTypes.Email, Options.ClaimsIssuer)); + } + + return result; + } + private static string GenerateTimeStamp() { var secondsSinceUnixEpocStart = DateTime.UtcNow - Epoch; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 77fb0bd7a8..8ab399a8f9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -38,6 +38,14 @@ namespace Microsoft.AspNetCore.Builder /// The consumer secret used to sign requests to Twitter. public string ConsumerSecret { get; set; } + /// + /// Enables the retrieval user details during the authentication process, including + /// e-mail addresses. Retrieving e-mail addresses requires special permissions + /// from Twitter Support on a per application basis. The default is false. + /// See https://dev.twitter.com/rest/reference/get/account/verify_credentials + /// + public bool RetrieveUserDetails { get; set; } + /// /// Gets or sets the type used to secure data handled by the middleware. /// diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 23ca0cf313..a185aa415a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -19,10 +19,15 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.0.0-*" + "Microsoft.AspNetCore.Authentication": "1.0.0-*", + "Newtonsoft.Json": "8.0.3" }, "frameworks": { "net451": {}, - "netstandard1.3": {} + "netstandard1.3": { + "imports": [ + "portable-net451+win8" + ] + } } } \ No newline at end of file From d5f29c1408db8e3f4aa9c02365ff66ab998cda75 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 28 Apr 2016 15:26:44 -0700 Subject: [PATCH 526/900] Fix build break --- samples/JwtBearerSample/project.json | 3 ++- samples/OpenIdConnect.AzureAdSample/project.json | 3 ++- samples/OpenIdConnectSample/project.json | 3 ++- samples/SocialSample/Startup.cs | 2 -- samples/SocialSample/project.json | 5 +++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index c0b448b72c..f3895f83b1 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -9,7 +9,8 @@ "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*" + "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" }, "frameworks": { "net451": {}, diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index da801b5c2d..d47884d767 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -7,7 +7,8 @@ "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", - "Microsoft.IdentityModel.Clients.ActiveDirectory": "2.22.302111727" + "Microsoft.IdentityModel.Clients.ActiveDirectory": "2.22.302111727", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" }, "frameworks": { "net451": {} diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index b907b68f98..62506bd540 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -6,7 +6,8 @@ "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" }, "frameworks": { "net451": {}, diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index bf09b3f6f2..1767861a98 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -18,8 +18,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.HttpOverrides; -using Microsoft.AspNetCore.Server.Kestrel.Filter; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index c37c5f2b16..6ff162a319 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -12,13 +12,14 @@ "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" }, "compilationOptions": { "emitEntryPoint": true }, "frameworks": { - "net451": {}, + "net451": { }, "netcoreapp1.0": { "imports": [ "dnxcore50" From ba8c0c5018350ac3d6e239a5f2810f73aa1bbad5 Mon Sep 17 00:00:00 2001 From: Petr Onderka Date: Thu, 28 Apr 2016 23:40:50 +0200 Subject: [PATCH 527/900] Removed space from file name This caused broken link in API reference --- ...nnectRedirectBehavior .cs => OpenIdConnectRedirectBehavior.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Microsoft.AspNetCore.Authentication.OpenIdConnect/{OpenIdConnectRedirectBehavior .cs => OpenIdConnectRedirectBehavior.cs} (100%) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior .cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior .cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior.cs From f6cdb9faf9b1460d7dd46aed4b9c351f4222f20f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 2 May 2016 11:27:26 -0700 Subject: [PATCH 528/900] Fix build warnings --- samples/CookieSample/project.json | 10 +++++---- samples/CookieSessionSample/project.json | 10 +++++---- samples/JwtBearerSample/project.json | 14 +++++++----- .../OpenIdConnect.AzureAdSample/project.json | 12 +++++----- samples/OpenIdConnectSample/project.json | 12 +++++----- samples/SocialSample/project.json | 16 ++++++++------ .../project.json | 20 +++++++++-------- .../project.json | 20 +++++++++-------- .../project.json | 20 +++++++++-------- .../project.json | 20 +++++++++-------- .../project.json | 20 +++++++++-------- .../project.json | 20 +++++++++-------- .../project.json | 20 +++++++++-------- .../project.json | 20 +++++++++-------- .../project.json | 20 +++++++++-------- .../project.json | 18 ++++++++------- .../project.json | 16 ++++++++------ .../project.json | 22 +++++++++++-------- .../project.json | 4 ++-- .../project.json | 4 ++-- .../project.json | 4 ++-- .../project.json | 2 +- 22 files changed, 181 insertions(+), 143 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 6da446848e..c28a644d46 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -7,7 +7,7 @@ "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, "frameworks": { @@ -24,9 +24,11 @@ } } }, - "content": [ - "web.config" - ], + "publishOptions": { + "include": [ + "web.config" + ] + }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { "version": "1.0.0-*", diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index 3c83173804..d3caf9364f 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -8,7 +8,7 @@ "Microsoft.Extensions.Caching.Memory": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, "frameworks": { @@ -25,9 +25,11 @@ } } }, - "content": [ - "web.config" - ], + "publishOptions": { + "include": [ + "web.config" + ] + }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { "version": "1.0.0-*", diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index f3895f83b1..a82778a76e 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -1,6 +1,6 @@ { "version": "1.0.0-*", - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, "dependencies": { @@ -26,11 +26,13 @@ } } }, - "content": [ - "project.json", - "wwwroot", - "web.config" - ], + "publishOptions": { + "include": [ + "project.json", + "wwwroot", + "web.config" + ] + }, "userSecretsId": "aspnet5-JwtBearerSample-20151210102827", "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index d47884d767..1524a76b53 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -13,13 +13,15 @@ "frameworks": { "net451": {} }, - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, - "content": [ - "project.json", - "web.config" - ], + "publishOptions": { + "include": [ + "project.json", + "web.config" + ] + }, "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318", "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 62506bd540..4a8e637f65 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -23,13 +23,15 @@ } } }, - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, - "content": [ - "project.json", - "web.config" - ], + "publishOptions": { + "include": [ + "project.json", + "web.config" + ] + }, "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318", "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 6ff162a319..faf517703f 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -15,11 +15,11 @@ "Microsoft.Extensions.Logging.Console": "1.0.0-*", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" }, - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, "frameworks": { - "net451": { }, + "net451": {}, "netcoreapp1.0": { "imports": [ "dnxcore50" @@ -33,11 +33,13 @@ } }, "userSecretsId": "aspnet5-SocialSample-20151210111056", - "content": [ - "config.json", - "project.json", - "web.config" - ], + "publishOptions": { + "include": [ + "config.json", + "project.json", + "web.config" + ] + }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { "version": "1.0.0-*", diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index 82438e4025..c98a4bba1c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -1,16 +1,18 @@ { "version": "1.0.0-*", "description": "ASP.NET Core middleware that enables an application to use cookie based authentication.", - "tags": [ - "aspnetcore", - "authentication", - "security" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore", + "authentication", + "security" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 6639914657..27b5f34eaf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -1,16 +1,18 @@ { "version": "1.0.0-*", "description": "ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow.", - "tags": [ - "aspnetcore", - "authentication", - "security" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore", + "authentication", + "security" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index 9740543ec5..3051e5fa7d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -1,16 +1,18 @@ { "version": "1.0.0-*", "description": "ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows.", - "tags": [ - "aspnetcore", - "authentication", - "security" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore", + "authentication", + "security" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 204ad1aced..f0c04896ec 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -1,16 +1,18 @@ { "version": "1.0.0-*", "description": "ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token.", - "tags": [ - "aspnetcore", - "authentication", - "security" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore", + "authentication", + "security" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index be1c9099e6..3a7b5e03e5 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -1,16 +1,18 @@ { "version": "1.0.0-*", "description": "ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow.", - "tags": [ - "aspnetcore", - "authentication", - "security" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore", + "authentication", + "security" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index a4ee111667..613cadae3f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -1,16 +1,18 @@ { "version": "1.0.0-*", "description": "ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow.", - "tags": [ - "aspnetcore", - "authentication", - "security" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore", + "authentication", + "security" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 581abf9ce1..f053b2be3d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -1,16 +1,18 @@ { "version": "0.1.0-*", "description": "ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow.", - "tags": [ - "aspnetcore", - "authentication", - "security" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore", + "authentication", + "security" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 23ca0cf313..dcd412412a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -1,16 +1,18 @@ { "version": "1.0.0-*", "description": "ASP.NET Core middleware that enables an application to support Twitter's OAuth 2.0 authentication workflow.", - "tags": [ - "aspnetcore", - "authentication", - "security" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore", + "authentication", + "security" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index ec5ff479c8..06de08d84b 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -1,16 +1,18 @@ { "version": "1.0.0-*", "description": "ASP.NET Core common types used by the various authentication middleware components.", - "tags": [ - "aspnetcore", - "authentication", - "security" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore", + "authentication", + "security" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 0d14ab8ad8..0f9becfc82 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -1,15 +1,17 @@ { "version": "1.0.0-*", "description": "ASP.NET Core authorization classes.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Authorization.AllowAnonymousAttribute\r\nMicrosoft.AspNetCore.Authorization.AuthorizeAttribute", - "tags": [ - "aspnetcore", - "authorization" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore", + "authorization" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json index 72a86bf802..3cd40fd20c 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/project.json @@ -1,14 +1,16 @@ { "version": "1.0.0-*", "description": "ASP.NET Core cookie policy classes to control the behavior of cookies.", - "tags": [ - "aspnetcore" - ], - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/aspnet/security" + }, + "tags": [ + "aspnetcore" + ] }, - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/src/Microsoft.Owin.Security.Interop/project.json b/src/Microsoft.Owin.Security.Interop/project.json index 691b16c42d..f94978e52a 100644 --- a/src/Microsoft.Owin.Security.Interop/project.json +++ b/src/Microsoft.Owin.Security.Interop/project.json @@ -1,23 +1,27 @@ { "version": "1.0.0-*", - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "description": "A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication.", - "tags": [ - "aspnetcore", - "katana", - "owin", - "security" - ], + "packOptions": { + "tags": [ + "aspnetcore", + "katana", + "owin", + "security" + ] + }, "dependencies": { "Microsoft.AspNetCore.DataProtection.Extensions": "1.0.0-*", "Microsoft.Owin.Security": "3.0.1" }, "frameworks": { - "net451": { } + "net451": {} } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 931b20be10..e99be60ee8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -1,8 +1,9 @@ { - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true }, "dependencies": { + "dotnet-test-xunit": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-*", @@ -22,7 +23,6 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index a16a0ba374..11b3caf4d4 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -1,8 +1,9 @@ { - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true }, "dependencies": { + "dotnet-test-xunit": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authorization": "1.0.0-*", "Microsoft.AspNetCore.Testing": "1.0.0-*", @@ -17,7 +18,6 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index bb388af16f..6e64aba57d 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -1,8 +1,9 @@ { - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true }, "dependencies": { + "dotnet-test-xunit": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.CookiePolicy": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", @@ -16,7 +17,6 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-*", "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index dac3f8185e..cd3ae56096 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -1,5 +1,5 @@ { - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true }, "dependencies": { From a4c132ca74284dbfe731c88c4067a6d0c6dd52c2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 2 May 2016 16:56:37 -0700 Subject: [PATCH 529/900] Adding dotnet-test-xunit --- test/Microsoft.Owin.Security.Interop.Test/project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index cd3ae56096..4dac4d3a28 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -3,14 +3,14 @@ "warningsAsErrors": true }, "dependencies": { + "dotnet-test-xunit": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Owin.Security.Cookies": "3.0.1", "Microsoft.Owin.Security.Interop": "1.0.0-*", "Microsoft.Owin.Testing": "3.0.1", - "xunit": "2.1.0", - "xunit.runner.console": "2.1.0" + "xunit": "2.1.0" }, "frameworks": { "net451": { From 764525342000c37f98cb7fca6f999d4453a1b83c Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 3 May 2016 09:39:36 -0700 Subject: [PATCH 530/900] #808 Update OIDC to v1.0 --- samples/OpenIdConnect.AzureAdSample/project.json | 2 +- samples/OpenIdConnectSample/project.json | 2 +- .../project.json | 2 +- test/Microsoft.AspNetCore.Authentication.Test/project.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 1524a76b53..40308478b9 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -2,7 +2,7 @@ "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 4a8e637f65..5f0744e0b7 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -2,7 +2,7 @@ "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index f053b2be3d..11d887e5c2 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -1,5 +1,5 @@ { - "version": "0.1.0-*", + "version": "1.0.0-*", "description": "ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow.", "packOptions": { "repository": { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index e99be60ee8..01d03d2b30 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -10,7 +10,7 @@ "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*", "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*", "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.AspNetCore.Testing": "1.0.0-*", From 1a99fad0c69c75f81fc5f74d9044842ae3484e9b Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Mon, 16 May 2016 08:44:41 -0700 Subject: [PATCH 531/900] Rename AuthorizationContext --- .../AuthorizationHandler.cs | 16 ++++++++-------- ...Context.cs => AuthorizationHandlerContext.cs} | 4 ++-- .../AuthorizationPolicyBuilder.cs | 4 ++-- .../DefaultAuthorizationService.cs | 2 +- .../IAuthorizationHandler.cs | 2 +- .../Infrastructure/AssertionRequirement.cs | 8 ++++---- .../ClaimsAuthorizationRequirement.cs | 2 +- .../DenyAnonymousAuthorizationRequirement.cs | 2 +- .../NameAuthorizationRequirement.cs | 2 +- .../PassThroughAuthorizationHandler.cs | 2 +- .../RolesAuthorizationRequirement.cs | 2 +- .../DefaultAuthorizationServiceTests.cs | 12 ++++++------ 12 files changed, 29 insertions(+), 29 deletions(-) rename src/Microsoft.AspNetCore.Authorization/{AuthorizationContext.cs => AuthorizationHandlerContext.cs} (95%) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs index 2bd90aad42..f6877f114e 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Authorization public abstract class AuthorizationHandler : IAuthorizationHandler where TRequirement : IAuthorizationRequirement { - public void Handle(AuthorizationContext context) + public void Handle(AuthorizationHandlerContext context) { foreach (var req in context.Requirements.OfType()) { @@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Authorization } } - public virtual async Task HandleAsync(AuthorizationContext context) + public virtual async Task HandleAsync(AuthorizationHandlerContext context) { foreach (var req in context.Requirements.OfType()) { @@ -25,9 +25,9 @@ namespace Microsoft.AspNetCore.Authorization } } - protected abstract void Handle(AuthorizationContext context, TRequirement requirement); + protected abstract void Handle(AuthorizationHandlerContext context, TRequirement requirement); - protected virtual Task HandleAsync(AuthorizationContext context, TRequirement requirement) + protected virtual Task HandleAsync(AuthorizationHandlerContext context, TRequirement requirement) { Handle(context, requirement); return Task.FromResult(0); @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Authorization public abstract class AuthorizationHandler : IAuthorizationHandler where TRequirement : IAuthorizationRequirement { - public virtual async Task HandleAsync(AuthorizationContext context) + public virtual async Task HandleAsync(AuthorizationHandlerContext context) { if (context.Resource is TResource) { @@ -48,13 +48,13 @@ namespace Microsoft.AspNetCore.Authorization } } - protected virtual Task HandleAsync(AuthorizationContext context, TRequirement requirement, TResource resource) + protected virtual Task HandleAsync(AuthorizationHandlerContext context, TRequirement requirement, TResource resource) { Handle(context, requirement, resource); return Task.FromResult(0); } - public virtual void Handle(AuthorizationContext context) + public virtual void Handle(AuthorizationHandlerContext context) { if (context.Resource is TResource) { @@ -65,6 +65,6 @@ namespace Microsoft.AspNetCore.Authorization } } - protected abstract void Handle(AuthorizationContext context, TRequirement requirement, TResource resource); + protected abstract void Handle(AuthorizationHandlerContext context, TRequirement requirement, TResource resource); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs similarity index 95% rename from src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs rename to src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs index 455adb0dda..2349feb319 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationContext.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs @@ -11,13 +11,13 @@ namespace Microsoft.AspNetCore.Authorization /// /// Contains authorization information used by . /// - public class AuthorizationContext + public class AuthorizationHandlerContext { private HashSet _pendingRequirements; private bool _failCalled; private bool _succeedCalled; - public AuthorizationContext( + public AuthorizationHandlerContext( IEnumerable requirements, ClaimsPrincipal user, object resource) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs index 965ffe02ef..653727f5ee 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs @@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.Authorization /// /// Function that must return true /// - public AuthorizationPolicyBuilder RequireAssertion(Func assert) + public AuthorizationPolicyBuilder RequireAssertion(Func assert) { if (assert == null) { @@ -145,7 +145,7 @@ namespace Microsoft.AspNetCore.Authorization /// /// Function that must return true /// - public AuthorizationPolicyBuilder RequireAssertion(Func> assert) + public AuthorizationPolicyBuilder RequireAssertion(Func> assert) { if (assert == null) { diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 39d35d0ddf..d90cf18031 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Authorization throw new ArgumentNullException(nameof(requirements)); } - var authContext = new AuthorizationContext(requirements, user, resource); + var authContext = new AuthorizationHandlerContext(requirements, user, resource); foreach (var handler in _handlers) { await handler.HandleAsync(authContext); diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs index fc8ba6e7ff..cf7896a30e 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs @@ -7,6 +7,6 @@ namespace Microsoft.AspNetCore.Authorization { public interface IAuthorizationHandler { - Task HandleAsync(AuthorizationContext context); + Task HandleAsync(AuthorizationHandlerContext context); } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs index 0cc1751a49..2ddf065266 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs @@ -11,9 +11,9 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure /// /// Function that is called to handle this requirement /// - public Func> Handler { get; } + public Func> Handler { get; } - public AssertionRequirement(Func assert) + public AssertionRequirement(Func assert) { if (assert == null) { @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure Handler = context => Task.FromResult(assert(context)); } - public AssertionRequirement(Func> assert) + public AssertionRequirement(Func> assert) { if (assert == null) { @@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure Handler = assert; } - public async Task HandleAsync(AuthorizationContext context) + public async Task HandleAsync(AuthorizationHandlerContext context) { if (await Handler(context)) { diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs index bff54954d9..644b33086d 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure public string ClaimType { get; } public IEnumerable AllowedValues { get; } - protected override void Handle(AuthorizationContext context, ClaimsAuthorizationRequirement requirement) + protected override void Handle(AuthorizationHandlerContext context, ClaimsAuthorizationRequirement requirement) { if (context.User != null) { diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs index 44ab475de0..57ad22dff6 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs @@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure { public class DenyAnonymousAuthorizationRequirement : AuthorizationHandler, IAuthorizationRequirement { - protected override void Handle(AuthorizationContext context, DenyAnonymousAuthorizationRequirement requirement) + protected override void Handle(AuthorizationHandlerContext context, DenyAnonymousAuthorizationRequirement requirement) { var user = context.User; var userIsAnonymous = diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs index a4f2455a69..b0c4e6b101 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure public string RequiredName { get; } - protected override void Handle(AuthorizationContext context, NameAuthorizationRequirement requirement) + protected override void Handle(AuthorizationHandlerContext context, NameAuthorizationRequirement requirement) { if (context.User != null) { diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs index 480e2de0cb..d718591ec1 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs @@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure { public class PassThroughAuthorizationHandler : IAuthorizationHandler { - public async Task HandleAsync(AuthorizationContext context) + public async Task HandleAsync(AuthorizationHandlerContext context) { foreach (var handler in context.Requirements.OfType()) { diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs index 217e3ea0c1..a57a0e4c8e 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure public IEnumerable AllowedRoles { get; } - protected override void Handle(AuthorizationContext context, RolesAuthorizationRequirement requirement) + protected override void Handle(AuthorizationHandlerContext context, RolesAuthorizationRequirement requirement) { if (context.User != null) { diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 7f11916940..42948c936f 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -580,7 +580,7 @@ namespace Microsoft.AspNetCore.Authorization.Test public class CustomRequirement : IAuthorizationRequirement { } public class CustomHandler : AuthorizationHandler { - protected override void Handle(AuthorizationContext context, CustomRequirement requirement) + protected override void Handle(AuthorizationHandlerContext context, CustomRequirement requirement) { context.Succeed(requirement); } @@ -636,7 +636,7 @@ namespace Microsoft.AspNetCore.Authorization.Test public bool Succeed { get; set; } - protected override void Handle(AuthorizationContext context, PassThroughRequirement requirement) + protected override void Handle(AuthorizationHandlerContext context, PassThroughRequirement requirement) { if (Succeed) { context.Succeed(requirement); @@ -766,7 +766,7 @@ namespace Microsoft.AspNetCore.Authorization.Test private IEnumerable _allowed; - protected override void Handle(AuthorizationContext context, OperationAuthorizationRequirement requirement, ExpenseReport resource) + protected override void Handle(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement, ExpenseReport resource) { if (_allowed.Contains(requirement)) { @@ -777,7 +777,7 @@ namespace Microsoft.AspNetCore.Authorization.Test public class SuperUserHandler : AuthorizationHandler { - protected override void Handle(AuthorizationContext context, OperationAuthorizationRequirement requirement) + protected override void Handle(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement) { if (context.User.HasClaim("SuperUser", "yes")) { @@ -812,7 +812,7 @@ namespace Microsoft.AspNetCore.Authorization.Test public class NotCalledHandler : AuthorizationHandler { - protected override void Handle(AuthorizationContext context, OperationAuthorizationRequirement requirement, string resource) + protected override void Handle(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement, string resource) { throw new NotImplementedException(); } @@ -820,7 +820,7 @@ namespace Microsoft.AspNetCore.Authorization.Test public class EvenHandler : AuthorizationHandler { - protected override void Handle(AuthorizationContext context, OperationAuthorizationRequirement requirement, int id) + protected override void Handle(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement, int id) { if (id % 2 == 0) { From 6294badd972882ba707216c211095474ef8c4709 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 16 May 2016 12:18:50 -0700 Subject: [PATCH 532/900] Use a shared CookieSecurePolicy. --- .../CookieAuthenticationHandler.cs | 4 +- .../CookieAuthenticationOptions.cs | 6 +- .../CookieSecureOption.cs | 35 -------- .../CookiePolicyMiddleware.cs | 8 +- .../CookiePolicyOptions.cs | 4 +- .../SecurePolicy.cs | 12 --- .../Cookies/CookieMiddlewareTests.cs | 20 ++--- .../CookiePolicyTests.cs | 81 +++++++++---------- 8 files changed, 62 insertions(+), 108 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/CookieSecureOption.cs delete mode 100644 src/Microsoft.AspNetCore.CookiePolicy/SecurePolicy.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index b056d0787b..3a8365a5b3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -145,13 +145,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies HttpOnly = Options.CookieHttpOnly, Path = Options.CookiePath ?? (OriginalPathBase.HasValue ? OriginalPathBase.ToString() : "/"), }; - if (Options.CookieSecure == CookieSecureOption.SameAsRequest) + if (Options.CookieSecure == CookieSecurePolicy.SameAsRequest) { cookieOptions.Secure = Request.IsHttps; } else { - cookieOptions.Secure = Options.CookieSecure == CookieSecureOption.Always; + cookieOptions.Secure = Options.CookieSecure == CookieSecurePolicy.Always; } return cookieOptions; } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 8a451c9c71..f9455f23a5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Builder ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; CookieHttpOnly = true; - CookieSecure = CookieSecureOption.SameAsRequest; + CookieSecure = CookieSecurePolicy.SameAsRequest; SystemClock = new SystemClock(); Events = new CookieAuthenticationEvents(); } @@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Builder public string CookieDomain { get; set; } /// - /// Determines the path used to create the cookie. The default value is "/" for highest browser compatability. + /// Determines the path used to create the cookie. The default value is "/" for highest browser compatibility. /// public string CookiePath { get; set; } @@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Builder /// to HTTPS requests if the page which is doing the SignIn is also HTTPS. If you have an HTTPS sign in page /// and portions of your site are HTTP you may need to change this value. /// - public CookieSecureOption CookieSecure { get; set; } + public CookieSecurePolicy CookieSecure { get; set; } /// /// If set this will be used by the CookieAuthenticationMiddleware for data protection. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieSecureOption.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieSecureOption.cs deleted file mode 100644 index 5a35415d1b..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieSecureOption.cs +++ /dev/null @@ -1,35 +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.AspNetCore.Authentication.Cookies -{ - /// - /// Determines how the identity cookie's security property is set. - /// - public enum CookieSecureOption - { - /// - /// If the URI that provides the cookie is HTTPS, then the cookie will only be returned to the server on - /// subsequent HTTPS requests. Otherwise if the URI that provides the cookie is HTTP, then the cookie will - /// be returned to the server on all HTTP and HTTPS requests. This is the default value because it ensures - /// HTTPS for all authenticated requests on deployed servers, and also supports HTTP for localhost development - /// and for servers that do not have HTTPS support. - /// - SameAsRequest, - - /// - /// CookieOptions.Secure is never marked true. Use this value when your login page is HTTPS, but other pages - /// on the site which are HTTP also require authentication information. This setting is not recommended because - /// the authentication information provided with an HTTP request may be observed and used by other computers - /// on your local network or wireless connection. - /// - Never, - - /// - /// CookieOptions.Secure is always marked true. Use this value when your login page and all subsequent pages - /// requiring the authenticated identity are HTTPS. Local development will also need to be done with HTTPS urls. - /// - Always, - } -} diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs index 7b52a58804..46daaad810 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.CookiePolicy private bool PolicyRequiresCookieOptions() { - return Policy.HttpOnly != HttpOnlyPolicy.None || Policy.Secure != SecurePolicy.None; + return Policy.HttpOnly != HttpOnlyPolicy.None || Policy.Secure != CookieSecurePolicy.None; } public void Append(string key, string value) @@ -140,13 +140,13 @@ namespace Microsoft.AspNetCore.CookiePolicy { switch (Policy.Secure) { - case SecurePolicy.Always: + case CookieSecurePolicy.Always: options.Secure = true; break; - case SecurePolicy.SameAsRequest: + case CookieSecurePolicy.SameAsRequest: options.Secure = Context.Request.IsHttps; break; - case SecurePolicy.None: + case CookieSecurePolicy.None: break; default: throw new InvalidOperationException(); diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index 8201b58639..6aed18bfb0 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.CookiePolicy; +using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Builder { @@ -15,10 +16,11 @@ namespace Microsoft.AspNetCore.Builder /// Affects whether cookies must be HttpOnly. /// public HttpOnlyPolicy HttpOnly { get; set; } = HttpOnlyPolicy.None; + /// /// Affects whether cookies must be Secure. /// - public SecurePolicy Secure { get; set; } = SecurePolicy.None; + public CookieSecurePolicy Secure { get; set; } = CookieSecurePolicy.None; /// /// Called when a cookie is appended. diff --git a/src/Microsoft.AspNetCore.CookiePolicy/SecurePolicy.cs b/src/Microsoft.AspNetCore.CookiePolicy/SecurePolicy.cs deleted file mode 100644 index c0dd639f1c..0000000000 --- a/src/Microsoft.AspNetCore.CookiePolicy/SecurePolicy.cs +++ /dev/null @@ -1,12 +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.AspNetCore.CookiePolicy -{ - public enum SecurePolicy - { - None, - Always, - SameAsRequest - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 5049f39e55..fa4a4502ff 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -192,14 +192,14 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } [Theory] - [InlineData(CookieSecureOption.Always, "http://example.com/testpath", true)] - [InlineData(CookieSecureOption.Always, "https://example.com/testpath", true)] - [InlineData(CookieSecureOption.Never, "http://example.com/testpath", false)] - [InlineData(CookieSecureOption.Never, "https://example.com/testpath", false)] - [InlineData(CookieSecureOption.SameAsRequest, "http://example.com/testpath", false)] - [InlineData(CookieSecureOption.SameAsRequest, "https://example.com/testpath", true)] + [InlineData(CookieSecurePolicy.Always, "http://example.com/testpath", true)] + [InlineData(CookieSecurePolicy.Always, "https://example.com/testpath", true)] + [InlineData(CookieSecurePolicy.None, "http://example.com/testpath", false)] + [InlineData(CookieSecurePolicy.None, "https://example.com/testpath", false)] + [InlineData(CookieSecurePolicy.SameAsRequest, "http://example.com/testpath", false)] + [InlineData(CookieSecurePolicy.SameAsRequest, "https://example.com/testpath", true)] public async Task SecureSignInCausesSecureOnlyCookieByDefault( - CookieSecureOption cookieSecureOption, + CookieSecurePolicy cookieSecurePolicy, string requestUri, bool shouldBeSecureOnly) { @@ -207,7 +207,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { LoginPath = new PathString("/login"), CookieName = "TestCookie", - CookieSecure = cookieSecureOption + CookieSecure = cookieSecurePolicy }, SignInAsAlice); var transaction = await SendAsync(server, requestUri); @@ -231,7 +231,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies CookieName = "TestCookie", CookiePath = "/foo", CookieDomain = "another.com", - CookieSecure = CookieSecureOption.Always, + CookieSecure = CookieSecurePolicy.Always, CookieHttpOnly = true }, SignInAsAlice, new Uri("http://example.com/base")); @@ -248,7 +248,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var server2 = CreateServer(new CookieAuthenticationOptions { CookieName = "SecondCookie", - CookieSecure = CookieSecureOption.Never, + CookieSecure = CookieSecurePolicy.None, CookieHttpOnly = false }, SignInAsAlice, new Uri("http://example.com/base")); diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index 307002d1f3..f08d7fef8e 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -37,18 +37,18 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test await RunTest("/secureAlways", new CookiePolicyOptions { - Secure = SecurePolicy.Always + Secure = CookieSecurePolicy.Always }, SecureCookieAppends, new RequestTest("http://example.com/secureAlways", - transaction => - { - Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; secure", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; secure", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; secure", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); - })); + transaction => + { + Assert.NotNull(transaction.SetCookie); + Assert.Equal("A=A; path=/; secure", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; secure", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; secure", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); + })); } [Fact] @@ -57,19 +57,18 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test await RunTest("/secureNone", new CookiePolicyOptions { - Secure = SecurePolicy.None + Secure = CookieSecurePolicy.None }, SecureCookieAppends, new RequestTest("http://example.com/secureNone", - transaction => - { - Assert.NotNull(transaction.SetCookie); - Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); - })); + transaction => + { + Assert.NotNull(transaction.SetCookie); + Assert.Equal("A=A; path=/", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); + })); } [Fact] @@ -78,27 +77,27 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test await RunTest("/secureSame", new CookiePolicyOptions { - Secure = SecurePolicy.SameAsRequest + Secure = CookieSecurePolicy.SameAsRequest }, SecureCookieAppends, new RequestTest("http://example.com/secureSame", - transaction => - { - Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/", transaction.SetCookie[3]); - }), + transaction => + { + Assert.NotNull(transaction.SetCookie); + Assert.Equal("A=A; path=/", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/", transaction.SetCookie[3]); + }), new RequestTest("https://example.com/secureSame", - transaction => - { - Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; secure", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; secure", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; secure", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); - })); + transaction => + { + Assert.NotNull(transaction.SetCookie); + Assert.Equal("A=A; path=/; secure", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; secure", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; secure", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); + })); } [Fact] @@ -283,13 +282,13 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test { var builder = new WebHostBuilder() .Configure(app => - { - app.Map(path, map => { - map.UseCookiePolicy(cookiePolicy); - map.Run(configureSetup); + app.Map(path, map => + { + map.UseCookiePolicy(cookiePolicy); + map.Run(configureSetup); + }); }); - }); var server = new TestServer(builder); foreach (var test in tests) { From 962a74c4883e00da0666296c7c1751495f443ac0 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Mon, 16 May 2016 08:09:00 -0700 Subject: [PATCH 533/900] Add argument validation --- .../OpenIdConnectMiddleware.cs | 12 +++- .../OpenIdConnectMiddlewareTests.cs | 63 +++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs index 80f2ca2ba3..b08f8e944c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -82,6 +82,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect throw new ArgumentNullException(nameof(htmlEncoder)); } + if (string.IsNullOrEmpty(Options.ClientId)) + { + throw new ArgumentException("Options.ClientId must be provided", nameof(Options.ClientId)); + } + if (!Options.CallbackPath.HasValue) { throw new ArgumentException("Options.CallbackPath must be provided."); @@ -120,7 +125,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Options.StringDataFormat = new SecureDataFormat(new StringSerializer(), dataProtector); } - if (Options.Events == null) { Options.Events = new OpenIdConnectEvents(); @@ -164,6 +168,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect new HttpDocumentRetriever(Backchannel) { RequireHttps = Options.RequireHttpsMetadata }); } } + + if (Options.ConfigurationManager == null) + { + throw new InvalidOperationException($"Provide {nameof(Options.Authority)}, {nameof(Options.MetadataAddress)}, " + + $"{nameof(Options.Configuration)}, or {nameof(Options.ConfigurationManager)} to {nameof(OpenIdConnectOptions)}"); + } } protected HttpClient Backchannel { get; private set; } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index ebc59b9ee8..20de135712 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -161,6 +161,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect return Task.FromResult(0); } }; + options.ClientId = "Test Id"; + options.Configuration = TestUtilities.DefaultOpenIdConnectConfiguration; return options; } @@ -550,5 +552,66 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect return nonceTime; } + + [Fact] + public void ThrowsWithNoClientId() + { + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions + { + SignInScheme = "TestScheme", + Authority = DefaultAuthority, + Configuration = TestUtilities.DefaultOpenIdConnectConfiguration, + AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost + }); + }).ConfigureServices(services => + { + services.AddAuthentication(); + }); + + try + { + var server = new TestServer(builder); + } + catch (ArgumentException e) + { + Assert.Equal("ClientId", e.ParamName); + return; + } + + Assert.True(false); + } + + [Fact] + public void ThrowsWithNoConfigurationValues() + { + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions + { + SignInScheme = "TestScheme", + ClientId = "Test Id", + AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost + }); + }).ConfigureServices(services => + { + services.AddAuthentication(); + }); + + try + { + var server = new TestServer(builder); + } + catch (InvalidOperationException e) + { + Assert.Equal("Provide Authority, MetadataAddress, Configuration, or ConfigurationManager to OpenIdConnectOptions", e.Message); + return; + } + + Assert.True(false); + } } } \ No newline at end of file From 8b4b99b168c97b6c559ec0f971ae6389a669c153 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 17 May 2016 13:36:18 -0700 Subject: [PATCH 534/900] Clean up samples --- samples/CookieSample/Program.cs | 24 ++++++++ .../Properties/launchSettings.json | 9 +-- samples/CookieSample/Startup.cs | 11 ---- samples/CookieSample/project.json | 1 + samples/CookieSessionSample/Program.cs | 24 ++++++++ .../Properties/launchSettings.json | 9 +-- samples/CookieSessionSample/Startup.cs | 11 ---- samples/CookieSessionSample/project.json | 1 + samples/JwtBearerSample/Program.cs | 24 ++++++++ .../Properties/launchSettings.json | 9 ++- samples/JwtBearerSample/Startup.cs | 29 ++++------ .../OpenIdConnect.AzureAdSample/Program.cs | 24 ++++++++ .../Properties/launchSettings.json | 9 ++- .../OpenIdConnect.AzureAdSample/Startup.cs | 28 ++++----- samples/OpenIdConnectSample/Program.cs | 24 ++++++++ .../Properties/launchSettings.json | 8 +-- samples/OpenIdConnectSample/Startup.cs | 28 ++++----- samples/SocialSample/Program.cs | 50 ++++++++++++++++ .../Properties/launchSettings.json | 9 +-- samples/SocialSample/Startup.cs | 57 +++++-------------- .../{config.json => appsettings.json} | 0 samples/SocialSample/project.json | 4 +- 22 files changed, 254 insertions(+), 139 deletions(-) create mode 100644 samples/CookieSample/Program.cs create mode 100644 samples/CookieSessionSample/Program.cs create mode 100644 samples/JwtBearerSample/Program.cs create mode 100644 samples/OpenIdConnect.AzureAdSample/Program.cs create mode 100644 samples/OpenIdConnectSample/Program.cs create mode 100644 samples/SocialSample/Program.cs rename samples/SocialSample/{config.json => appsettings.json} (100%) diff --git a/samples/CookieSample/Program.cs b/samples/CookieSample/Program.cs new file mode 100644 index 0000000000..cd8aab3aee --- /dev/null +++ b/samples/CookieSample/Program.cs @@ -0,0 +1,24 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace CookieSample +{ + public static class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); + + var host = new WebHostBuilder() + .UseKestrel() + .UseConfiguration(config) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/samples/CookieSample/Properties/launchSettings.json b/samples/CookieSample/Properties/launchSettings.json index c85de8d26e..75da70bee0 100644 --- a/samples/CookieSample/Properties/launchSettings.json +++ b/samples/CookieSample/Properties/launchSettings.json @@ -12,15 +12,16 @@ "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { - "ASPNET_ENV": "Development" + "ASPNETCORE_ENVIRONMENT": "Development" } }, - "web": { - "commandName": "web", + "CookieSample": { + "commandName": "Project", "launchBrowser": true, "launchUrl": "http://localhost:12345", "environmentVariables": { - "Hosting:Environment": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_SERVER.URLS": "http://localhost:12345" } } } diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 768415f0ce..002d878885 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -41,16 +41,5 @@ namespace CookieSample await context.Response.WriteAsync("Hello old timer"); }); } - - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseKestrel() - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); - } } } diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index c28a644d46..954c366434 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -5,6 +5,7 @@ "Microsoft.AspNetCore.DataProtection": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "buildOptions": { diff --git a/samples/CookieSessionSample/Program.cs b/samples/CookieSessionSample/Program.cs new file mode 100644 index 0000000000..6b9014f5e9 --- /dev/null +++ b/samples/CookieSessionSample/Program.cs @@ -0,0 +1,24 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace CookieSessionSample +{ + public static class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); + + var host = new WebHostBuilder() + .UseKestrel() + .UseConfiguration(config) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/samples/CookieSessionSample/Properties/launchSettings.json b/samples/CookieSessionSample/Properties/launchSettings.json index 8d4a0316ab..15b478a0ed 100644 --- a/samples/CookieSessionSample/Properties/launchSettings.json +++ b/samples/CookieSessionSample/Properties/launchSettings.json @@ -12,15 +12,16 @@ "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { - "ASPNET_ENV": "Development" + "ASPNETCORE_ENVIRONMENT": "Development" } }, - "web": { - "commandName": "web", + "CookieSessionSample": { + "commandName": "Project", "launchBrowser": true, "launchUrl": "http://localhost:12345", "environmentVariables": { - "Hosting:Environment": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_SERVER.URLS": "http://localhost:12345" } } } diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 4d3ea3aa67..ecb61ab665 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -51,16 +51,5 @@ namespace CookieSessionSample await context.Response.WriteAsync("Hello old timer"); }); } - - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseKestrel() - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); - } } } diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index d3caf9364f..a3626218c4 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -6,6 +6,7 @@ "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.Extensions.Caching.Memory": "1.0.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "buildOptions": { diff --git a/samples/JwtBearerSample/Program.cs b/samples/JwtBearerSample/Program.cs new file mode 100644 index 0000000000..82da93d591 --- /dev/null +++ b/samples/JwtBearerSample/Program.cs @@ -0,0 +1,24 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace JwtBearerSample +{ + public static class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); + + var host = new WebHostBuilder() + .UseKestrel() + .UseConfiguration(config) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/samples/JwtBearerSample/Properties/launchSettings.json b/samples/JwtBearerSample/Properties/launchSettings.json index 49cbac543a..f5dfcd0181 100644 --- a/samples/JwtBearerSample/Properties/launchSettings.json +++ b/samples/JwtBearerSample/Properties/launchSettings.json @@ -15,10 +15,13 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, - "web": { - "commandName": "web", + "JwtBearer": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "http://localhost:42023", "environmentVariables": { - "Hosting:Environment": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_SERVER.URLS": "http://localhost:42023" } } } diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index b2df5033e4..02611de8c4 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -13,12 +13,19 @@ namespace JwtBearerSample { public class Startup { - public Startup() + public Startup(IHostingEnvironment env) { - Configuration = new ConfigurationBuilder() - .AddEnvironmentVariables() - .AddUserSecrets() - .Build(); + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath); + + if (env.IsDevelopment()) + { + // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 + builder.AddUserSecrets(); + } + + builder.AddEnvironmentVariables(); + Configuration = builder.Build(); } public IConfiguration Configuration { get; set; } @@ -106,18 +113,6 @@ namespace JwtBearerSample }); }); } - - // Entry point for the application. - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseKestrel() - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); - } } } diff --git a/samples/OpenIdConnect.AzureAdSample/Program.cs b/samples/OpenIdConnect.AzureAdSample/Program.cs new file mode 100644 index 0000000000..5dcda4c86a --- /dev/null +++ b/samples/OpenIdConnect.AzureAdSample/Program.cs @@ -0,0 +1,24 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace OpenIdConnect.AzureAdSample +{ + public static class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); + + var host = new WebHostBuilder() + .UseKestrel() + .UseConfiguration(config) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json index 49cbac543a..2ae08a6cc9 100644 --- a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json +++ b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json @@ -15,10 +15,13 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, - "web": { - "commandName": "web", + "OpenIdConnect": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "http://localhost:42023", "environmentVariables": { - "Hosting:Environment": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_SERVER.URLS": "http://localhost:42023" } } } diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 7d8cf23461..f4d0c37aaa 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -20,12 +20,19 @@ namespace OpenIdConnect.AzureAdSample { private const string GraphResourceID = "https://graph.windows.net"; - public Startup() + public Startup(IHostingEnvironment env) { - Configuration = new ConfigurationBuilder() - .AddEnvironmentVariables() - .AddUserSecrets() - .Build(); + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath); + + if (env.IsDevelopment()) + { + // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 + builder.AddUserSecrets(); + } + + builder.AddEnvironmentVariables(); + Configuration = builder.Build(); } public IConfiguration Configuration { get; set; } @@ -150,17 +157,6 @@ namespace OpenIdConnect.AzureAdSample await context.Response.WriteAsync($""); }); } - - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseKestrel() - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); - } } } diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs new file mode 100644 index 0000000000..a81f11dfb0 --- /dev/null +++ b/samples/OpenIdConnectSample/Program.cs @@ -0,0 +1,24 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace OpenIdConnectSample +{ + public static class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); + + var host = new WebHostBuilder() + .UseKestrel() + .UseConfiguration(config) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/samples/OpenIdConnectSample/Properties/launchSettings.json b/samples/OpenIdConnectSample/Properties/launchSettings.json index 5a0163016a..557b6921e2 100644 --- a/samples/OpenIdConnectSample/Properties/launchSettings.json +++ b/samples/OpenIdConnectSample/Properties/launchSettings.json @@ -15,13 +15,13 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, - "web": { - "commandName": "web", + "OpenIdConnectSample": { + "commandName": "Project", "launchBrowser": true, "launchUrl": "http://localhost:42023", "environmentVariables": { - "Hosting:Environment": "Development", - "ASPNET_server.urls": "http://localhost:42023" + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_SERVER.URLS": "http://localhost:42023" } } } diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index ff68b471fa..c2f831e199 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -15,12 +15,19 @@ namespace OpenIdConnectSample { public class Startup { - public Startup() + public Startup(IHostingEnvironment env) { - Configuration = new ConfigurationBuilder() - .AddEnvironmentVariables() - .AddUserSecrets() - .Build(); + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath); + + if (env.IsDevelopment()) + { + // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 + builder.AddUserSecrets(); + } + + builder.AddEnvironmentVariables(); + Configuration = builder.Build(); } public IConfiguration Configuration { get; set; } @@ -96,17 +103,6 @@ namespace OpenIdConnectSample await context.Response.WriteAsync($""); }); } - - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseKestrel() - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); - } } } diff --git a/samples/SocialSample/Program.cs b/samples/SocialSample/Program.cs new file mode 100644 index 0000000000..386819e6f5 --- /dev/null +++ b/samples/SocialSample/Program.cs @@ -0,0 +1,50 @@ +using System.IO; +using System.Reflection; +using System.Security.Cryptography.X509Certificates; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.FileProviders; + +namespace SocialSample +{ + public static class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); + + var host = new WebHostBuilder() + .UseKestrel(options => + { + //Configure SSL + var serverCertificate = LoadCertificate(); + options.UseHttps(serverCertificate); + }) + .UseConfiguration(config) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + + private static X509Certificate2 LoadCertificate() + { + var socialSampleAssembly = typeof(Startup).GetTypeInfo().Assembly; + var embeddedFileProvider = new EmbeddedFileProvider(socialSampleAssembly, "SocialSample"); + var certificateFileInfo = embeddedFileProvider.GetFileInfo("compiler/resources/cert.pfx"); + using (var certificateStream = certificateFileInfo.CreateReadStream()) + { + byte[] certificatePayload; + using (var memoryStream = new MemoryStream()) + { + certificateStream.CopyTo(memoryStream); + certificatePayload = memoryStream.ToArray(); + } + + return new X509Certificate2(certificatePayload, "testPassword"); + } + } + } +} diff --git a/samples/SocialSample/Properties/launchSettings.json b/samples/SocialSample/Properties/launchSettings.json index e9d26ad03e..903a815886 100644 --- a/samples/SocialSample/Properties/launchSettings.json +++ b/samples/SocialSample/Properties/launchSettings.json @@ -13,15 +13,16 @@ "launchBrowser": true, "launchUrl": "https://localhost:44318/", "environmentVariables": { - "ASPNET_ENV": "Development" + "ASPNETCORE_ENVIRONMENT": "Development" } }, - "web": { - "commandName": "web", + "SocialSample": { + "commandName": "Project", "launchBrowser": true, "launchUrl": "https://localhost:54541/", "environmentVariables": { - "Hosting:Environment": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_SERVER.URLS": "https://localhost:54541/" } } } diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 7cad7de849..f8c7495d34 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -1,11 +1,8 @@ using System; -using System.IO; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; -using System.Reflection; using System.Security.Claims; -using System.Security.Cryptography.X509Certificates; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; @@ -20,7 +17,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; @@ -29,13 +25,20 @@ namespace SocialSample /* Note all servers must use the same address and port because these are pre-registered with the various providers. */ public class Startup { - public Startup() + public Startup(IHostingEnvironment env) { - Configuration = new ConfigurationBuilder() - .AddEnvironmentVariables() - .AddJsonFile("config.json") - .AddUserSecrets() - .Build(); + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath) + .AddJsonFile("appsettings.json"); + + if (env.IsDevelopment()) + { + // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 + builder.AddUserSecrets(); + } + + builder.AddEnvironmentVariables(); + Configuration = builder.Build(); } public IConfiguration Configuration { get; set; } @@ -343,40 +346,6 @@ namespace SocialSample await context.Response.WriteAsync(""); }); } - - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseKestrel(options => - { - //Configure SSL - var serverCertificate = LoadCertificate(); - options.UseHttps(serverCertificate); - }) - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); - } - - private static X509Certificate2 LoadCertificate() - { - var socialSampleAssembly = typeof(Startup).GetTypeInfo().Assembly; - var embeddedFileProvider = new EmbeddedFileProvider(socialSampleAssembly, "SocialSample"); - var certificateFileInfo = embeddedFileProvider.GetFileInfo("compiler/resources/cert.pfx"); - using (var certificateStream = certificateFileInfo.CreateReadStream()) - { - byte[] certificatePayload; - using (var memoryStream = new MemoryStream()) - { - certificateStream.CopyTo(memoryStream); - certificatePayload = memoryStream.ToArray(); - } - - return new X509Certificate2(certificatePayload, "testPassword"); - } - } } } diff --git a/samples/SocialSample/config.json b/samples/SocialSample/appsettings.json similarity index 100% rename from samples/SocialSample/config.json rename to samples/SocialSample/appsettings.json diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index faf517703f..fb19d3ec2a 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -19,7 +19,7 @@ "emitEntryPoint": true }, "frameworks": { - "net451": {}, + "net451": { }, "netcoreapp1.0": { "imports": [ "dnxcore50" @@ -35,7 +35,7 @@ "userSecretsId": "aspnet5-SocialSample-20151210111056", "publishOptions": { "include": [ - "config.json", + "appsettings.json", "project.json", "web.config" ] From 621ccf889ca93042304e2f54ef61e6f05621781d Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 17 May 2016 14:34:03 -0700 Subject: [PATCH 535/900] React to updated CoreCLR packages https://github.com/aspnet/Coherence/issues/97 --- src/Microsoft.AspNetCore.Authentication/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index 06de08d84b..e5107da8fc 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -40,7 +40,7 @@ }, "netstandard1.3": { "dependencies": { - "System.Net.Http": "4.0.1-*" + "System.Net.Http": "4.1.0-*" }, "imports": [ "portable-net451" From 4c27df166b497636ab4aa1771619d228cb5b429c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 18 May 2016 09:40:51 -0700 Subject: [PATCH 536/900] Revert "React to updated CoreCLR packages" This reverts commit 621ccf889ca93042304e2f54ef61e6f05621781d. --- src/Microsoft.AspNetCore.Authentication/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index e5107da8fc..06de08d84b 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -40,7 +40,7 @@ }, "netstandard1.3": { "dependencies": { - "System.Net.Http": "4.1.0-*" + "System.Net.Http": "4.0.1-*" }, "imports": [ "portable-net451" From bfbe7ec15d22914bdbdfd2bec989f160c03d8a50 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 20 May 2016 13:53:03 -0700 Subject: [PATCH 537/900] Update fb to v2.6 --- .../FacebookDefaults.cs | 6 +++--- .../Facebook/FacebookMiddlewareTests.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs index da65e246ba..012f95dcce 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -7,10 +7,10 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { public const string AuthenticationScheme = "Facebook"; - public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.5/dialog/oauth"; + public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.6/dialog/oauth"; - public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.5/oauth/access_token"; + public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.6/oauth/access_token"; - public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v2.5/me"; + public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v2.6/me"; } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs index eaa339d153..f38ca8afc8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var transaction = await server.SendAsync("http://example.com/base/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.5/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v2.6/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=" + UrlEncoder.Default.Encode("http://example.com/base/signin-facebook"), location); @@ -113,7 +113,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var transaction = await server.SendAsync("http://example.com/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.5/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v2.6/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri="+ UrlEncoder.Default.Encode("http://example.com/signin-facebook"), location); @@ -150,7 +150,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var transaction = await server.SendAsync("http://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.5/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v2.6/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=", location); From db7009531a23029e2516c52ca0d103149434f888 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 20 May 2016 14:00:08 -0700 Subject: [PATCH 538/900] Update google token endpoint to v4 --- .../GoogleDefaults.cs | 2 +- .../Google/GoogleMiddlewareTests.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs index 06fd12eb1f..c17ff6b2ab 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Authentication.Google public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/auth"; - public static readonly string TokenEndpoint = "https://www.googleapis.com/oauth2/v3/token"; + public static readonly string TokenEndpoint = "https://www.googleapis.com/oauth2/v4/token"; public static readonly string UserInformationEndpoint = "https://www.googleapis.com/plus/v1/people/me"; } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 31fb9e3175..42cecf81bd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -299,7 +299,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { Sender = req => { - if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v3/token") + if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token") { return ReturnJsonResponse(new { @@ -489,7 +489,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { Sender = req => { - if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v3/token") + if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token") { return ReturnJsonResponse(new { @@ -569,7 +569,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { Sender = req => { - if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v3/token") + if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token") { return ReturnJsonResponse(new { @@ -659,7 +659,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { Sender = req => { - if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v3/token") + if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token") { return ReturnJsonResponse(new { From 59fc691f4152e6d5017176c0b700ee9834640481 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 17 May 2016 16:23:00 -0700 Subject: [PATCH 539/900] #667 #801 Handle authorize and forbid for redirecting handlers. --- samples/OpenIdConnectSample/Startup.cs | 48 ++++++++++++++++--- .../Properties/launchSettings.json | 4 +- samples/SocialSample/Startup.cs | 37 +++++++++----- .../RemoteAuthenticationHandler.cs | 33 +++++++++++-- 4 files changed, 96 insertions(+), 26 deletions(-) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index c2f831e199..3fffe9ce69 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -81,25 +82,58 @@ namespace OpenIdConnectSample { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); context.Response.ContentType = "text/html"; - await context.Response.WriteAsync($"Signing out {context.User.Identity.Name}
{Environment.NewLine}"); + await context.Response.WriteAsync($"Signed out {context.User.Identity.Name}
{Environment.NewLine}"); await context.Response.WriteAsync("Sign In"); await context.Response.WriteAsync($""); return; } - - if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) + if (context.Request.Path.Equals("/Account/AccessDenied")) { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" }); + await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + context.Response.ContentType = "text/html"; + await context.Response.WriteAsync($"Access Denied for user {context.User.Identity.Name} to resource '{context.Request.Query["ReturnUrl"]}'
{Environment.NewLine}"); + await context.Response.WriteAsync("Sign Out"); + await context.Response.WriteAsync($""); + return; + } + + // CookieAuthenticationOptions.AutomaticAuthenticate = true (default) causes User to be set + var user = context.User; + + // This is what [Authorize] calls + // var user = await context.Authentication.AuthenticateAsync(AuthenticationManager.AutomaticScheme); + + // This is what [Authorize(ActiveAuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)] calls + // var user = await context.Authentication.AuthenticateAsync(OpenIdConnectDefaults.AuthenticationScheme); + + // Not authenticated + if (user == null || !user.Identities.Any(identity => identity.IsAuthenticated)) + { + // This is what [Authorize] calls + // The cookie middleware will intercept this 401 and redirect to /login + await context.Authentication.ChallengeAsync(); + + // This is what [Authorize(ActiveAuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)] calls + // await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme); + + return; + } + + // Authenticated, but not authorized + if (context.Request.Path.Equals("/restricted") && !user.Identities.Any(identity => identity.HasClaim("special", "true"))) + { + await context.Authentication.ChallengeAsync(); return; } context.Response.ContentType = "text/html"; - await context.Response.WriteAsync($"Hello Authenticated User {context.User.Identity.Name}
{Environment.NewLine}"); - foreach (var claim in context.User.Claims) + await context.Response.WriteAsync($"Hello Authenticated User {user.Identity.Name}
{Environment.NewLine}"); + foreach (var claim in user.Claims) { await context.Response.WriteAsync($"{claim.Type}: {claim.Value}
{Environment.NewLine}"); } - await context.Response.WriteAsync("Sign Out"); + await context.Response.WriteAsync("Restricted
"); + await context.Response.WriteAsync("Sign Out
"); await context.Response.WriteAsync($""); }); } diff --git a/samples/SocialSample/Properties/launchSettings.json b/samples/SocialSample/Properties/launchSettings.json index 903a815886..9224a4881c 100644 --- a/samples/SocialSample/Properties/launchSettings.json +++ b/samples/SocialSample/Properties/launchSettings.json @@ -19,10 +19,10 @@ "SocialSample": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "https://localhost:54541/", + "launchUrl": "https://localhost:44318/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_SERVER.URLS": "https://localhost:54541/" + "ASPNETCORE_SERVER.URLS": "https://localhost:44318/" } } } diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index f8c7495d34..4f3a03d50d 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -313,21 +313,32 @@ namespace SocialSample }); }); - // Deny anonymous request beyond this point. - app.Use(async (context, next) => - { - if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) - { - // The cookie middleware will intercept this 401 and redirect to /login - await context.Authentication.ChallengeAsync(); - return; - } - await next(); - }); - // Display user information app.Run(async context => { + // CookieAuthenticationOptions.AutomaticAuthenticate = true (default) causes User to be set + var user = context.User; + + // This is what [Authorize] calls + // var user = await context.Authentication.AuthenticateAsync(AuthenticationManager.AutomaticScheme); + + // This is what [Authorize(ActiveAuthenticationSchemes = MicrosoftAccountDefaults.AuthenticationScheme)] calls + // var user = await context.Authentication.AuthenticateAsync(MicrosoftAccountDefaults.AuthenticationScheme); + + // Deny anonymous request beyond this point. + if (user == null || !user.Identities.Any(identity => identity.IsAuthenticated)) + { + // This is what [Authorize] calls + // The cookie middleware will intercept this 401 and redirect to /login + await context.Authentication.ChallengeAsync(); + + // This is what [Authorize(ActiveAuthenticationSchemes = MicrosoftAccountDefaults.AuthenticationScheme)] calls + // await context.Authentication.ChallengeAsync(MicrosoftAccountDefaults.AuthenticationScheme); + + return; + } + + // Display user information context.Response.ContentType = "text/html"; await context.Response.WriteAsync(""); await context.Response.WriteAsync("Hello " + (context.User.Identity.Name ?? "anonymous") + "
"); @@ -342,7 +353,7 @@ namespace SocialSample await context.Response.WriteAsync("Refresh Token: " + await context.Authentication.GetTokenAsync("refresh_token") + "
"); await context.Response.WriteAsync("Token Type: " + await context.Authentication.GetTokenAsync("token_type") + "
"); await context.Response.WriteAsync("expires_at: " + await context.Authentication.GetTokenAsync("expires_at") + "
"); - await context.Response.WriteAsync("Logout"); + await context.Response.WriteAsync("Logout
"); await context.Response.WriteAsync(""); }); } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index d6cc4ce7fc..f1ad0d0559 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -89,9 +89,32 @@ namespace Microsoft.AspNetCore.Authentication protected abstract Task HandleRemoteAuthenticateAsync(); - protected override Task HandleAuthenticateAsync() + protected override async Task HandleAuthenticateAsync() { - return Task.FromResult(AuthenticateResult.Fail("Remote authentication does not support authenticate")); + // Most RemoteAuthenticationHandlers will have a PriorHandler, but it might not be set up during unit tests. + if (PriorHandler != null) + { + var authenticateContext = new AuthenticateContext(Options.SignInScheme); + await PriorHandler.AuthenticateAsync(authenticateContext); + if (authenticateContext.Accepted) + { + if (authenticateContext.Error != null) + { + return AuthenticateResult.Fail(authenticateContext.Error); + } + + if (authenticateContext.Principal != null) + { + return AuthenticateResult.Success(new AuthenticationTicket(authenticateContext.Principal, + new AuthenticationProperties(authenticateContext.Properties), Options.AuthenticationScheme)); + } + + return AuthenticateResult.Fail("Not authenticated"); + } + + } + + return AuthenticateResult.Fail("Remote authentication does not support authenticate"); } protected override Task HandleSignOutAsync(SignOutContext context) @@ -104,9 +127,11 @@ namespace Microsoft.AspNetCore.Authentication throw new NotSupportedException(); } - protected override Task HandleForbiddenAsync(ChallengeContext context) + protected override async Task HandleForbiddenAsync(ChallengeContext context) { - throw new NotSupportedException(); + var challengeContext = new ChallengeContext(Options.SignInScheme, context.Properties, ChallengeBehavior.Forbidden); + await PriorHandler.ChallengeAsync(challengeContext); + return challengeContext.Accepted; } protected virtual void GenerateCorrelationId(AuthenticationProperties properties) From 2634fe318d8b81a3fc6e7e67a2dca980fb9bcc69 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 24 May 2016 13:53:57 -0700 Subject: [PATCH 540/900] #814 Rework CookieAuth for compat with CookiePolicy. --- .../ChunkingCookieManager.cs | 114 ++----- .../CookieAuthenticationMiddleware.cs | 2 +- .../ChunkingCookieManager.cs | 281 ++++++++++++++++++ .../Constants.cs | 13 + .../Infrastructure/CookieChunkingTests.cs | 68 +---- .../CookiePolicyTests.cs | 99 ++++++ .../project.json | 1 + .../CookieInteropTests.cs | 147 ++++++++- 8 files changed, 569 insertions(+), 156 deletions(-) create mode 100644 src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs create mode 100644 src/Microsoft.Owin.Security.Interop/Constants.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs index 380e6f9374..c7bff38d1f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Text.Encodings.Web; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; @@ -18,13 +17,16 @@ namespace Microsoft.AspNetCore.Authentication.Cookies ///
public class ChunkingCookieManager : ICookieManager { - public ChunkingCookieManager(UrlEncoder urlEncoder) + private const string ChunkKeySuffix = "C"; + private const string ChunkCountPrefix = "chunks-"; + + public ChunkingCookieManager() { // Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case. // See http://browsercookielimits.x64.me/. - ChunkSize = 4090; + // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. + ChunkSize = 4070; ThrowForPartialCookies = true; - Encoder = urlEncoder ?? UrlEncoder.Default; } /// @@ -41,14 +43,12 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// public bool ThrowForPartialCookies { get; set; } - private UrlEncoder Encoder { get; set; } - - // Parse the "chunks:XX" to determine how many chunks there should be. + // Parse the "chunks-XX" to determine how many chunks there should be. private static int ParseChunksCount(string value) { - if (value != null && value.StartsWith("chunks:", StringComparison.Ordinal)) + if (value != null && value.StartsWith(ChunkCountPrefix, StringComparison.Ordinal)) { - var chunksCountString = value.Substring("chunks:".Length); + var chunksCountString = value.Substring(ChunkCountPrefix.Length); int chunksCount; if (int.TryParse(chunksCountString, NumberStyles.None, CultureInfo.InvariantCulture, out chunksCount)) { @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Get the reassembled cookie. Non chunked cookies are returned normally. - /// Cookies with missing chunks just have their "chunks:XX" header returned. + /// Cookies with missing chunks just have their "chunks-XX" header returned. /// /// /// @@ -82,11 +82,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var chunksCount = ParseChunksCount(value); if (chunksCount > 0) { - var quoted = false; var chunks = new string[chunksCount]; for (var chunkId = 1; chunkId <= chunksCount; chunkId++) { - var chunk = requestCookies[key + "C" + chunkId.ToString(CultureInfo.InvariantCulture)]; + var chunk = requestCookies[key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture)]; if (string.IsNullOrEmpty(chunk)) { if (ThrowForPartialCookies) @@ -102,20 +101,11 @@ namespace Microsoft.AspNetCore.Authentication.Cookies // Missing chunk, abort by returning the original cookie value. It may have been a false positive? return value; } - if (IsQuoted(chunk)) - { - // Note: Since we assume these cookies were generated by our code, then we can assume that if one cookie has quotes then they all do. - quoted = true; - chunk = RemoveQuotes(chunk); - } + chunks[chunkId - 1] = chunk; } - var merged = string.Join(string.Empty, chunks); - if (quoted) - { - merged = Quote(merged); - } - return merged; + + return string.Join(string.Empty, chunks); } return value; } @@ -123,7 +113,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Appends a new response cookie to the Set-Cookie header. If the cookie is larger than the given size limit /// then it will be broken down into multiple cookies as follows: - /// Set-Cookie: CookieName=chunks:3; path=/ + /// Set-Cookie: CookieName=chunks-3; path=/ /// Set-Cookie: CookieNameC1=Segment1; path=/ /// Set-Cookie: CookieNameC2=Segment2; path=/ /// Set-Cookie: CookieNameC3=Segment3; path=/ @@ -149,9 +139,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies throw new ArgumentNullException(nameof(options)); } - var escapedKey = Encoder.Encode(key); - - var template = new SetCookieHeaderValue(escapedKey) + var template = new SetCookieHeaderValue(key) { Domain = options.Domain, Expires = options.Expires, @@ -163,22 +151,14 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var templateLength = template.ToString().Length; value = value ?? string.Empty; - var quoted = false; - if (IsQuoted(value)) - { - quoted = true; - value = RemoveQuotes(value); - } - var escapedValue = Encoder.Encode(value); // Normal cookie - var responseHeaders = context.Response.Headers; - if (!ChunkSize.HasValue || ChunkSize.Value > templateLength + escapedValue.Length + (quoted ? 2 : 0)) + var responseCookies = context.Response.Cookies; + if (!ChunkSize.HasValue || ChunkSize.Value > templateLength + value.Length) { - template.Value = quoted ? Quote(escapedValue) : escapedValue; - responseHeaders.Append(Constants.Headers.SetCookie, template.ToString()); + responseCookies.Append(key, value, options); } - else if (ChunkSize.Value < templateLength + (quoted ? 2 : 0) + 10) + else if (ChunkSize.Value < templateLength + 10) { // 10 is the minimum data we want to put in an individual cookie, including the cookie chunk identifier "CXX". // No room for data, we can't chunk the options and name @@ -188,30 +168,25 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { // Break the cookie down into multiple cookies. // Key = CookieName, value = "Segment1Segment2Segment2" - // Set-Cookie: CookieName=chunks:3; path=/ + // Set-Cookie: CookieName=chunks-3; path=/ // Set-Cookie: CookieNameC1="Segment1"; path=/ // Set-Cookie: CookieNameC2="Segment2"; path=/ // Set-Cookie: CookieNameC3="Segment3"; path=/ - var dataSizePerCookie = ChunkSize.Value - templateLength - (quoted ? 2 : 0) - 3; // Budget 3 chars for the chunkid. - var cookieChunkCount = (int)Math.Ceiling(escapedValue.Length * 1.0 / dataSizePerCookie); + var dataSizePerCookie = ChunkSize.Value - templateLength - 3; // Budget 3 chars for the chunkid. + var cookieChunkCount = (int)Math.Ceiling(value.Length * 1.0 / dataSizePerCookie); - template.Value = "chunks:" + cookieChunkCount.ToString(CultureInfo.InvariantCulture); - responseHeaders.Append(Constants.Headers.SetCookie, template.ToString()); + responseCookies.Append(key, ChunkCountPrefix + cookieChunkCount.ToString(CultureInfo.InvariantCulture), options); - var chunks = new string[cookieChunkCount]; var offset = 0; for (var chunkId = 1; chunkId <= cookieChunkCount; chunkId++) { - var remainingLength = escapedValue.Length - offset; + var remainingLength = value.Length - offset; var length = Math.Min(dataSizePerCookie, remainingLength); - var segment = escapedValue.Substring(offset, length); + var segment = value.Substring(offset, length); offset += length; - template.Name = escapedKey + "C" + chunkId.ToString(CultureInfo.InvariantCulture); - template.Value = quoted ? Quote(segment) : segment; - chunks[chunkId - 1] = template.ToString(); + responseCookies.Append(key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture), segment, options); } - responseHeaders.Append(Constants.Headers.SetCookie, chunks); } } @@ -239,9 +214,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies throw new ArgumentNullException(nameof(options)); } - var escapedKey = Encoder.Encode(key); var keys = new List(); - keys.Add(escapedKey + "="); + keys.Add(key + "="); var requestCookie = context.Request.Cookies[key]; var chunks = ParseChunksCount(requestCookie); @@ -249,7 +223,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { for (int i = 1; i <= chunks + 1; i++) { - var subkey = escapedKey + "C" + i.ToString(CultureInfo.InvariantCulture); + var subkey = key + ChunkKeySuffix + i.ToString(CultureInfo.InvariantCulture); keys.Add(subkey + "="); } } @@ -304,35 +278,5 @@ namespace Microsoft.AspNetCore.Authentication.Cookies }); } } - - private static bool IsQuoted(string value) - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - - return value.Length >= 2 && value[0] == '"' && value[value.Length - 1] == '"'; - } - - private static string RemoveQuotes(string value) - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - - return value.Substring(1, value.Length - 2); - } - - private static string Quote(string value) - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - - return '"' + value + '"'; - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs index ff54957cfe..14d152a818 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } if (Options.CookieManager == null) { - Options.CookieManager = new ChunkingCookieManager(urlEncoder); + Options.CookieManager = new ChunkingCookieManager(); } if (!Options.LoginPath.HasValue) { diff --git a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs new file mode 100644 index 0000000000..b323258d9b --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs @@ -0,0 +1,281 @@ +// 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.Collections.Generic; +using System.Globalization; +using System.Linq; +using Microsoft.Owin.Infrastructure; + +namespace Microsoft.Owin.Security.Interop +{ + // This MUST be kept in sync with Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager + /// + /// This handles cookies that are limited by per cookie length. It breaks down long cookies for responses, and reassembles them + /// from requests. + /// + public class ChunkingCookieManager : ICookieManager + { + private const string ChunkKeySuffix = "C"; + private const string ChunkCountPrefix = "chunks-"; + + public ChunkingCookieManager() + { + // Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case. + // See http://browsercookielimits.x64.me/. + // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. + ChunkSize = 4070; + ThrowForPartialCookies = true; + } + + /// + /// The maximum size of cookie to send back to the client. If a cookie exceeds this size it will be broken down into multiple + /// cookies. Set this value to null to disable this behavior. The default is 4090 characters, which is supported by all + /// common browsers. + /// + /// Note that browsers may also have limits on the total size of all cookies per domain, and on the number of cookies per domain. + /// + public int? ChunkSize { get; set; } + + /// + /// Throw if not all chunks of a cookie are available on a request for re-assembly. + /// + public bool ThrowForPartialCookies { get; set; } + + // Parse the "chunks-XX" to determine how many chunks there should be. + private static int ParseChunksCount(string value) + { + if (value != null && value.StartsWith(ChunkCountPrefix, StringComparison.Ordinal)) + { + var chunksCountString = value.Substring(ChunkCountPrefix.Length); + int chunksCount; + if (int.TryParse(chunksCountString, NumberStyles.None, CultureInfo.InvariantCulture, out chunksCount)) + { + return chunksCount; + } + } + return 0; + } + + /// + /// Get the reassembled cookie. Non chunked cookies are returned normally. + /// Cookies with missing chunks just have their "chunks-XX" header returned. + /// + /// + /// + /// The reassembled cookie, if any, or null. + public string GetRequestCookie(IOwinContext context, string key) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + var requestCookies = context.Request.Cookies; + var value = requestCookies[key]; + var chunksCount = ParseChunksCount(value); + if (chunksCount > 0) + { + var chunks = new string[chunksCount]; + for (var chunkId = 1; chunkId <= chunksCount; chunkId++) + { + var chunk = requestCookies[key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture)]; + if (string.IsNullOrEmpty(chunk)) + { + if (ThrowForPartialCookies) + { + var totalSize = 0; + for (int i = 0; i < chunkId - 1; i++) + { + totalSize += chunks[i].Length; + } + throw new FormatException( + string.Format(CultureInfo.CurrentCulture, + "The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded.", + chunkId - 1, chunksCount, totalSize)); + } + // Missing chunk, abort by returning the original cookie value. It may have been a false positive? + return value; + } + + chunks[chunkId - 1] = chunk; + } + + return string.Join(string.Empty, chunks); + } + return value; + } + + /// + /// Appends a new response cookie to the Set-Cookie header. If the cookie is larger than the given size limit + /// then it will be broken down into multiple cookies as follows: + /// Set-Cookie: CookieName=chunks-3; path=/ + /// Set-Cookie: CookieNameC1=Segment1; path=/ + /// Set-Cookie: CookieNameC2=Segment2; path=/ + /// Set-Cookie: CookieNameC3=Segment3; path=/ + /// + /// + /// + /// + /// + public void AppendResponseCookie(IOwinContext context, string key, string value, CookieOptions options) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var domainHasValue = !string.IsNullOrEmpty(options.Domain); + var pathHasValue = !string.IsNullOrEmpty(options.Path); + var expiresHasValue = options.Expires.HasValue; + + var templateLength = key.Length + "=".Length + + (domainHasValue ? "; domain=".Length + options.Domain.Length : 0) + + (pathHasValue ? "; path=".Length + options.Path.Length : 0) + + (expiresHasValue ? "; expires=ddd, dd-MMM-yyyy HH:mm:ss GMT".Length : 0) + + (options.Secure ? "; secure".Length : 0) + + (options.HttpOnly ? "; HttpOnly".Length : 0); + + // Normal cookie + var responseCookies = context.Response.Cookies; + if (!ChunkSize.HasValue || ChunkSize.Value > templateLength + value.Length) + { + responseCookies.Append(key, value, options); + } + else if (ChunkSize.Value < templateLength + 10) + { + // 10 is the minimum data we want to put in an individual cookie, including the cookie chunk identifier "CXX". + // No room for data, we can't chunk the options and name + throw new InvalidOperationException("The cookie key and options are larger than ChunksSize, leaving no room for data."); + } + else + { + // Break the cookie down into multiple cookies. + // Key = CookieName, value = "Segment1Segment2Segment2" + // Set-Cookie: CookieName=chunks-3; path=/ + // Set-Cookie: CookieNameC1="Segment1"; path=/ + // Set-Cookie: CookieNameC2="Segment2"; path=/ + // Set-Cookie: CookieNameC3="Segment3"; path=/ + var dataSizePerCookie = ChunkSize.Value - templateLength - 3; // Budget 3 chars for the chunkid. + var cookieChunkCount = (int)Math.Ceiling(value.Length * 1.0 / dataSizePerCookie); + + responseCookies.Append(key, ChunkCountPrefix + cookieChunkCount.ToString(CultureInfo.InvariantCulture), options); + + var offset = 0; + for (var chunkId = 1; chunkId <= cookieChunkCount; chunkId++) + { + var remainingLength = value.Length - offset; + var length = Math.Min(dataSizePerCookie, remainingLength); + var segment = value.Substring(offset, length); + offset += length; + + responseCookies.Append(key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture), segment, options); + } + } + } + + /// + /// Deletes the cookie with the given key by setting an expired state. If a matching chunked cookie exists on + /// the request, delete each chunk. + /// + /// + /// + /// + public void DeleteCookie(IOwinContext context, string key, CookieOptions options) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var keys = new List(); + keys.Add(key + "="); + + var requestCookie = context.Request.Cookies[key]; + var chunks = ParseChunksCount(requestCookie); + if (chunks > 0) + { + for (int i = 1; i <= chunks + 1; i++) + { + var subkey = key + ChunkKeySuffix + i.ToString(CultureInfo.InvariantCulture); + keys.Add(subkey + "="); + } + } + + var domainHasValue = !string.IsNullOrEmpty(options.Domain); + var pathHasValue = !string.IsNullOrEmpty(options.Path); + + Func rejectPredicate; + Func predicate = value => keys.Any(k => value.StartsWith(k, StringComparison.OrdinalIgnoreCase)); + if (domainHasValue) + { + rejectPredicate = value => predicate(value) && value.IndexOf("domain=" + options.Domain, StringComparison.OrdinalIgnoreCase) != -1; + } + else if (pathHasValue) + { + rejectPredicate = value => predicate(value) && value.IndexOf("path=" + options.Path, StringComparison.OrdinalIgnoreCase) != -1; + } + else + { + rejectPredicate = value => predicate(value); + } + + var responseHeaders = context.Response.Headers; + string[] existingValues; + if (responseHeaders.TryGetValue(Constants.Headers.SetCookie, out existingValues) && existingValues != null) + { + responseHeaders.SetValues(Constants.Headers.SetCookie, existingValues.Where(value => !rejectPredicate(value)).ToArray()); + } + + AppendResponseCookie( + context, + key, + string.Empty, + new CookieOptions() + { + Path = options.Path, + Domain = options.Domain, + Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), + }); + + for (int i = 1; i <= chunks; i++) + { + AppendResponseCookie( + context, + key + "C" + i.ToString(CultureInfo.InvariantCulture), + string.Empty, + new CookieOptions() + { + Path = options.Path, + Domain = options.Domain, + Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), + }); + } + } + } +} diff --git a/src/Microsoft.Owin.Security.Interop/Constants.cs b/src/Microsoft.Owin.Security.Interop/Constants.cs new file mode 100644 index 0000000000..1e75761b70 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/Constants.cs @@ -0,0 +1,13 @@ +// 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.Owin.Security.Interop +{ + internal static class Constants + { + internal static class Headers + { + internal const string SetCookie = "Set-Cookie"; + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs index 4b92f08c8d..670baf5db4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure HttpContext context = new DefaultHttpContext(); string testString = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - new ChunkingCookieManager(null) { ChunkSize = null }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); + new ChunkingCookieManager() { ChunkSize = null }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); var values = context.Response.Headers["Set-Cookie"]; Assert.Equal(1, values.Count); Assert.Equal("TestCookie=" + testString + "; path=/", values[0]); @@ -27,12 +27,12 @@ namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure HttpContext context = new DefaultHttpContext(); string testString = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - new ChunkingCookieManager(null) { ChunkSize = 30 }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); + new ChunkingCookieManager() { ChunkSize = 30 }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); var values = context.Response.Headers["Set-Cookie"]; Assert.Equal(9, values.Count); Assert.Equal(new[] { - "TestCookie=chunks:8; path=/", + "TestCookie=chunks-8; path=/", "TestCookieC1=abcdefgh; path=/", "TestCookieC2=ijklmnop; path=/", "TestCookieC3=qrstuvwx; path=/", @@ -44,36 +44,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure }, values); } - [Fact] - public void AppendLargeQuotedCookieWithLimit_QuotedChunked() - { - HttpContext context = new DefaultHttpContext(); - - string testString = "\"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\""; - new ChunkingCookieManager(null) { ChunkSize = 32 }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); - var values = context.Response.Headers["Set-Cookie"]; - Assert.Equal(9, values.Count); - Assert.Equal(new[] - { - "TestCookie=chunks:8; path=/", - "TestCookieC1=\"abcdefgh\"; path=/", - "TestCookieC2=\"ijklmnop\"; path=/", - "TestCookieC3=\"qrstuvwx\"; path=/", - "TestCookieC4=\"yz012345\"; path=/", - "TestCookieC5=\"6789ABCD\"; path=/", - "TestCookieC6=\"EFGHIJKL\"; path=/", - "TestCookieC7=\"MNOPQRST\"; path=/", - "TestCookieC8=\"UVWXYZ\"; path=/", - }, values); - } - [Fact] public void GetLargeChunkedCookie_Reassembled() { HttpContext context = new DefaultHttpContext(); context.Request.Headers["Cookie"] = new[] { - "TestCookie=chunks:7", + "TestCookie=chunks-7", "TestCookieC1=abcdefghi", "TestCookieC2=jklmnopqr", "TestCookieC3=stuvwxyz0", @@ -83,39 +60,18 @@ namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure "TestCookieC7=STUVWXYZ" }; - string result = new ChunkingCookieManager(null).GetRequestCookie(context, "TestCookie"); + string result = new ChunkingCookieManager().GetRequestCookie(context, "TestCookie"); string testString = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Assert.Equal(testString, result); } - [Fact] - public void GetLargeChunkedCookieWithQuotes_Reassembled() - { - HttpContext context = new DefaultHttpContext(); - context.Request.Headers["Cookie"] = new[] - { - "TestCookie=chunks:7", - "TestCookieC1=\"abcdefghi\"", - "TestCookieC2=\"jklmnopqr\"", - "TestCookieC3=\"stuvwxyz0\"", - "TestCookieC4=\"123456789\"", - "TestCookieC5=\"ABCDEFGHI\"", - "TestCookieC6=\"JKLMNOPQR\"", - "TestCookieC7=\"STUVWXYZ\"" - }; - - string result = new ChunkingCookieManager(null).GetRequestCookie(context, "TestCookie"); - string testString = "\"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\""; - Assert.Equal(testString, result); - } - [Fact] public void GetLargeChunkedCookieWithMissingChunk_ThrowingEnabled_Throws() { HttpContext context = new DefaultHttpContext(); context.Request.Headers["Cookie"] = new[] { - "TestCookie=chunks:7", + "TestCookie=chunks-7", "TestCookieC1=abcdefghi", // Missing chunk "TestCookieC2=jklmnopqr", "TestCookieC3=stuvwxyz0", @@ -125,7 +81,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure "TestCookieC7=STUVWXYZ" }; - Assert.Throws(() => new ChunkingCookieManager(null).GetRequestCookie(context, "TestCookie")); + Assert.Throws(() => new ChunkingCookieManager().GetRequestCookie(context, "TestCookie")); } [Fact] @@ -134,7 +90,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure HttpContext context = new DefaultHttpContext(); context.Request.Headers["Cookie"] = new[] { - "TestCookie=chunks:7", + "TestCookie=chunks-7", "TestCookieC1=abcdefghi", // Missing chunk "TestCookieC2=jklmnopqr", "TestCookieC3=stuvwxyz0", @@ -144,8 +100,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure "TestCookieC7=STUVWXYZ" }; - string result = new ChunkingCookieManager(null) { ThrowForPartialCookies = false }.GetRequestCookie(context, "TestCookie"); - string testString = "chunks:7"; + string result = new ChunkingCookieManager() { ThrowForPartialCookies = false }.GetRequestCookie(context, "TestCookie"); + string testString = "chunks-7"; Assert.Equal(testString, result); } @@ -153,9 +109,9 @@ namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure public void DeleteChunkedCookieWithOptions_AllDeleted() { HttpContext context = new DefaultHttpContext(); - context.Request.Headers.Append("Cookie", "TestCookie=chunks:7"); + context.Request.Headers.Append("Cookie", "TestCookie=chunks-7"); - new ChunkingCookieManager(null).DeleteCookie(context, "TestCookie", new CookieOptions() { Domain = "foo.com" }); + new ChunkingCookieManager().DeleteCookie(context, "TestCookie", new CookieOptions() { Domain = "foo.com" }); var cookies = context.Response.Headers["Set-Cookie"]; Assert.Equal(8, cookies.Count); Assert.Equal(new[] diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index f08d7fef8e..34d967617b 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -2,12 +2,17 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Security.Claims; +using System.Security.Principal; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.CookiePolicy.Test @@ -228,6 +233,100 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test Assert.Equal("Done", transaction.ResponseText); } + [Fact] + public async Task CookiePolicyAppliesToCookieAuth() + { + var builder = new WebHostBuilder() + .ConfigureServices(services => + { + services.AddAuthentication(); + }) + .Configure(app => + { + app.UseCookiePolicy(new CookiePolicyOptions + { + HttpOnly = HttpOnlyPolicy.Always, + Secure = CookieSecurePolicy.Always, + }); + app.UseCookieAuthentication(new CookieAuthenticationOptions() + { + CookieName = "TestCookie", + CookieHttpOnly = false, + CookieSecure = CookieSecurePolicy.None, + }); + app.Run(context => + { + return context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("TestUser", "Cookies")))); + }); + }); + var server = new TestServer(builder); + + var transaction = await server.SendAsync("http://example.com/login"); + + Assert.NotNull(transaction.SetCookie); + Assert.Equal(1, transaction.SetCookie.Count); + var cookie = SetCookieHeaderValue.Parse(transaction.SetCookie[0]); + Assert.Equal("TestCookie", cookie.Name); + Assert.True(cookie.HttpOnly); + Assert.True(cookie.Secure); + Assert.Equal("/", cookie.Path); + } + + [Fact] + public async Task CookiePolicyAppliesToCookieAuthChunks() + { + var builder = new WebHostBuilder() + .ConfigureServices(services => + { + services.AddAuthentication(); + }) + .Configure(app => + { + app.UseCookiePolicy(new CookiePolicyOptions + { + HttpOnly = HttpOnlyPolicy.Always, + Secure = CookieSecurePolicy.Always, + }); + app.UseCookieAuthentication(new CookieAuthenticationOptions() + { + CookieName = "TestCookie", + CookieHttpOnly = false, + CookieSecure = CookieSecurePolicy.None, + }); + app.Run(context => + { + return context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity(new string('c', 1024 * 5), "Cookies")))); + }); + }); + var server = new TestServer(builder); + + var transaction = await server.SendAsync("http://example.com/login"); + + Assert.NotNull(transaction.SetCookie); + Assert.Equal(3, transaction.SetCookie.Count); + + var cookie = SetCookieHeaderValue.Parse(transaction.SetCookie[0]); + Assert.Equal("TestCookie", cookie.Name); + Assert.Equal("chunks-2", cookie.Value); + Assert.True(cookie.HttpOnly); + Assert.True(cookie.Secure); + Assert.Equal("/", cookie.Path); + + cookie = SetCookieHeaderValue.Parse(transaction.SetCookie[1]); + Assert.Equal("TestCookieC1", cookie.Name); + Assert.True(cookie.HttpOnly); + Assert.True(cookie.Secure); + Assert.Equal("/", cookie.Path); + + cookie = SetCookieHeaderValue.Parse(transaction.SetCookie[2]); + Assert.Equal("TestCookieC2", cookie.Name); + Assert.True(cookie.HttpOnly); + Assert.True(cookie.Secure); + Assert.Equal("/", cookie.Path); + } + private class TestCookieFeature : IResponseCookiesFeature { public IResponseCookies Cookies { get; } = new BadCookies(); diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 6e64aba57d..26cc946be1 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -5,6 +5,7 @@ "dependencies": { "dotnet-test-xunit": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.CookiePolicy": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index 2abb115e47..79288b026d 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.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.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; @@ -14,6 +15,7 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; using Microsoft.Owin.Security.Cookies; using Microsoft.Owin.Testing; using Owin; @@ -71,12 +73,73 @@ namespace Microsoft.Owin.Security.Interop var newServer = new AspNetCore.TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); - request.Headers.Add("Cookie", transaction.SetCookie.Split(new[] { ';' }, 2).First()); + foreach (var cookie in SetCookieHeaderValue.ParseList(transaction.SetCookie)) + { + request.Headers.Add("Cookie", cookie.Name + "=" + cookie.Value); + } var response = await newServer.CreateClient().SendAsync(request); Assert.Equal("Alice", await response.Content.ReadAsStringAsync()); } + [Fact] + public async Task AspNetCoreWithLargeInteropCookieContainsIdentity() + { + var identity = new ClaimsIdentity("Cookies"); + identity.AddClaim(new Claim(ClaimTypes.Name, new string('a', 1024 * 5))); + + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type + CookieAuthenticationDefaults.AuthenticationType, "v2"); + + var interopServer = TestServer.Create(app => + { + app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; + + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, + CookieManager = new ChunkingCookieManager(), + }); + + app.Run(context => + { + context.Authentication.SignIn(identity); + return Task.FromResult(0); + }); + }); + + var transaction = await SendAsync(interopServer, "http://example.com"); + + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions + { + DataProtectionProvider = dataProtection + }); + app.Run(async context => + { + var result = await context.Authentication.AuthenticateAsync("Cookies"); + await context.Response.WriteAsync(result.Identity.Name); + }); + }) + .ConfigureServices(services => services.AddAuthentication()); + var newServer = new AspNetCore.TestHost.TestServer(builder); + + var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); + foreach (var cookie in SetCookieHeaderValue.ParseList(transaction.SetCookie)) + { + request.Headers.Add("Cookie", cookie.Name + "=" + cookie.Value); + } + var response = await newServer.CreateClient().SendAsync(request); + + Assert.Equal(1024 * 5, (await response.Content.ReadAsStringAsync()).Length); + } + [Fact] public async Task InteropWithNewCookieContainsIdentity() { @@ -102,13 +165,13 @@ namespace Microsoft.Owin.Security.Interop .ConfigureServices(services => services.AddAuthentication()); var newServer = new AspNetCore.TestHost.TestServer(builder); - var cookie = await SendAndGetCookie(newServer, "http://example.com/login"); + var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); var server = TestServer.Create(app => { app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - app.UseCookieAuthentication(new Owin.Security.Cookies.CookieAuthenticationOptions + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions { TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix @@ -122,18 +185,74 @@ namespace Microsoft.Owin.Security.Interop }); }); - var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookie); + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookies); Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); } - private static async Task SendAndGetCookie(AspNetCore.TestHost.TestServer server, string uri) + [Fact] + public async Task InteropWithLargeNewCookieContainsIdentity() + { + var user = new ClaimsPrincipal(); + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim(ClaimTypes.Name, new string('a', 1024 * 5))); + user.AddIdentity(identity); + + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type + CookieAuthenticationDefaults.AuthenticationType, "v2"); + + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions + { + DataProtectionProvider = dataProtection + }); + app.Run(context => context.Authentication.SignInAsync("Cookies", user)); + }) + .ConfigureServices(services => services.AddAuthentication()); + var newServer = new AspNetCore.TestHost.TestServer(builder); + + var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); + + var server = TestServer.Create(app => + { + app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; + + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, + CookieManager = new ChunkingCookieManager(), + }); + + app.Run(async context => + { + var result = await context.Authentication.AuthenticateAsync("Cookies"); + Describe(context.Response, result); + }); + }); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookies); + + Assert.Equal(1024 * 5, FindClaimValue(transaction2, ClaimTypes.Name).Length); + } + + private static async Task> SendAndGetCookies(AspNetCore.TestHost.TestServer server, string uri) { var request = new HttpRequestMessage(HttpMethod.Get, uri); var response = await server.CreateClient().SendAsync(request); if (response.Headers.Contains("Set-Cookie")) { - return response.Headers.GetValues("Set-Cookie").ToList().First(); + IList cookieHeaders = new List(); + foreach (var cookie in SetCookieHeaderValue.ParseList(response.Headers.GetValues("Set-Cookie").ToList())) + { + cookieHeaders.Add(cookie.Name + "=" + cookie.Value); + } + return cookieHeaders; } return null; } @@ -148,7 +267,7 @@ namespace Microsoft.Owin.Security.Interop return claim.Attribute("value").Value; } - private static void Describe(IOwinResponse res, Owin.Security.AuthenticateResult result) + private static void Describe(IOwinResponse res, AuthenticateResult result) { res.StatusCode = 200; res.ContentType = "text/xml"; @@ -171,12 +290,12 @@ namespace Microsoft.Owin.Security.Interop } } - private static async Task SendAsync(TestServer server, string uri, string cookieHeader = null, bool ajaxRequest = false) + private static async Task SendAsync(TestServer server, string uri, IList cookieHeaders = null, bool ajaxRequest = false) { var request = new HttpRequestMessage(HttpMethod.Get, uri); - if (!string.IsNullOrEmpty(cookieHeader)) + if (cookieHeaders != null) { - request.Headers.Add("Cookie", cookieHeader); + request.Headers.Add("Cookie", cookieHeaders); } if (ajaxRequest) { @@ -189,11 +308,11 @@ namespace Microsoft.Owin.Security.Interop }; if (transaction.Response.Headers.Contains("Set-Cookie")) { - transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").SingleOrDefault(); + transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").ToList(); } - if (!string.IsNullOrEmpty(transaction.SetCookie)) + if (transaction.SetCookie != null && transaction.SetCookie.Any()) { - transaction.CookieNameValue = transaction.SetCookie.Split(new[] { ';' }, 2).First(); + transaction.CookieNameValue = transaction.SetCookie.First().Split(new[] { ';' }, 2).First(); } transaction.ResponseText = await transaction.Response.Content.ReadAsStringAsync(); @@ -211,7 +330,7 @@ namespace Microsoft.Owin.Security.Interop public HttpRequestMessage Request { get; set; } public HttpResponseMessage Response { get; set; } - public string SetCookie { get; set; } + public IList SetCookie { get; set; } public string CookieNameValue { get; set; } public string ResponseText { get; set; } From e57e01d02c35fc50160ff1ce0983450d7efeb1ce Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 26 May 2016 18:25:05 -0700 Subject: [PATCH 541/900] React to updated CoreCLR packages https://github.com/aspnet/Coherence/issues/97 --- src/Microsoft.AspNetCore.Authentication/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index 06de08d84b..e5107da8fc 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -40,7 +40,7 @@ }, "netstandard1.3": { "dependencies": { - "System.Net.Http": "4.0.1-*" + "System.Net.Http": "4.1.0-*" }, "imports": [ "portable-net451" From b358f571d673e230f612c08f95f9c5352a483375 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Fri, 27 May 2016 11:36:59 -0700 Subject: [PATCH 542/900] Fix OSX build on Travis. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index df22f7a880..ceb3c7b67b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,5 +22,7 @@ branches: - release - dev - /^(.*\/)?ci-.*$/ +before_install: + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; brew link --force openssl; fi script: - ./build.sh verify \ No newline at end of file From d6763bd77c931aeff1024cafd03255abfe55b753 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 25 May 2016 16:00:57 -0700 Subject: [PATCH 543/900] #423 Support distributed sign-out. --- samples/OpenIdConnectSample/Program.cs | 32 +++++++++++++++--- .../Properties/launchSettings.json | 9 ++--- samples/OpenIdConnectSample/Startup.cs | 19 +++++++++++ .../compiler/resources/cert.pfx | Bin 0 -> 2483 bytes samples/OpenIdConnectSample/project.json | 2 ++ samples/SocialSample/Program.cs | 3 -- .../Events/IOpenIdConnectEvents.cs | 5 +++ .../Events/OpenIdConnectEvents.cs | 7 ++++ .../Events/RemoteSignoutContext.cs | 16 +++++++++ .../LoggingExtensions.cs | 30 ++++++++++++++++ .../OpenIdConnectHandler.cs | 27 +++++++++++++++ .../OpenIdConnectOptions.cs | 12 +++++++ 12 files changed, 150 insertions(+), 12 deletions(-) create mode 100644 samples/OpenIdConnectSample/compiler/resources/cert.pfx create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs index a81f11dfb0..fe77dd1a7c 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -1,6 +1,8 @@ using System.IO; +using System.Reflection; +using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.FileProviders; namespace OpenIdConnectSample { @@ -8,11 +10,13 @@ namespace OpenIdConnectSample { public static void Main(string[] args) { - var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); - var host = new WebHostBuilder() - .UseKestrel() - .UseConfiguration(config) + .UseKestrel(options => + { + //Configure SSL + var serverCertificate = LoadCertificate(); + options.UseHttps(serverCertificate); + }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() @@ -20,5 +24,23 @@ namespace OpenIdConnectSample host.Run(); } + + private static X509Certificate2 LoadCertificate() + { + var assembly = typeof(Startup).GetTypeInfo().Assembly; + var embeddedFileProvider = new EmbeddedFileProvider(assembly, "OpenIdConnectSample"); + var certificateFileInfo = embeddedFileProvider.GetFileInfo("compiler/resources/cert.pfx"); + using (var certificateStream = certificateFileInfo.CreateReadStream()) + { + byte[] certificatePayload; + using (var memoryStream = new MemoryStream()) + { + certificateStream.CopyTo(memoryStream); + certificatePayload = memoryStream.ToArray(); + } + + return new X509Certificate2(certificatePayload, "testPassword"); + } + } } } diff --git a/samples/OpenIdConnectSample/Properties/launchSettings.json b/samples/OpenIdConnectSample/Properties/launchSettings.json index 557b6921e2..48610115fa 100644 --- a/samples/OpenIdConnectSample/Properties/launchSettings.json +++ b/samples/OpenIdConnectSample/Properties/launchSettings.json @@ -4,13 +4,14 @@ "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:42023", - "sslPort": 0 + "sslPort": 44318 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, + "launchUrl": "https://localhost:44318/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -18,10 +19,10 @@ "OpenIdConnectSample": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "http://localhost:42023", + "launchUrl": "https://localhost:44318/", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_SERVER.URLS": "http://localhost:42023" + "ASPNETCORE_URLS": "https://localhost:44318/", + "ASPNETCORE_ENVIRONMENT": "Development" } } } diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 3fffe9ce69..6beaa0a20b 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -78,6 +78,14 @@ namespace OpenIdConnectSample app.Run(async context => { + if (context.Request.Path.Equals("/signedout")) + { + context.Response.ContentType = "text/html"; + await context.Response.WriteAsync($"You have been signed out.
{Environment.NewLine}"); + await context.Response.WriteAsync("Sign In"); + await context.Response.WriteAsync($""); + return; + } if (context.Request.Path.Equals("/signout")) { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); @@ -87,6 +95,16 @@ namespace OpenIdConnectSample await context.Response.WriteAsync($""); return; } + if (context.Request.Path.Equals("/signout-remote")) + { + // Redirects + await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties() + { + RedirectUri = "/signedout" + }); + await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + return; + } if (context.Request.Path.Equals("/Account/AccessDenied")) { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); @@ -134,6 +152,7 @@ namespace OpenIdConnectSample } await context.Response.WriteAsync("Restricted
"); await context.Response.WriteAsync("Sign Out
"); + await context.Response.WriteAsync("Sign Out Remote
"); await context.Response.WriteAsync($""); }); } diff --git a/samples/OpenIdConnectSample/compiler/resources/cert.pfx b/samples/OpenIdConnectSample/compiler/resources/cert.pfx new file mode 100644 index 0000000000000000000000000000000000000000..7118908c2d730670c16e9f8b2c532a262c951989 GIT binary patch literal 2483 zcmaKuc|27A8pqF>IWr86E&Q@(n=B)p$ug!;QVB6xij*z;uPLG!yCz#DQB)+9G$9m9 zQU)=DWXU?*EZIwG!+0d++P@yZ4Xhoagg?p6B~|Ue7tN=Ny=UD?x#1n1MTq z#c9MHh+D#gd|(a(cN}8i91v^=GcdgW3SmA$49p~gM-dys3jVWdg8+!iVL)pz1LDE5 zSb=|GAn(@R=(Ux!MfS9@}sFu-xDd zIt2+mqSq$glwy_6UNs<2?(qERU!gJ;5j}Pp&6trxG=wi)=@k(w2+fJVnc+qvXVzy(>Om4;L|^)R`t*3nTpAmEmTl(#i!RV#a0t#u6>Q9mY`-Nmcs7$XjXT7 zUmCD`O~_j7!%R#I?cG-7C^hcH)@l?WC1vyw$FFu_(r)jhOq6p}W8sG7NO{YTy8tG4 zrb$tTkag*G?(7lfoGx$4YWui>{{@}-FB2ub=}RX{1zx?j)s-##J9|G7E1@-;7Nuln z9MQoX7FJ76+D#XXT@ZZmLZCufIdf3@OigG6m8I7!GT=7VD|>?6e!z9=eT}*E_tSn6 zl+clHCZ-kcIR#gen#LjMJW8>0QtViaQB#FhqsCb0YPYr3;jRITl@V9Aph24D?r2d` zetCyyCg<*O-u+M& zW^ptmT|}p$VAOZpmbQ1{5fK-6ytEvre#Po}6c2URn`viQAF2+e?Z~PK2&pd>7=7)I zTCYm)@3PFRu_6a6Kb)IpCzQ%e3l%O#SDA+$Pq{Dk{HCqi7z>qd{nVpebffL7h{c4( zmhXn~G+C27S3(IfC)q2KON=YwqHXEo%zc40DgWLzF{%RIdr@RcLu90qMSHf!Y}JaqP<={8_Rfe;ddR5= zKEo;^Yip&^m((#{czE{kUga3-@`*;&EwO}Jt>QdURP2P>ob^j-A!qld-0S_pm)kjs zkNo48oZnMt){W~o8g^f;4#?lRLr-T@f}wH1o~-Iq=NEVtTVEZ`vrW~!>2yh%;Bc~H zHl&OK>n@d`*e19*9#v>zZpU?I);f7}IPIfSSk#N|ujE492Itg)l!)TJ19@FE^x|p= zH16NC7OfK&|6_!AnWfTIf^YPOa&`|nbk3VR0vql6&s@y1V3QOU%(`Re+kJgrz?r9!{^wOQ4W-eng23gc}f(LxIs zH_Ls~5izbjcRQH#WH6s6hR;zn>j_R8aJ$A)6xNneu8UI-vWV8Z@HZu&WwvG5q{1ZS zdZeVf{Pv5-u281~y;aJe*x%Uv0@biMZ$vPbKj}O`(SOWQc~kJX` zXR&d4DtAe@2RH$^ z0os5*;0eIUeJi3Uh`A%44x(XzjClG8BO~-r_A}odiRuHo2-86#`mhrgN5p~<$RLY? zq(kynfFA5{v#p+EA1 z5aoe1763EQHorRm`C&ktKn(OQ1n)$Q{GZz&jRb`eDEMpl<0O#+)DMV(T7nsIzCG{QuM->B9g7Lrl2SE&gW`M!~(un|y0fIn=b^6_$ z9{zEzgYI~39xn0ZP*9qBL%fg7rg$ttt&TOmvfNNO<6FT0ZavM$Y4CYLQGIcIYv9Y& zBGPUh&QTfW;V2!)oIra@s&d968y-y}Y|ww(R$GzWS*V&)k@W0>Slem{|HdTCjm;_5 zwY*A8W3nUbemE^_f0ng$tbd<`sr?TO-_&VCw+F#7P@LkIl$1PzTBoPY1b88EIO>UO zP-NK7+g2yD3U6g3i|iA6+su>54sf_Sk0F=)1|9odnCM4u2Rs z=&Y?-V&VquSN%3FJ2~ZGweP~iLs|w=l@9yu$tj@}Dp?e-2JUsqOoswdXb=E%&0te_ zA2M+{5Hf-dqD7=yw*r@A*xkn(1IS~nfP}k}e?4Bt|9g(eph4hFX_|S6nj1&Sz9z^= zRw~<&-9d@FzTn6S*RVE{Wj5lgLJr9HLB8S9CgOm*>XA8*y4`JE;^s$=bqD#U4;e5C&x&ggKIAVL zrQ)Yd8|{>7Z(6*B&7&4&9(*vDOfHMuR-Dk1IZia*XM^EZUD^{?cWG>J>KrtElc*{K zaVl(7SN2cH4I6Q$bZOpJ8e5LKaG7p;?tJ~#+9QrTYU@f#5`Vo7cEX!szCT}iX-K^2 w#3o+=C+lQz2J+SOEzVX(eJ)e7=eicC{rr9U2VGDcdH?_b literal 0 HcmV?d00001 diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 5f0744e0b7..32e19ca40e 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -5,7 +5,9 @@ "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", + "Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" }, diff --git a/samples/SocialSample/Program.cs b/samples/SocialSample/Program.cs index 386819e6f5..f3cad66ad3 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -11,8 +11,6 @@ namespace SocialSample { public static void Main(string[] args) { - var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); - var host = new WebHostBuilder() .UseKestrel(options => { @@ -20,7 +18,6 @@ namespace SocialSample var serverCertificate = LoadCertificate(); options.UseHttps(serverCertificate); }) - .UseConfiguration(config) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs index 57600cee8d..128fa08a3e 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs @@ -35,6 +35,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect ///
Task RedirectToIdentityProviderForSignOut(RedirectContext context); + /// + /// Invoked when a request is received on the RemoteSignOutPath. + /// + Task RemoteSignOut(RemoteSignOutContext context); + /// /// Invoked after "authorization code" is redeemed for tokens at the token endpoint. /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index 9893b72072..42d35b7982 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -36,6 +36,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// public Func OnRedirectToIdentityProviderForSignOut { get; set; } = context => Task.FromResult(0); + /// + /// Invoked when a request is received on the RemoteSignOutPath. + /// + public Func OnRemoteSignOut { get; set; } = context => Task.FromResult(0); + /// /// Invoked after "authorization code" is redeemed for tokens at the token endpoint. /// @@ -61,6 +66,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect public virtual Task RedirectToIdentityProviderForSignOut(RedirectContext context) => OnRedirectToIdentityProviderForSignOut(context); + public virtual Task RemoteSignOut(RemoteSignOutContext context) => OnRemoteSignOut(context); + public virtual Task TokenResponseReceived(TokenResponseReceivedContext context) => OnTokenResponseReceived(context); public virtual Task TokenValidated(TokenValidatedContext context) => OnTokenValidated(context); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs new file mode 100644 index 0000000000..b5077e035d --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs @@ -0,0 +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. + +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect +{ + public class RemoteSignOutContext : BaseOpenIdConnectContext + { + public RemoteSignOutContext(HttpContext context, OpenIdConnectOptions options) + : base(context, options) + { + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs index ff580ff266..ef1d5d83b9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -47,6 +47,9 @@ namespace Microsoft.Extensions.Logging private static Action _invalidSecurityTokenType; private static Action _unableToValidateIdToken; private static Action _postAuthenticationLocalRedirect; + private static Action _remoteSignOutHandledResponse; + private static Action _remoteSignOutSkipped; + private static Action _remoteSignOut; static LoggingExtensions() { @@ -211,6 +214,18 @@ namespace Microsoft.Extensions.Logging eventId: 43, logLevel: LogLevel.Error, formatString: "Unable to read the 'id_token', no suitable ISecurityTokenValidator was found for: '{IdToken}'."); + _remoteSignOutHandledResponse = LoggerMessage.Define( + eventId: 44, + logLevel: LogLevel.Debug, + formatString: "RemoteSignOutContext.HandledResponse"); + _remoteSignOutSkipped = LoggerMessage.Define( + eventId: 45, + logLevel: LogLevel.Debug, + formatString: "RemoteSignOutContext.Skipped"); + _remoteSignOut = LoggerMessage.Define( + eventId: 46, + logLevel: LogLevel.Information, + formatString: "Remote signout request processed."); } public static void UpdatingConfiguration(this ILogger logger) @@ -412,5 +427,20 @@ namespace Microsoft.Extensions.Logging { _postAuthenticationLocalRedirect(logger, redirectUri, null); } + + public static void RemoteSignOutHandledResponse(this ILogger logger) + { + _remoteSignOutHandledResponse(logger, null); + } + + public static void RemoteSignOutSkipped(this ILogger logger) + { + _remoteSignOutSkipped(logger, null); + } + + public static void RemoteSignOut(this ILogger logger) + { + _remoteSignOut(logger, null); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index f85ba9c146..e23173ed18 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -62,6 +62,33 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect HtmlEncoder = htmlEncoder; } + public override async Task HandleRequestAsync() + { + if (Options.RemoteSignOutPath.HasValue && Options.RemoteSignOutPath == Request.Path) + { + var remoteSignOutContext = new RemoteSignOutContext(Context, Options); + await Options.Events.RemoteSignOut(remoteSignOutContext); + + if (remoteSignOutContext.HandledResponse) + { + Logger.RemoteSignOutHandledResponse(); + return true; + } + if (remoteSignOutContext.Skipped) + { + Logger.RemoteSignOutSkipped(); + return false; + } + + Logger.RemoteSignOut(); + + // We've received a remote sign-out request + await Context.Authentication.SignOutAsync(Options.SignOutScheme ?? Options.SignInScheme); + return true; + } + return await base.HandleRequestAsync(); + } + /// /// Handles Signout /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index cdbc9e0f0d..c9b614acde 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -50,6 +50,7 @@ namespace Microsoft.AspNetCore.Builder AutomaticChallenge = true; DisplayName = OpenIdConnectDefaults.Caption; CallbackPath = new PathString("/signin-oidc"); + RemoteSignOutPath = new PathString("/signout-oidc"); Events = new OpenIdConnectEvents(); Scope.Add("openid"); Scope.Add("profile"); @@ -155,6 +156,17 @@ namespace Microsoft.AspNetCore.Builder /// public ICollection Scope { get; } = new HashSet(); + /// + /// Requests received on this path will cause the middleware to invoke SignOut using the SignInScheme. + /// + public PathString RemoteSignOutPath { get; set; } + + /// + /// The Authentication Scheme to use with SignOut on the SignOutPath. SignInScheme will be used if this + /// is not set. + /// + public string SignOutScheme { get; set; } + /// /// Gets or sets the type used to secure data handled by the middleware. /// From 871885259bd4172a21fb8059fb609a2964845ba4 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 24 May 2016 10:34:39 -0700 Subject: [PATCH 544/900] Update the OIDC AzureAd sample. --- .../AuthPropertiesTokenCache.cs | 69 +++++++++++++++---- .../OpenIdConnect.AzureAdSample/Program.cs | 3 - .../Properties/launchSettings.json | 2 +- .../OpenIdConnect.AzureAdSample/Startup.cs | 20 ++---- .../OpenIdConnect.AzureAdSample/project.json | 17 ++++- 5 files changed, 75 insertions(+), 36 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs b/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs index f174174cf8..54989c13a4 100644 --- a/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs +++ b/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs @@ -1,5 +1,9 @@ using System; +using System.Security.Claims; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.IdentityModel.Clients.ActiveDirectory; namespace OpenIdConnect.AzureAdSample @@ -8,46 +12,85 @@ namespace OpenIdConnect.AzureAdSample { private const string TokenCacheKey = ".TokenCache"; + private HttpContext _httpContext; + private ClaimsPrincipal _principal; private AuthenticationProperties _authProperties; + private string _signInScheme; - public bool HasCacheChanged { get; internal set; } - - public AuthPropertiesTokenCache(AuthenticationProperties authProperties) : base() + private AuthPropertiesTokenCache(AuthenticationProperties authProperties) : base() { _authProperties = authProperties; - BeforeAccess = BeforeAccessNotification; - AfterAccess = AfterAccessNotification; + BeforeAccess = BeforeAccessNotificationWithProperties; + AfterAccess = AfterAccessNotificationWithProperties; BeforeWrite = BeforeWriteNotification; + } + private AuthPropertiesTokenCache(HttpContext httpContext, string signInScheme) : base() + { + _httpContext = httpContext; + _signInScheme = signInScheme; + BeforeAccess = BeforeAccessNotificationWithContext; + AfterAccess = AfterAccessNotificationWithContext; + BeforeWrite = BeforeWriteNotification; + } + + public static TokenCache ForCodeRedemption(AuthenticationProperties authProperties) + { + return new AuthPropertiesTokenCache(authProperties); + } + + public static TokenCache ForApiCalls(HttpContext httpContext, + string signInScheme = CookieAuthenticationDefaults.AuthenticationScheme) + { + return new AuthPropertiesTokenCache(httpContext, signInScheme); + } + + private void BeforeAccessNotificationWithProperties(TokenCacheNotificationArgs args) + { string cachedTokensText; - if (authProperties.Items.TryGetValue(TokenCacheKey, out cachedTokensText)) + if (_authProperties.Items.TryGetValue(TokenCacheKey, out cachedTokensText)) { var cachedTokens = Convert.FromBase64String(cachedTokensText); Deserialize(cachedTokens); } } - // Notification raised before ADAL accesses the cache. - // This is your chance to update the in-memory copy from the DB, if the in-memory version is stale - private void BeforeAccessNotification(TokenCacheNotificationArgs args) + private void BeforeAccessNotificationWithContext(TokenCacheNotificationArgs args) { + // Retrieve the auth session with the cached tokens + var authenticateContext = new AuthenticateContext(_signInScheme); + _httpContext.Authentication.AuthenticateAsync(authenticateContext).Wait(); + _authProperties = new AuthenticationProperties(authenticateContext.Properties); + _principal = authenticateContext.Principal; + BeforeAccessNotificationWithProperties(args); } - // Notification raised after ADAL accessed the cache. - // If the HasStateChanged flag is set, ADAL changed the content of the cache - private void AfterAccessNotification(TokenCacheNotificationArgs args) + private void AfterAccessNotificationWithProperties(TokenCacheNotificationArgs args) { // if state changed if (HasStateChanged) { - HasCacheChanged = true; var cachedTokens = Serialize(); var cachedTokensText = Convert.ToBase64String(cachedTokens); _authProperties.Items[TokenCacheKey] = cachedTokensText; } } + private void AfterAccessNotificationWithContext(TokenCacheNotificationArgs args) + { + // if state changed + if (HasStateChanged) + { + AfterAccessNotificationWithProperties(args); + + var cachedTokens = Serialize(); + var cachedTokensText = Convert.ToBase64String(cachedTokens); + _authProperties.Items[TokenCacheKey] = cachedTokensText; + _httpContext.Authentication.SignInAsync(_signInScheme, _principal, _authProperties).Wait(); + } + } + private void BeforeWriteNotification(TokenCacheNotificationArgs args) { // if you want to ensure that no concurrent write take place, use this notification to place a lock on the entry diff --git a/samples/OpenIdConnect.AzureAdSample/Program.cs b/samples/OpenIdConnect.AzureAdSample/Program.cs index 5dcda4c86a..254668022d 100644 --- a/samples/OpenIdConnect.AzureAdSample/Program.cs +++ b/samples/OpenIdConnect.AzureAdSample/Program.cs @@ -8,11 +8,8 @@ namespace OpenIdConnect.AzureAdSample { public static void Main(string[] args) { - var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); - var host = new WebHostBuilder() .UseKestrel() - .UseConfiguration(config) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json index 2ae08a6cc9..62dc4ef778 100644 --- a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json +++ b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json @@ -21,7 +21,7 @@ "launchUrl": "http://localhost:42023", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_SERVER.URLS": "http://localhost:42023" + "ASPNETCORE_URLS": "http://localhost:42023" } } } diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index f4d0c37aaa..37a49b7ab2 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -89,12 +89,12 @@ namespace OpenIdConnect.AzureAdSample var request = context.HttpContext.Request; var currentUri = UriHelper.Encode(request.Scheme, request.Host, request.PathBase, request.Path); var credential = new ClientCredential(clientId, clientSecret); - var authContext = new AuthenticationContext(authority, new AuthPropertiesTokenCache(context.Properties)); + var authContext = new AuthenticationContext(authority, AuthPropertiesTokenCache.ForCodeRedemption(context.Properties)); var result = await authContext.AcquireTokenByAuthorizationCodeAsync( context.ProtocolMessage.Code, new Uri(currentUri), credential, resource); - context.HandleCodeRedemption(result.AccessToken, result.IdToken); + context.HandleCodeRedemption(); } } }); @@ -128,23 +128,11 @@ namespace OpenIdConnect.AzureAdSample await context.Response.WriteAsync("Tokens:
" + Environment.NewLine); try { - // Retrieve the auth session with the cached tokens - var authenticateContext = new AuthenticateContext(CookieAuthenticationDefaults.AuthenticationScheme); - await context.Authentication.AuthenticateAsync(authenticateContext); - var authProperties = new AuthenticationProperties(authenticateContext.Properties); - var tokenCache = new AuthPropertiesTokenCache(authProperties); - // Use ADAL to get the right token - var authContext = new AuthenticationContext(authority, tokenCache); + var authContext = new AuthenticationContext(authority, AuthPropertiesTokenCache.ForApiCalls(context, CookieAuthenticationDefaults.AuthenticationScheme)); var credential = new ClientCredential(clientId, clientSecret); string userObjectID = context.User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; - var result = authContext.AcquireTokenSilent(resource, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId)); - - // Update the cookie with the modified tokens - if (tokenCache.HasCacheChanged) - { - await context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, authenticateContext.Principal, authProperties); - } + var result = await authContext.AcquireTokenSilentAsync(resource, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId)); await context.Response.WriteAsync($"access_token: {result.AccessToken}
{Environment.NewLine}"); } diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 40308478b9..04cc2d01e4 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -5,13 +5,24 @@ "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", - "Microsoft.IdentityModel.Clients.ActiveDirectory": "2.22.302111727", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" + "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.9.302261508-alpha" }, "frameworks": { - "net451": {} + "net451": { }, + "netcoreapp1.0": { + "imports": [ + "dnxcore50" + ], + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } + } + } }, "buildOptions": { "emitEntryPoint": true From 00990448bfd77a6ef119dc0096571b9be566fa8d Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 27 May 2016 15:04:05 -0700 Subject: [PATCH 545/900] Sample config cleanup. --- samples/CookieSample/Program.cs | 3 --- samples/CookieSample/Properties/launchSettings.json | 2 +- samples/CookieSessionSample/Program.cs | 3 --- samples/CookieSessionSample/Properties/launchSettings.json | 2 +- samples/JwtBearerSample/Program.cs | 3 --- samples/JwtBearerSample/Properties/launchSettings.json | 2 +- samples/SocialSample/Properties/launchSettings.json | 2 +- 7 files changed, 4 insertions(+), 13 deletions(-) diff --git a/samples/CookieSample/Program.cs b/samples/CookieSample/Program.cs index cd8aab3aee..df74352e7c 100644 --- a/samples/CookieSample/Program.cs +++ b/samples/CookieSample/Program.cs @@ -8,11 +8,8 @@ namespace CookieSample { public static void Main(string[] args) { - var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); - var host = new WebHostBuilder() .UseKestrel() - .UseConfiguration(config) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/samples/CookieSample/Properties/launchSettings.json b/samples/CookieSample/Properties/launchSettings.json index 75da70bee0..afe862f4f4 100644 --- a/samples/CookieSample/Properties/launchSettings.json +++ b/samples/CookieSample/Properties/launchSettings.json @@ -21,7 +21,7 @@ "launchUrl": "http://localhost:12345", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_SERVER.URLS": "http://localhost:12345" + "ASPNETCORE_URLS": "http://localhost:12345" } } } diff --git a/samples/CookieSessionSample/Program.cs b/samples/CookieSessionSample/Program.cs index 6b9014f5e9..adf8f1f1a4 100644 --- a/samples/CookieSessionSample/Program.cs +++ b/samples/CookieSessionSample/Program.cs @@ -8,11 +8,8 @@ namespace CookieSessionSample { public static void Main(string[] args) { - var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); - var host = new WebHostBuilder() .UseKestrel() - .UseConfiguration(config) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/samples/CookieSessionSample/Properties/launchSettings.json b/samples/CookieSessionSample/Properties/launchSettings.json index 15b478a0ed..edb6e4dd19 100644 --- a/samples/CookieSessionSample/Properties/launchSettings.json +++ b/samples/CookieSessionSample/Properties/launchSettings.json @@ -21,7 +21,7 @@ "launchUrl": "http://localhost:12345", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_SERVER.URLS": "http://localhost:12345" + "ASPNETCORE_URLS": "http://localhost:12345" } } } diff --git a/samples/JwtBearerSample/Program.cs b/samples/JwtBearerSample/Program.cs index 82da93d591..44d2fe0c4f 100644 --- a/samples/JwtBearerSample/Program.cs +++ b/samples/JwtBearerSample/Program.cs @@ -8,11 +8,8 @@ namespace JwtBearerSample { public static void Main(string[] args) { - var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build(); - var host = new WebHostBuilder() .UseKestrel() - .UseConfiguration(config) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/samples/JwtBearerSample/Properties/launchSettings.json b/samples/JwtBearerSample/Properties/launchSettings.json index f5dfcd0181..e89788c48f 100644 --- a/samples/JwtBearerSample/Properties/launchSettings.json +++ b/samples/JwtBearerSample/Properties/launchSettings.json @@ -21,7 +21,7 @@ "launchUrl": "http://localhost:42023", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_SERVER.URLS": "http://localhost:42023" + "ASPNETCORE_URLS": "http://localhost:42023" } } } diff --git a/samples/SocialSample/Properties/launchSettings.json b/samples/SocialSample/Properties/launchSettings.json index 9224a4881c..251bfbffd4 100644 --- a/samples/SocialSample/Properties/launchSettings.json +++ b/samples/SocialSample/Properties/launchSettings.json @@ -22,7 +22,7 @@ "launchUrl": "https://localhost:44318/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_SERVER.URLS": "https://localhost:44318/" + "ASPNETCORE_URLS": "https://localhost:44318/" } } } From 080447e9aafa38a587d5672a76d563937b4e0a1e Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 27 May 2016 15:29:40 -0700 Subject: [PATCH 546/900] #780 Remove obsolete DateTime conversions --- .../CookieAuthenticationHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 3a8365a5b3..eecd03065a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -192,7 +192,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var cookieOptions = BuildCookieOptions(); if (ticket.Properties.IsPersistent && _refreshExpiresUtc.HasValue) { - cookieOptions.Expires = _refreshExpiresUtc.Value.ToUniversalTime().DateTime; + cookieOptions.Expires = _refreshExpiresUtc.Value.ToUniversalTime(); } Options.CookieManager.AppendResponseCookie( @@ -240,7 +240,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (signInContext.Properties.IsPersistent) { var expiresUtc = signInContext.Properties.ExpiresUtc ?? issuedUtc.Add(Options.ExpireTimeSpan); - signInContext.CookieOptions.Expires = expiresUtc.ToUniversalTime().DateTime; + signInContext.CookieOptions.Expires = expiresUtc.ToUniversalTime(); } var ticket = new AuthenticationTicket(signInContext.Principal, signInContext.Properties, signInContext.AuthenticationScheme); From c257c9528f16db78a33eed810b9a66f796146b3c Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 31 May 2016 13:45:30 -0700 Subject: [PATCH 547/900] AuthZ: Combine needs to use policy provider Fixes https://github.com/aspnet/Security/issues/841 --- .../AuthorizationPolicy.cs | 18 +++++----- .../DefaultAuthorizationPolicyProvider.cs | 7 +++- .../IAuthorizationPolicyProvider.cs | 6 ++++ .../AuthorizationPolicyFacts.cs | 36 ++++++++++++------- .../DefaultAuthorizationServiceTests.cs | 18 ++++++++-- 5 files changed, 61 insertions(+), 24 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs index 97aa5b381b..171fe014d6 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization { @@ -57,27 +58,27 @@ namespace Microsoft.AspNetCore.Authorization return builder.Build(); } - public static AuthorizationPolicy Combine(AuthorizationOptions options, IEnumerable attributes) + public static async Task CombineAsync(IAuthorizationPolicyProvider policyProvider, IEnumerable authorizeData) { - if (options == null) + if (policyProvider == null) { - throw new ArgumentNullException(nameof(options)); + throw new ArgumentNullException(nameof(policyProvider)); } - if (attributes == null) + if (authorizeData == null) { - throw new ArgumentNullException(nameof(attributes)); + throw new ArgumentNullException(nameof(authorizeData)); } var policyBuilder = new AuthorizationPolicyBuilder(); var any = false; - foreach (var authorizeAttribute in attributes.OfType()) + foreach (var authorizeAttribute in authorizeData.OfType()) { any = true; var useDefaultPolicy = true; if (!string.IsNullOrWhiteSpace(authorizeAttribute.Policy)) { - var policy = options.GetPolicy(authorizeAttribute.Policy); + var policy = await policyProvider.GetPolicyAsync(authorizeAttribute.Policy); if (policy == null) { throw new InvalidOperationException(Resources.FormatException_AuthorizationPolicyNotFound(authorizeAttribute.Policy)); @@ -89,7 +90,6 @@ namespace Microsoft.AspNetCore.Authorization if (rolesSplit != null && rolesSplit.Any()) { var trimmedRolesSplit = rolesSplit.Where(r => !string.IsNullOrWhiteSpace(r)).Select(r => r.Trim()); - policyBuilder.RequireRole(trimmedRolesSplit); useDefaultPolicy = false; } @@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.Authorization } if (useDefaultPolicy) { - policyBuilder.Combine(options.DefaultPolicy); + policyBuilder.Combine(await policyProvider.GetDefaultPolicyAsync()); } } return any ? policyBuilder.Build() : null; diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs index 97b806e87d..e053e41f95 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -22,7 +22,12 @@ namespace Microsoft.AspNetCore.Authorization } _options = options.Value; - } + } + + public Task GetDefaultPolicyAsync() + { + return Task.FromResult(_options.DefaultPolicy); + } /// /// Gets a from the given diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs index 1a0dbace60..ac141b327d 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs @@ -16,5 +16,11 @@ namespace Microsoft.AspNetCore.Authorization /// /// Task GetPolicyAsync(string policyName); + + /// + /// Returns the default . + /// + /// + Task GetDefaultPolicyAsync(); } } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs index f74e461523..6825dd868b 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -3,8 +3,10 @@ using System; using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization.Infrastructure; +using Microsoft.Extensions.Options; using Xunit; namespace Microsoft.AspNetCore.Authroization.Test @@ -18,7 +20,7 @@ namespace Microsoft.AspNetCore.Authroization.Test } [Fact] - public void CanCombineAuthorizeAttributes() + public async Task CanCombineAuthorizeAttributes() { // Arrange var attributes = new AuthorizeAttribute[] { @@ -31,8 +33,10 @@ namespace Microsoft.AspNetCore.Authroization.Test options.AddPolicy("1", policy => policy.RequireClaim("1")); options.AddPolicy("2", policy => policy.RequireClaim("2")); + var provider = new DefaultAuthorizationPolicyProvider(Options.Create(options)); + // Act - var combined = AuthorizationPolicy.Combine(options, attributes); + var combined = await AuthorizationPolicy.CombineAsync(provider, attributes); // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); @@ -45,7 +49,7 @@ namespace Microsoft.AspNetCore.Authroization.Test } [Fact] - public void CanReplaceDefaultPolicy() + public async Task CanReplaceDefaultPolicy() { // Arrange var attributes = new AuthorizeAttribute[] { @@ -56,8 +60,10 @@ namespace Microsoft.AspNetCore.Authroization.Test options.DefaultPolicy = new AuthorizationPolicyBuilder("default").RequireClaim("default").Build(); options.AddPolicy("2", policy => policy.RequireClaim("2")); + var provider = new DefaultAuthorizationPolicyProvider(Options.Create(options)); + // Act - var combined = AuthorizationPolicy.Combine(options, attributes); + var combined = await AuthorizationPolicy.CombineAsync(provider, attributes); // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); @@ -69,16 +75,17 @@ namespace Microsoft.AspNetCore.Authroization.Test } [Fact] - public void CombineMustTrimRoles() + public async Task CombineMustTrimRoles() { // Arrange var attributes = new AuthorizeAttribute[] { new AuthorizeAttribute() { Roles = "r1 , r2" } }; var options = new AuthorizationOptions(); + var provider = new DefaultAuthorizationPolicyProvider(Options.Create(options)); // Act - var combined = AuthorizationPolicy.Combine(options, attributes); + var combined = await AuthorizationPolicy.CombineAsync(provider, attributes); // Assert Assert.True(combined.Requirements.Any(r => r is RolesAuthorizationRequirement)); @@ -89,7 +96,7 @@ namespace Microsoft.AspNetCore.Authroization.Test } [Fact] - public void CombineMustTrimAuthenticationScheme() + public async Task CombineMustTrimAuthenticationScheme() { // Arrange var attributes = new AuthorizeAttribute[] { @@ -97,8 +104,10 @@ namespace Microsoft.AspNetCore.Authroization.Test }; var options = new AuthorizationOptions(); + var provider = new DefaultAuthorizationPolicyProvider(Options.Create(options)); + // Act - var combined = AuthorizationPolicy.Combine(options, attributes); + var combined = await AuthorizationPolicy.CombineAsync(provider, attributes); // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); @@ -107,7 +116,7 @@ namespace Microsoft.AspNetCore.Authroization.Test } [Fact] - public void CombineMustIgnoreEmptyAuthenticationScheme() + public async Task CombineMustIgnoreEmptyAuthenticationScheme() { // Arrange var attributes = new AuthorizeAttribute[] { @@ -115,8 +124,10 @@ namespace Microsoft.AspNetCore.Authroization.Test }; var options = new AuthorizationOptions(); + var provider = new DefaultAuthorizationPolicyProvider(Options.Create(options)); + // Act - var combined = AuthorizationPolicy.Combine(options, attributes); + var combined = await AuthorizationPolicy.CombineAsync(provider, attributes); // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); @@ -125,16 +136,17 @@ namespace Microsoft.AspNetCore.Authroization.Test } [Fact] - public void CombineMustIgnoreEmptyRoles() + public async Task CombineMustIgnoreEmptyRoles() { // Arrange var attributes = new AuthorizeAttribute[] { new AuthorizeAttribute() { Roles = "r1 , ,, , r2" } }; var options = new AuthorizationOptions(); + var provider = new DefaultAuthorizationPolicyProvider(Options.Create(options)); // Act - var combined = AuthorizationPolicy.Combine(options, attributes); + var combined = await AuthorizationPolicy.CombineAsync(provider, attributes); // Assert Assert.True(combined.Requirements.Any(r => r is RolesAuthorizationRequirement)); diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 42948c936f..b6383ffb48 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -8,6 +8,7 @@ using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization.Infrastructure; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Xunit; namespace Microsoft.AspNetCore.Authorization.Test @@ -28,9 +29,12 @@ namespace Microsoft.AspNetCore.Authorization.Test } [Fact] - public void AuthorizeCombineThrowsOnUnknownPolicy() + public async Task AuthorizeCombineThrowsOnUnknownPolicy() { - Assert.Throws(() => AuthorizationPolicy.Combine(new AuthorizationOptions(), new AuthorizeAttribute[] { + var provider = new DefaultAuthorizationPolicyProvider(Options.Create(new AuthorizationOptions())); + + // Act + await Assert.ThrowsAsync(() => AuthorizationPolicy.CombineAsync(provider, new AuthorizeAttribute[] { new AuthorizeAttribute { Policy = "Wut" } })); } @@ -944,6 +948,11 @@ namespace Microsoft.AspNetCore.Authorization.Test public class StaticPolicyProvider : IAuthorizationPolicyProvider { + public Task GetDefaultPolicyAsync() + { + return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); + } + public Task GetPolicyAsync(string policyName) { return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); @@ -973,6 +982,11 @@ namespace Microsoft.AspNetCore.Authorization.Test public class DynamicPolicyProvider : IAuthorizationPolicyProvider { + public Task GetDefaultPolicyAsync() + { + return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); + } + public Task GetPolicyAsync(string policyName) { return Task.FromResult(new AuthorizationPolicyBuilder().RequireClaim(policyName).Build()); From c9f8455dbc94162abce5687e8c7f95c6b59e6d3c Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 31 May 2016 15:56:43 -0700 Subject: [PATCH 548/900] Update sample ADAL dependency --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- samples/OpenIdConnect.AzureAdSample/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 37a49b7ab2..2fc8ac19b2 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -45,7 +45,7 @@ namespace OpenIdConnect.AzureAdSample public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { - loggerfactory.AddConsole(LogLevel.Information); + loggerfactory.AddConsole(Microsoft.Extensions.Logging.LogLevel.Information); // Simple error page app.Use(async (context, next) => diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 04cc2d01e4..7727c0ba31 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -8,7 +8,7 @@ "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", - "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.9.302261508-alpha" + "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.11.305310302-alpha" }, "frameworks": { "net451": { }, From e299695974a5632d58d032c2f534dfe4daf44551 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 1 Jun 2016 07:10:16 -0700 Subject: [PATCH 549/900] #776 Show some JwtBearer errors in response headers --- .../Events/JwtBearerChallengeContext.cs | 6 ++ .../JwtBearerHandler.cs | 96 +++++++++++++++++- .../OpenIdConnectHandler.cs | 2 +- .../JwtBearer/JwtBearerMiddlewareTests.cs | 98 ++++++++++++++----- 4 files changed, 171 insertions(+), 31 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs index b3a4d21ba6..b4dcf1147b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.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 Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; @@ -16,5 +17,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } public AuthenticationProperties Properties { get; } + + /// + /// Any failures encountered during the authentication process. + /// + public Exception AuthenticateFailure { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 40a0b2efd7..077f1debdb 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; +using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; @@ -103,7 +104,8 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Logger.TokenValidationFailed(token, ex); // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the event. - if (Options.RefreshOnIssuerKeyNotFound && ex.GetType().Equals(typeof(SecurityTokenSignatureKeyNotFoundException))) + if (Options.RefreshOnIssuerKeyNotFound && Options.ConfigurationManager != null + && ex is SecurityTokenSignatureKeyNotFoundException) { Options.ConfigurationManager.RequestRefresh(); } @@ -183,7 +185,12 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { - var eventContext = new JwtBearerChallengeContext(Context, Options, new AuthenticationProperties(context.Properties)); + var authResult = await HandleAuthenticateOnceAsync(); + + var eventContext = new JwtBearerChallengeContext(Context, Options, new AuthenticationProperties(context.Properties)) + { + AuthenticateFailure = authResult?.Failure, + }; await Options.Events.Challenge(eventContext); if (eventContext.HandledResponse) { @@ -195,11 +202,94 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } Response.StatusCode = 401; - Response.Headers.Append(HeaderNames.WWWAuthenticate, Options.Challenge); + + var errorDescription = CreateErrorDescription(eventContext.AuthenticateFailure); + + if (errorDescription.Length == 0) + { + Response.Headers.Append(HeaderNames.WWWAuthenticate, Options.Challenge); + } + else + { + // https://tools.ietf.org/html/rfc6750#section-3.1 + // WWW-Authenticate: Bearer realm="example", error="invalid_token", error_description="The access token expired" + var builder = new StringBuilder(Options.Challenge); + if (Options.Challenge.IndexOf(" ", StringComparison.Ordinal) > 0) + { + // Only add a comma after the first param, if any + builder.Append(','); + } + builder.Append(" error=\"invalid_token\", error_description=\""); + builder.Append(errorDescription); + builder.Append('\"'); + + Response.Headers.Append(HeaderNames.WWWAuthenticate, builder.ToString()); + } return false; } + private static string CreateErrorDescription(Exception authFailure) + { + if (authFailure == null) + { + return string.Empty; + } + + IEnumerable exceptions; + if (authFailure is AggregateException) + { + var agEx = authFailure as AggregateException; + exceptions = agEx.InnerExceptions; + } + else + { + exceptions = new[] { authFailure }; + } + + var messages = new List(); + + foreach (var ex in exceptions) + { + // Order sensitive, some of these exceptions derive from others + // and we want to display the most specific message possible. + if (ex is SecurityTokenInvalidAudienceException) + { + messages.Add("The audience is invalid"); + } + else if (ex is SecurityTokenInvalidIssuerException) + { + messages.Add("The issuer is invalid"); + } + else if (ex is SecurityTokenNoExpirationException) + { + messages.Add("The token has no expiration"); + } + else if (ex is SecurityTokenInvalidLifetimeException) + { + messages.Add("The token lifetime is invalid"); + } + else if (ex is SecurityTokenNotYetValidException) + { + messages.Add("The token is not valid yet"); + } + else if (ex is SecurityTokenExpiredException) + { + messages.Add("The token is expired"); + } + else if (ex is SecurityTokenSignatureKeyNotFoundException) + { + messages.Add("The signature key was not found"); + } + else if (ex is SecurityTokenInvalidSignatureException) + { + messages.Add("The signature is invalid"); + } + } + + return string.Join("; ", messages); + } + protected override Task HandleSignOutAsync(SignOutContext context) { throw new NotSupportedException(); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index e23173ed18..c674e21077 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -575,7 +575,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Logger.ExceptionProcessingMessage(exception); // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the event. - if (Options.RefreshOnIssuerKeyNotFound && exception.GetType().Equals(typeof(SecurityTokenSignatureKeyNotFoundException))) + if (Options.RefreshOnIssuerKeyNotFound && exception is SecurityTokenSignatureKeyNotFoundException) { if (Options.ConfigurationManager != null) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 81c03dc83a..5a10ef616f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -2,9 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; +using System.Linq; using System.Net; using System.Net.Http; +using System.Reflection; using System.Security.Claims; using System.Threading.Tasks; using System.Xml.Linq; @@ -30,7 +31,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { var options = new JwtBearerOptions { - AutomaticAuthenticate = true, Authority = "https://login.windows.net/tushartest.onmicrosoft.com", Audience = "https://TusharTest.onmicrosoft.com/TodoListService-ManualJwt" }; @@ -45,10 +45,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task SignInThrows() { - var server = CreateServer(new JwtBearerOptions - { - AutomaticAuthenticate = true - }); + var server = CreateServer(new JwtBearerOptions()); var transaction = await server.SendAsync("https://example.com/signIn"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } @@ -56,10 +53,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task SignOutThrows() { - var server = CreateServer(new JwtBearerOptions - { - AutomaticAuthenticate = true - }); + var server = CreateServer(new JwtBearerOptions()); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } @@ -70,7 +64,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { var server = CreateServer(new JwtBearerOptions { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnMessageReceived = context => @@ -117,10 +110,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task UnrecognizedTokenReceived() { - var server = CreateServer(new JwtBearerOptions - { - AutomaticAuthenticate = true - }); + var server = CreateServer(new JwtBearerOptions()); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); @@ -130,16 +120,67 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task InvalidTokenReceived() { - var options = new JwtBearerOptions - { - AutomaticAuthenticate = true - }; + var options = new JwtBearerOptions(); options.SecurityTokenValidators.Clear(); options.SecurityTokenValidators.Add(new InvalidTokenValidator()); var server = CreateServer(options); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); + Assert.Equal("Bearer", response.Response.Headers.WwwAuthenticate.First().ToString()); + Assert.Equal("", response.ResponseText); + } + + [Theory] + [InlineData(typeof(SecurityTokenInvalidAudienceException), "The audience is invalid")] + [InlineData(typeof(SecurityTokenInvalidIssuerException), "The issuer is invalid")] + [InlineData(typeof(SecurityTokenNoExpirationException), "The token has no expiration")] + [InlineData(typeof(SecurityTokenInvalidLifetimeException), "The token lifetime is invalid")] + [InlineData(typeof(SecurityTokenNotYetValidException), "The token is not valid yet")] + [InlineData(typeof(SecurityTokenExpiredException), "The token is expired")] + [InlineData(typeof(SecurityTokenInvalidSignatureException), "The signature is invalid")] + [InlineData(typeof(SecurityTokenSignatureKeyNotFoundException), "The signature key was not found")] + public async Task ExceptionReportedInHeaderForAuthenticationFailures(Type errorType, string message) + { + var options = new JwtBearerOptions(); + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new InvalidTokenValidator(errorType)); + var server = CreateServer(options); + + var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); + Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); + Assert.Equal($"Bearer error=\"invalid_token\", error_description=\"{message}\"", response.Response.Headers.WwwAuthenticate.First().ToString()); + Assert.Equal("", response.ResponseText); + } + + [Theory] + [InlineData(typeof(ArgumentException))] + public async Task ExceptionNotReportedInHeaderForOtherFailures(Type errorType) + { + var options = new JwtBearerOptions(); + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new InvalidTokenValidator(errorType)); + var server = CreateServer(options); + + var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); + Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); + Assert.Equal("Bearer", response.Response.Headers.WwwAuthenticate.First().ToString()); + Assert.Equal("", response.ResponseText); + } + + [Fact] + public async Task ExceptionsReportedInHeaderForMultipleAuthenticationFailures() + { + var options = new JwtBearerOptions(); + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new InvalidTokenValidator(typeof(SecurityTokenInvalidAudienceException))); + options.SecurityTokenValidators.Add(new InvalidTokenValidator(typeof(SecurityTokenSignatureKeyNotFoundException))); + var server = CreateServer(options); + + var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); + Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); + Assert.Equal($"Bearer error=\"invalid_token\", error_description=\"The audience is invalid; The signature key was not found\"", + response.Response.Headers.WwwAuthenticate.First().ToString()); Assert.Equal("", response.ResponseText); } @@ -148,7 +189,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { var options = new JwtBearerOptions { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnTokenValidated = context => @@ -185,7 +225,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { var options = new JwtBearerOptions() { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnMessageReceived = context => @@ -233,7 +272,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { var server = CreateServer(new JwtBearerOptions { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnMessageReceived = context => @@ -266,7 +304,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { var options = new JwtBearerOptions { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnTokenValidated = context => @@ -298,7 +335,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { var options = new JwtBearerOptions { - AutomaticAuthenticate = true, Events = new JwtBearerEvents() { OnTokenValidated = context => @@ -330,8 +366,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { var server = CreateServer(new JwtBearerOptions { - AutomaticAuthenticate = true, - AutomaticChallenge = true, Events = new JwtBearerEvents() { OnChallenge = context => @@ -352,8 +386,16 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { public InvalidTokenValidator() { + ExceptionType = typeof(SecurityTokenException); } + public InvalidTokenValidator(Type exceptionType) + { + ExceptionType = exceptionType; + } + + public Type ExceptionType { get; set; } + public bool CanValidateToken => true; public int MaximumTokenSizeInBytes @@ -366,7 +408,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParameters validationParameters, out SecurityToken validatedToken) { - throw new SecurityTokenException("InvalidToken"); + var constructor = ExceptionType.GetTypeInfo().GetConstructor(new[] { typeof(string) }); + var exception = (Exception)constructor.Invoke(new[] { ExceptionType.Name }); + throw exception; } } From 56dca7e0bc2e65b21b68cf67720a1a1d48ee9dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Tue, 31 May 2016 02:05:48 +0200 Subject: [PATCH 550/900] Add a 'sid' check to the OIDC middleware to prevent unsolicited logout when possible --- samples/OpenIdConnectSample/Startup.cs | 4 +- samples/OpenIdConnectSample/project.json | 1 + .../Events/RemoteSignoutContext.cs | 7 +- .../LoggingExtensions.cs | 22 +++++ .../OpenIdConnectHandler.cs | 89 ++++++++++++++----- .../OpenIdConnectMiddleware.cs | 4 + 6 files changed, 104 insertions(+), 23 deletions(-) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 6beaa0a20b..e9836506a3 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -42,6 +41,7 @@ namespace OpenIdConnectSample public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { loggerfactory.AddConsole(LogLevel.Information); + loggerfactory.AddDebug(LogLevel.Information); // Simple error page app.Use(async (context, next) => @@ -98,11 +98,11 @@ namespace OpenIdConnectSample if (context.Request.Path.Equals("/signout-remote")) { // Redirects + await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties() { RedirectUri = "/signedout" }); - await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); return; } if (context.Request.Path.Equals("/Account/AccessDenied")) diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 32e19ca40e..c507160fec 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -9,6 +9,7 @@ "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.Extensions.Logging.Debug": "1.0.0-*", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs index b5077e035d..a76dc9e592 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs @@ -3,14 +3,19 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class RemoteSignOutContext : BaseOpenIdConnectContext { - public RemoteSignOutContext(HttpContext context, OpenIdConnectOptions options) + public RemoteSignOutContext( + HttpContext context, + OpenIdConnectOptions options, + OpenIdConnectMessage message) : base(context, options) { + ProtocolMessage = message; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs index ef1d5d83b9..d0f3e12d90 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -50,6 +50,8 @@ namespace Microsoft.Extensions.Logging private static Action _remoteSignOutHandledResponse; private static Action _remoteSignOutSkipped; private static Action _remoteSignOut; + private static Action _remoteSignOutSessionIdMissing; + private static Action _remoteSignOutSessionIdInvalid; static LoggingExtensions() { @@ -226,6 +228,16 @@ namespace Microsoft.Extensions.Logging eventId: 46, logLevel: LogLevel.Information, formatString: "Remote signout request processed."); + _remoteSignOutSessionIdMissing = LoggerMessage.Define( + eventId: 47, + logLevel: LogLevel.Error, + formatString: "The remote signout request was ignored because the 'sid' parameter " + + "was missing, which may indicate an unsolicited logout."); + _remoteSignOutSessionIdInvalid = LoggerMessage.Define( + eventId: 48, + logLevel: LogLevel.Error, + formatString: "The remote signout request was ignored because the 'sid' parameter didn't match " + + "the expected value, which may indicate an unsolicited logout."); } public static void UpdatingConfiguration(this ILogger logger) @@ -442,5 +454,15 @@ namespace Microsoft.Extensions.Logging { _remoteSignOut(logger, null); } + + public static void RemoteSignOutSessionIdMissing(this ILogger logger) + { + _remoteSignOutSessionIdMissing(logger, null); + } + + public static void RemoteSignOutSessionIdInvalid(this ILogger logger) + { + _remoteSignOutSessionIdInvalid(logger, null); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index c674e21077..a10122b7af 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -66,29 +66,76 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { if (Options.RemoteSignOutPath.HasValue && Options.RemoteSignOutPath == Request.Path) { - var remoteSignOutContext = new RemoteSignOutContext(Context, Options); - await Options.Events.RemoteSignOut(remoteSignOutContext); - - if (remoteSignOutContext.HandledResponse) - { - Logger.RemoteSignOutHandledResponse(); - return true; - } - if (remoteSignOutContext.Skipped) - { - Logger.RemoteSignOutSkipped(); - return false; - } - - Logger.RemoteSignOut(); - - // We've received a remote sign-out request - await Context.Authentication.SignOutAsync(Options.SignOutScheme ?? Options.SignInScheme); - return true; + return await HandleRemoteSignOutAsync(); } return await base.HandleRequestAsync(); } + protected virtual async Task HandleRemoteSignOutAsync() + { + OpenIdConnectMessage message = null; + + if (string.Equals(Request.Method, "GET", StringComparison.OrdinalIgnoreCase)) + { + message = new OpenIdConnectMessage(Request.Query.Select(pair => new KeyValuePair(pair.Key, pair.Value))); + } + // assumption: if the ContentType is "application/x-www-form-urlencoded" it should be safe to read as it is small. + else if (string.Equals(Request.Method, "POST", StringComparison.OrdinalIgnoreCase) + && !string.IsNullOrEmpty(Request.ContentType) + // May have media/type; charset=utf-8, allow partial match. + && Request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase) + && Request.Body.CanRead) { + var form = await Request.ReadFormAsync(); + message = new OpenIdConnectMessage(form.Select(pair => new KeyValuePair(pair.Key, pair.Value))); + } + + var remoteSignOutContext = new RemoteSignOutContext(Context, Options, message); + await Options.Events.RemoteSignOut(remoteSignOutContext); + + if (remoteSignOutContext.HandledResponse) + { + Logger.RemoteSignOutHandledResponse(); + return true; + } + if (remoteSignOutContext.Skipped) + { + Logger.RemoteSignOutSkipped(); + return false; + } + + if (message == null) + { + return false; + } + + // Try to extract the session identifier from the authentication ticket persisted by the sign-in handler. + // If the identifier cannot be found, bypass the session identifier checks: this may indicate that the + // authentication cookie was already cleared, that the session identifier was lost because of a lossy + // external/application cookie conversion or that the identity provider doesn't support sessions. + var sid = (await Context.Authentication.AuthenticateAsync(Options.SignOutScheme))?.FindFirst("sid")?.Value; + if (!string.IsNullOrEmpty(sid)) + { + // Ensure a 'sid' parameter was sent by the identity provider. + if (string.IsNullOrEmpty(message.GetParameter("sid"))) + { + Logger.RemoteSignOutSessionIdMissing(); + return true; + } + // Ensure the 'sid' parameter corresponds to the 'sid' stored in the authentication ticket. + if (!string.Equals(sid, message.GetParameter("sid"), StringComparison.Ordinal)) + { + Logger.RemoteSignOutSessionIdInvalid(); + return true; + } + } + + Logger.RemoteSignOut(); + + // We've received a remote sign-out request + await Context.Authentication.SignOutAsync(Options.SignOutScheme); + return true; + } + /// /// Handles Signout /// @@ -132,7 +179,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect message.PostLogoutRedirectUri = logoutRedirectUri; } - message.IdTokenHint = await Context.Authentication.GetTokenAsync(OpenIdConnectParameterNames.IdToken); + // Attach the identity token to the logout request when possible. + message.IdTokenHint = await Context.Authentication.GetTokenAsync(Options.SignOutScheme, OpenIdConnectParameterNames.IdToken); + var redirectContext = new RedirectContext(Context, Options, properties) { ProtocolMessage = message diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs index b08f8e944c..8d880d0d90 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs @@ -100,6 +100,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { throw new ArgumentException("Options.SignInScheme is required."); } + if (string.IsNullOrEmpty(Options.SignOutScheme)) + { + Options.SignOutScheme = Options.SignInScheme; + } HtmlEncoder = htmlEncoder; From d289e82a852a0d52ecc100088f18d3f79d243fea Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 2 Jun 2016 15:06:17 -0700 Subject: [PATCH 551/900] Remove old Basic auth samples from ReadMe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f32798072d..ab822bd682 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Contains the security and authorization middlewares for ASP.NET Core. ### Notes -ASP.NET Security will not include Basic Authentication middleware due to its potential insecurity and performance problems. If you host under IIS you can enable it via IIS configuration. If you require Basic Authentication middleware for testing purposes, as a shared secret authentication mechanism for server to server communication, or to use a database as a user source then please look at the samples from [leastprivilege](https://github.com/leastprivilege/BasicAuthentication.AspNet5) or [Kukkimonsuta](https://github.com/Kukkimonsuta/Odachi/tree/master/src/Odachi.AspNetCore.Authentication.Basic). +ASP.NET Security will not include Basic Authentication middleware due to its potential insecurity and performance problems. If you host under IIS you can enable it via IIS configuration. This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo. From 35d0592701c4aa2edb6da919b629f87b8701807a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 3 Jun 2016 13:26:16 -0700 Subject: [PATCH 552/900] Make AuthorizationHandler async only --- .../AuthorizationHandler.cs | 70 +++++++++---------- .../IAuthorizationHandler.cs | 7 ++ .../ClaimsAuthorizationRequirement.cs | 4 +- .../DenyAnonymousAuthorizationRequirement.cs | 4 +- .../NameAuthorizationRequirement.cs | 4 +- .../RolesAuthorizationRequirement.cs | 4 +- .../DefaultAuthorizationServiceTests.cs | 17 +++-- 7 files changed, 64 insertions(+), 46 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs index f6877f114e..2eb19c6176 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs @@ -6,65 +6,63 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization { + /// + /// Base class for authorization handlers that need to be called for a specific requirement type. + /// + /// The type of the requirement to handle. public abstract class AuthorizationHandler : IAuthorizationHandler - where TRequirement : IAuthorizationRequirement + where TRequirement : IAuthorizationRequirement { - public void Handle(AuthorizationHandlerContext context) - { - foreach (var req in context.Requirements.OfType()) - { - Handle(context, req); - } - } - + /// + /// Makes a decision if authorization is allowed. + /// + /// The authorization information. public virtual async Task HandleAsync(AuthorizationHandlerContext context) { foreach (var req in context.Requirements.OfType()) { - await HandleAsync(context, req); + await HandleRequirementAsync(context, req); } } - protected abstract void Handle(AuthorizationHandlerContext context, TRequirement requirement); - - protected virtual Task HandleAsync(AuthorizationHandlerContext context, TRequirement requirement) - { - Handle(context, requirement); - return Task.FromResult(0); - } + /// + /// Makes a decision if authorization is allowed based on a specific requirement. + /// + /// The authorization information. + /// The requirement to evaluate. + protected abstract Task HandleRequirementAsync(AuthorizationHandlerContext context, TRequirement requirement); } + /// + /// Base class for authorization handlers that need to be called for specific requirement and + /// resource types. + /// + /// The type of the requirement to evaluate. + /// The type of the resource to evaluate. public abstract class AuthorizationHandler : IAuthorizationHandler where TRequirement : IAuthorizationRequirement { + /// + /// Makes a decision if authorization is allowed. + /// + /// The authorization information. public virtual async Task HandleAsync(AuthorizationHandlerContext context) { if (context.Resource is TResource) { foreach (var req in context.Requirements.OfType()) { - await HandleAsync(context, req, (TResource)context.Resource); + await HandleRequirementAsync(context, req, (TResource)context.Resource); } } } - protected virtual Task HandleAsync(AuthorizationHandlerContext context, TRequirement requirement, TResource resource) - { - Handle(context, requirement, resource); - return Task.FromResult(0); - } - - public virtual void Handle(AuthorizationHandlerContext context) - { - if (context.Resource is TResource) - { - foreach (var req in context.Requirements.OfType()) - { - Handle(context, req, (TResource)context.Resource); - } - } - } - - protected abstract void Handle(AuthorizationHandlerContext context, TRequirement requirement, TResource resource); + /// + /// Makes a decision if authorization is allowed based on a specific requirement and resource. + /// + /// The authorization information. + /// The requirement to evaluate. + /// The resource to evaluate. + protected abstract Task HandleRequirementAsync(AuthorizationHandlerContext context, TRequirement requirement, TResource resource); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs index cf7896a30e..afe9e43f02 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs @@ -5,8 +5,15 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization { + /// + /// Classes implementing this interface are able to make a decision if authorization is allowed. + /// public interface IAuthorizationHandler { + /// + /// Makes a decision if authorization is allowed. + /// + /// The authorization information. Task HandleAsync(AuthorizationHandlerContext context); } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs index 644b33086d..c5a06c2f95 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -25,7 +26,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure public string ClaimType { get; } public IEnumerable AllowedValues { get; } - protected override void Handle(AuthorizationHandlerContext context, ClaimsAuthorizationRequirement requirement) + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ClaimsAuthorizationRequirement requirement) { if (context.User != null) { @@ -44,6 +45,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure context.Succeed(requirement); } } + return Task.FromResult(0); } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs index 57ad22dff6..82d40639bc 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs @@ -2,12 +2,13 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Linq; +using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { public class DenyAnonymousAuthorizationRequirement : AuthorizationHandler, IAuthorizationRequirement { - protected override void Handle(AuthorizationHandlerContext context, DenyAnonymousAuthorizationRequirement requirement) + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, DenyAnonymousAuthorizationRequirement requirement) { var user = context.User; var userIsAnonymous = @@ -17,6 +18,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure { context.Succeed(requirement); } + return Task.FromResult(0); } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs index b0c4e6b101..3643b1fb7a 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -23,7 +24,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure public string RequiredName { get; } - protected override void Handle(AuthorizationHandlerContext context, NameAuthorizationRequirement requirement) + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, NameAuthorizationRequirement requirement) { if (context.User != null) { @@ -33,6 +34,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure context.Succeed(requirement); } } + return Task.FromResult(0); } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs index a57a0e4c8e..53d6beb167 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -27,7 +28,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure public IEnumerable AllowedRoles { get; } - protected override void Handle(AuthorizationHandlerContext context, RolesAuthorizationRequirement requirement) + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RolesAuthorizationRequirement requirement) { if (context.User != null) { @@ -45,6 +46,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure context.Succeed(requirement); } } + return Task.FromResult(0); } } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index b6383ffb48..19bd761e05 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -584,9 +584,10 @@ namespace Microsoft.AspNetCore.Authorization.Test public class CustomRequirement : IAuthorizationRequirement { } public class CustomHandler : AuthorizationHandler { - protected override void Handle(AuthorizationHandlerContext context, CustomRequirement requirement) + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, CustomRequirement requirement) { context.Succeed(requirement); + return Task.FromResult(0); } } @@ -640,11 +641,12 @@ namespace Microsoft.AspNetCore.Authorization.Test public bool Succeed { get; set; } - protected override void Handle(AuthorizationHandlerContext context, PassThroughRequirement requirement) + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, PassThroughRequirement requirement) { if (Succeed) { context.Succeed(requirement); } + return Task.FromResult(0); } } @@ -770,23 +772,25 @@ namespace Microsoft.AspNetCore.Authorization.Test private IEnumerable _allowed; - protected override void Handle(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement, ExpenseReport resource) + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement, ExpenseReport resource) { if (_allowed.Contains(requirement)) { context.Succeed(requirement); } + return Task.FromResult(0); } } public class SuperUserHandler : AuthorizationHandler { - protected override void Handle(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement) + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement) { if (context.User.HasClaim("SuperUser", "yes")) { context.Succeed(requirement); } + return Task.FromResult(0); } } @@ -816,7 +820,7 @@ namespace Microsoft.AspNetCore.Authorization.Test public class NotCalledHandler : AuthorizationHandler { - protected override void Handle(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement, string resource) + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement, string resource) { throw new NotImplementedException(); } @@ -824,12 +828,13 @@ namespace Microsoft.AspNetCore.Authorization.Test public class EvenHandler : AuthorizationHandler { - protected override void Handle(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement, int id) + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement, int id) { if (id % 2 == 0) { context.Succeed(requirement); } + return Task.FromResult(0); } } From 120021e8a33ddda13411ff3876a78040f75bec2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Thu, 2 Jun 2016 16:45:05 +0200 Subject: [PATCH 553/900] Add a new IncludeErrorDetails option to prevent the JWT middleware from returning error/error_description --- .../Events/JwtBearerChallengeContext.cs | 20 ++++ .../JwtBearerHandler.cs | 51 +++++++--- .../JwtBearerOptions.cs | 7 ++ .../JwtBearer/JwtBearerMiddlewareTests.cs | 96 ++++++++++++++++++- 4 files changed, 160 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs index b4dcf1147b..5846812538 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs @@ -22,5 +22,25 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// Any failures encountered during the authentication process. /// public Exception AuthenticateFailure { get; set; } + + /// + /// Gets or sets the "error" value returned to the caller as part + /// of the WWW-Authenticate header. This property may be null when + /// is set to false. + /// + public string Error { get; set; } + + /// + /// Gets or sets the "error_description" value returned to the caller as part + /// of the WWW-Authenticate header. This property may be null when + /// is set to false. + /// + public string ErrorDescription { get; set; } + + /// + /// Gets or sets the "error_uri" value returned to the caller as part of the + /// WWW-Authenticate header. This property is always null unless explicitly set. + /// + public string ErrorUri { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 077f1debdb..34b13562a5 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -191,6 +191,14 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { AuthenticateFailure = authResult?.Failure, }; + + // Avoid returning error=invalid_token if the error is not caused by an authentication failure (e.g missing token). + if (Options.IncludeErrorDetails && eventContext.AuthenticateFailure != null) + { + eventContext.Error = "invalid_token"; + eventContext.ErrorDescription = CreateErrorDescription(eventContext.AuthenticateFailure); + } + await Options.Events.Challenge(eventContext); if (eventContext.HandledResponse) { @@ -203,9 +211,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Response.StatusCode = 401; - var errorDescription = CreateErrorDescription(eventContext.AuthenticateFailure); - - if (errorDescription.Length == 0) + if (string.IsNullOrEmpty(eventContext.Error) && + string.IsNullOrEmpty(eventContext.ErrorDescription) && + string.IsNullOrEmpty(eventContext.ErrorUri)) { Response.Headers.Append(HeaderNames.WWWAuthenticate, Options.Challenge); } @@ -219,9 +227,35 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer // Only add a comma after the first param, if any builder.Append(','); } - builder.Append(" error=\"invalid_token\", error_description=\""); - builder.Append(errorDescription); - builder.Append('\"'); + if (!string.IsNullOrEmpty(eventContext.Error)) + { + builder.Append(" error=\""); + builder.Append(eventContext.Error); + builder.Append("\""); + } + if (!string.IsNullOrEmpty(eventContext.ErrorDescription)) + { + if (!string.IsNullOrEmpty(eventContext.Error)) + { + builder.Append(","); + } + + builder.Append(" error_description=\""); + builder.Append(eventContext.ErrorDescription); + builder.Append('\"'); + } + if (!string.IsNullOrEmpty(eventContext.ErrorUri)) + { + if (!string.IsNullOrEmpty(eventContext.Error) || + !string.IsNullOrEmpty(eventContext.ErrorDescription)) + { + builder.Append(","); + } + + builder.Append(" error_uri=\""); + builder.Append(eventContext.ErrorUri); + builder.Append('\"'); + } Response.Headers.Append(HeaderNames.WWWAuthenticate, builder.ToString()); } @@ -231,11 +265,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer private static string CreateErrorDescription(Exception authFailure) { - if (authFailure == null) - { - return string.Empty; - } - IEnumerable exceptions; if (authFailure is AggregateException) { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs index 837928e777..1d73b843ee 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -118,5 +118,12 @@ namespace Microsoft.AspNetCore.Builder /// after a successful authorization. /// public bool SaveToken { get; set; } = true; + + /// + /// Defines whether the token validation errors should be returned to the caller. + /// Enabled by default, this option can be disabled to prevent the JWT middleware + /// from returning an error and an error_description in the WWW-Authenticate header. + /// + public bool IncludeErrorDetails { get; set; } = true; } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index 5a10ef616f..b1f0ce4fed 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -7,6 +7,7 @@ using System.Net; using System.Net.Http; using System.Reflection; using System.Security.Claims; +using System.Text; using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.AspNetCore.Builder; @@ -127,7 +128,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); - Assert.Equal("Bearer", response.Response.Headers.WwwAuthenticate.First().ToString()); + Assert.Equal("Bearer error=\"invalid_token\"", response.Response.Headers.WwwAuthenticate.First().ToString()); Assert.Equal("", response.ResponseText); } @@ -164,7 +165,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); - Assert.Equal("Bearer", response.Response.Headers.WwwAuthenticate.First().ToString()); + Assert.Equal("Bearer error=\"invalid_token\"", response.Response.Headers.WwwAuthenticate.First().ToString()); Assert.Equal("", response.ResponseText); } @@ -179,11 +180,100 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); - Assert.Equal($"Bearer error=\"invalid_token\", error_description=\"The audience is invalid; The signature key was not found\"", + Assert.Equal("Bearer error=\"invalid_token\", error_description=\"The audience is invalid; The signature key was not found\"", response.Response.Headers.WwwAuthenticate.First().ToString()); Assert.Equal("", response.ResponseText); } + [Theory] + [InlineData("custom_error", "custom_description", "custom_uri")] + [InlineData("custom_error", "custom_description", null)] + [InlineData("custom_error", null, null)] + [InlineData(null, "custom_description", "custom_uri")] + [InlineData(null, "custom_description", null)] + [InlineData(null, null, "custom_uri")] + public async Task ExceptionsReportedInHeaderExposesUserDefinedError(string error, string description, string uri) + { + var options = new JwtBearerOptions + { + Events = new JwtBearerEvents + { + OnChallenge = context => + { + context.Error = error; + context.ErrorDescription = description; + context.ErrorUri = uri; + + return Task.FromResult(0); + } + } + }; + var server = CreateServer(options); + + var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); + Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); + Assert.Equal("", response.ResponseText); + + var builder = new StringBuilder(options.Challenge); + + if (!string.IsNullOrEmpty(error)) + { + builder.Append(" error=\""); + builder.Append(error); + builder.Append("\""); + } + if (!string.IsNullOrEmpty(description)) + { + if (!string.IsNullOrEmpty(error)) + { + builder.Append(","); + } + + builder.Append(" error_description=\""); + builder.Append(description); + builder.Append('\"'); + } + if (!string.IsNullOrEmpty(uri)) + { + if (!string.IsNullOrEmpty(error) || + !string.IsNullOrEmpty(description)) + { + builder.Append(","); + } + + builder.Append(" error_uri=\""); + builder.Append(uri); + builder.Append('\"'); + } + + Assert.Equal(builder.ToString(), response.Response.Headers.WwwAuthenticate.First().ToString()); + } + + [Fact] + public async Task ExceptionNotReportedInHeaderWhenIncludeErrorDetailsIsFalse() + { + var server = CreateServer(new JwtBearerOptions + { + IncludeErrorDetails = false + }); + + var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); + Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); + Assert.Equal("Bearer", response.Response.Headers.WwwAuthenticate.First().ToString()); + Assert.Equal("", response.ResponseText); + } + + [Fact] + public async Task ExceptionNotReportedInHeaderWhenTokenWasMissing() + { + var server = CreateServer(new JwtBearerOptions()); + + var response = await SendAsync(server, "http://example.com/oauth"); + Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); + Assert.Equal("Bearer", response.Response.Headers.WwwAuthenticate.First().ToString()); + Assert.Equal("", response.ResponseText); + } + [Fact] public async Task CustomTokenValidated() { From bffbfc7f9e6c40238467d84efd1da82dc5485026 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 3 Jun 2016 20:03:55 -0700 Subject: [PATCH 554/900] React to OpenId renames --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- samples/OpenIdConnectSample/Startup.cs | 2 +- .../OpenIdConnectHandler.cs | 4 ++-- .../OpenIdConnectOptions.cs | 8 ++++---- .../OpenIdConnect/ExpectedQueryValues.cs | 12 ++++++------ .../OpenIdConnect/OpenIdConnectMiddlewareTests.cs | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 2fc8ac19b2..40727ff1a3 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -80,7 +80,7 @@ namespace OpenIdConnect.AzureAdSample ClientId = clientId, ClientSecret = clientSecret, // for code flow Authority = authority, - ResponseType = OpenIdConnectResponseTypes.CodeIdToken, + ResponseType = OpenIdConnectResponseType.CodeIdToken, // GetClaimsFromUserInfoEndpoint = true, Events = new OpenIdConnectEvents() { diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index e9836506a3..3a39919032 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -72,7 +72,7 @@ namespace OpenIdConnectSample ClientId = Configuration["oidc:clientid"], ClientSecret = Configuration["oidc:clientsecret"], // for code flow Authority = Configuration["oidc:authority"], - ResponseType = OpenIdConnectResponseTypes.Code, + ResponseType = OpenIdConnectResponseType.Code, GetClaimsFromUserInfoEndpoint = true }); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index a10122b7af..4189ee262c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -286,8 +286,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // Omitting the response_mode parameter when it already corresponds to the default // response_mode used for the specified response_type is recommended by the specifications. // See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#ResponseModes - if (!string.Equals(Options.ResponseType, OpenIdConnectResponseTypes.Code, StringComparison.Ordinal) || - !string.Equals(Options.ResponseMode, OpenIdConnectResponseModes.Query, StringComparison.Ordinal)) + if (!string.Equals(Options.ResponseType, OpenIdConnectResponseType.Code, StringComparison.Ordinal) || + !string.Equals(Options.ResponseMode, OpenIdConnectResponseMode.Query, StringComparison.Ordinal)) { message.ResponseMode = Options.ResponseMode; } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index c9b614acde..b5f6c03daa 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -38,8 +38,8 @@ namespace Microsoft.AspNetCore.Builder /// Caption: . /// ProtocolValidator: new . /// RefreshOnIssuerKeyNotFound: true - /// ResponseType: - /// Scope: . + /// ResponseType: + /// Scope: . /// TokenValidationParameters: new with AuthenticationScheme = authenticationScheme. /// UseTokenLifetime: false. /// @@ -144,12 +144,12 @@ namespace Microsoft.AspNetCore.Builder /// /// Gets or sets the 'response_mode'. /// - public string ResponseMode { get; set; } = OpenIdConnectResponseModes.FormPost; + public string ResponseMode { get; set; } = OpenIdConnectResponseMode.FormPost; /// /// Gets or sets the 'response_type'. /// - public string ResponseType { get; set; } = OpenIdConnectResponseTypes.IdToken; + public string ResponseType { get; set; } = OpenIdConnectResponseType.IdToken; /// /// Gets the list of permissions to request. diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs index 66fc2f4bab..98df02ee61 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs @@ -25,8 +25,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public static ExpectedQueryValues Defaults(string authority) { var result = new ExpectedQueryValues(authority); - result.Scope = OpenIdConnectScopes.OpenIdProfile; - result.ResponseType = OpenIdConnectResponseTypes.CodeIdToken; + result.Scope = OpenIdConnectScope.OpenIdProfile; + result.ResponseType = OpenIdConnectResponseType.CodeIdToken; return result; } @@ -111,11 +111,11 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public string RedirectUri { get; set; } = Guid.NewGuid().ToString(); - public OpenIdConnectRequestType RequestType { get; set; } = OpenIdConnectRequestType.AuthenticationRequest; + public OpenIdConnectRequestType RequestType { get; set; } = OpenIdConnectRequestType.Authentication; public string Resource { get; set; } = Guid.NewGuid().ToString(); - public string ResponseMode { get; set; } = OpenIdConnectResponseModes.FormPost; + public string ResponseMode { get; set; } = OpenIdConnectResponseMode.FormPost; public string ResponseType { get; set; } = Guid.NewGuid().ToString(); @@ -127,11 +127,11 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { get { - if (RequestType == OpenIdConnectRequestType.TokenRequest) + if (RequestType == OpenIdConnectRequestType.Token) { return Configuration?.EndSessionEndpoint ?? Authority + @"/oauth2/token"; } - else if (RequestType == OpenIdConnectRequestType.LogoutRequest) + else if (RequestType == OpenIdConnectRequestType.Logout) { return Configuration?.TokenEndpoint ?? Authority + @"/oauth2/logout"; } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 20de135712..41154820b9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -113,7 +113,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var queryValues = new ExpectedQueryValues(DefaultAuthority, configuration) { - RequestType = OpenIdConnectRequestType.AuthenticationRequest + RequestType = OpenIdConnectRequestType.Authentication }; var server = CreateServer(GetProtocolMessageOptions()); var transaction = await SendAsync(server, DefaultHost + Challenge); @@ -135,7 +135,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var queryValues = new ExpectedQueryValues(DefaultAuthority, configuration) { - RequestType = OpenIdConnectRequestType.LogoutRequest + RequestType = OpenIdConnectRequestType.Logout }; var server = CreateServer(GetProtocolMessageOptions()); var transaction = await SendAsync(server, DefaultHost + Signout); From 33b69c14edda3d96bc489e74a8ecf8d98f55ef25 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 6 Jun 2016 15:15:02 -0700 Subject: [PATCH 555/900] React to UriHelper.Encode rename. --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 40727ff1a3..f27a524928 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -87,7 +87,7 @@ namespace OpenIdConnect.AzureAdSample OnAuthorizationCodeReceived = async context => { var request = context.HttpContext.Request; - var currentUri = UriHelper.Encode(request.Scheme, request.Host, request.PathBase, request.Path); + var currentUri = UriHelper.BuildAbsolute(request.Scheme, request.Host, request.PathBase, request.Path); var credential = new ClientCredential(clientId, clientSecret); var authContext = new AuthenticationContext(authority, AuthPropertiesTokenCache.ForCodeRedemption(context.Properties)); From 933b374f3ecdfc65cea13057b123fbfed015f114 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Fri, 3 Jun 2016 12:38:28 -0700 Subject: [PATCH 556/900] Update Json.NET to 9.0.1-beta1 --- src/Microsoft.AspNetCore.Authentication.OAuth/project.json | 2 +- src/Microsoft.AspNetCore.Authentication.Twitter/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index 613cadae3f..af3f17a99b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -22,7 +22,7 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", - "Newtonsoft.Json": "8.0.3" + "Newtonsoft.Json": "9.0.1-beta1" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 63464eab96..1789475252 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -22,7 +22,7 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", - "Newtonsoft.Json": "8.0.3" + "Newtonsoft.Json": "9.0.1-beta1" }, "frameworks": { "net451": {}, From e1495f5f3265dfd55611c514063910e0d73efa3c Mon Sep 17 00:00:00 2001 From: jacalvar Date: Tue, 7 Jun 2016 22:46:08 -0700 Subject: [PATCH 557/900] Remove unncessary usings --- samples/CookieSample/project.json | 8 +------- samples/CookieSessionSample/project.json | 8 +------- samples/JwtBearerSample/project.json | 8 +------- samples/OpenIdConnect.AzureAdSample/project.json | 8 +------- samples/OpenIdConnectSample/project.json | 8 +------- samples/SocialSample/project.json | 8 +------- .../project.json | 3 --- .../project.json | 3 --- .../project.json | 3 --- .../project.json | 3 --- .../project.json | 5 +---- .../project.json | 3 --- .../project.json | 3 --- src/Microsoft.AspNetCore.Authentication/project.json | 5 +---- 14 files changed, 8 insertions(+), 68 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 954c366434..aa38029d98 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -14,9 +14,6 @@ "frameworks": { "net451": {}, "netcoreapp1.0": { - "imports": [ - "dnxcore50" - ], "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0-*", @@ -31,10 +28,7 @@ ] }, "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": { - "version": "1.0.0-*", - "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" - } + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index a3626218c4..fb8d16c023 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -15,9 +15,6 @@ "frameworks": { "net451": {}, "netcoreapp1.0": { - "imports": [ - "dnxcore50" - ], "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0-*", @@ -32,10 +29,7 @@ ] }, "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": { - "version": "1.0.0-*", - "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" - } + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index a82778a76e..5bf0a928a9 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -15,9 +15,6 @@ "frameworks": { "net451": {}, "netcoreapp1.0": { - "imports": [ - "dnxcore50" - ], "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0-*", @@ -35,10 +32,7 @@ }, "userSecretsId": "aspnet5-JwtBearerSample-20151210102827", "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": { - "version": "1.0.0-*", - "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" - } + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 7727c0ba31..ff03a5584b 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -13,9 +13,6 @@ "frameworks": { "net451": { }, "netcoreapp1.0": { - "imports": [ - "dnxcore50" - ], "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0-*", @@ -35,10 +32,7 @@ }, "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318", "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": { - "version": "1.0.0-*", - "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" - } + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index c507160fec..7e0aa0e5f1 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -15,9 +15,6 @@ "frameworks": { "net451": {}, "netcoreapp1.0": { - "imports": [ - "dnxcore50" - ], "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0-*", @@ -37,10 +34,7 @@ }, "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318", "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": { - "version": "1.0.0-*", - "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" - } + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index fb19d3ec2a..98ff9263aa 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -21,9 +21,6 @@ "frameworks": { "net451": { }, "netcoreapp1.0": { - "imports": [ - "dnxcore50" - ], "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0-*", @@ -41,10 +38,7 @@ ] }, "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": { - "version": "1.0.0-*", - "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" - } + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 27b5f34eaf..35fedfada5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -26,9 +26,6 @@ "frameworks": { "net451": {}, "netstandard1.3": { - "imports": [ - "portable-net451+win8" - ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index 3051e5fa7d..37d91ba542 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -26,9 +26,6 @@ "frameworks": { "net451": {}, "netstandard1.3": { - "imports": [ - "portable-net451+win8" - ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index f0c04896ec..2863967e29 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -27,9 +27,6 @@ "frameworks": { "net451": {}, "netstandard1.4": { - "imports": [ - "portable-net451+win8" - ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index 3a7b5e03e5..81f34b7361 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -26,9 +26,6 @@ "frameworks": { "net451": {}, "netstandard1.3": { - "imports": [ - "portable-net451+win8" - ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index af3f17a99b..971a8d6960 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -29,10 +29,7 @@ "netstandard1.3": { "dependencies": { "System.Runtime.Serialization.Primitives": "4.1.1-*" - }, - "imports": [ - "portable-net451+win8" - ] + } } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 11d887e5c2..b80faf063f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -27,9 +27,6 @@ "frameworks": { "net451": {}, "netstandard1.4": { - "imports": [ - "portable-net451+win8" - ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 1789475252..7d830ad8c1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -27,9 +27,6 @@ "frameworks": { "net451": {}, "netstandard1.3": { - "imports": [ - "portable-net451+win8" - ] } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index e5107da8fc..dc56181a71 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -41,10 +41,7 @@ "netstandard1.3": { "dependencies": { "System.Net.Http": "4.1.0-*" - }, - "imports": [ - "portable-net451" - ] + } } } } \ No newline at end of file From 38e89d498da65ceb603b3b19e5c8fb64e2986ca4 Mon Sep 17 00:00:00 2001 From: Barry Dorrans Date: Thu, 9 Jun 2016 16:15:09 -0700 Subject: [PATCH 558/900] Doc Comments --- .../AuthorizationHandler.cs | 8 +- .../AuthorizationHandlerContext.cs | 35 ++++++ .../AuthorizationOptions.cs | 5 +- .../AuthorizationPolicy.cs | 50 ++++++++ .../AuthorizationPolicyBuilder.cs | 114 +++++++++++++++--- .../AuthorizationServiceExtensions.cs | 57 +++++---- .../AuthorizeAttribute.cs | 1 - .../DefaultAuthorizationPolicyProvider.cs | 15 ++- .../DefaultAuthorizationService.cs | 29 +++++ .../IAllowAnonymous.cs | 3 + .../IAuthorizationPolicyProvider.cs | 8 +- .../IAuthorizationRequirement.cs | 3 + .../IAuthorizationService.cs | 16 ++- .../IAuthorizeData.cs | 5 +- .../Infrastructure/AssertionRequirement.cs | 34 ++++-- .../ClaimsAuthorizationRequirement.cs | 26 +++- .../DenyAnonymousAuthorizationRequirement.cs | 9 ++ .../NameAuthorizationRequirement.cs | 16 ++- .../OperationAuthorizationRequirement.cs | 7 ++ .../PassThroughAuthorizationHandler.cs | 8 ++ .../RolesAuthorizationRequirement.cs | 19 ++- 21 files changed, 399 insertions(+), 69 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs index 2eb19c6176..a4a923c3c7 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Authorization /// /// Makes a decision if authorization is allowed. /// - /// The authorization information. + /// The authorization context. public virtual async Task HandleAsync(AuthorizationHandlerContext context) { foreach (var req in context.Requirements.OfType()) @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Authorization /// /// Makes a decision if authorization is allowed based on a specific requirement. /// - /// The authorization information. + /// The authorization context. /// The requirement to evaluate. protected abstract Task HandleRequirementAsync(AuthorizationHandlerContext context, TRequirement requirement); } @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Authorization /// /// Makes a decision if authorization is allowed. /// - /// The authorization information. + /// The authorization context. public virtual async Task HandleAsync(AuthorizationHandlerContext context) { if (context.Resource is TResource) @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Authorization /// /// Makes a decision if authorization is allowed based on a specific requirement and resource. /// - /// The authorization information. + /// The authorization context. /// The requirement to evaluate. /// The resource to evaluate. protected abstract Task HandleRequirementAsync(AuthorizationHandlerContext context, TRequirement requirement, TResource resource); diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs index 2349feb319..65aafa2bb6 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs @@ -17,6 +17,12 @@ namespace Microsoft.AspNetCore.Authorization private bool _failCalled; private bool _succeedCalled; + /// + /// Creates a new instance of . + /// + /// A collection of all the for the current authorization action. + /// A representing the current user. + /// An optional resource to evaluate the against. public AuthorizationHandlerContext( IEnumerable requirements, ClaimsPrincipal user, @@ -33,14 +39,34 @@ namespace Microsoft.AspNetCore.Authorization _pendingRequirements = new HashSet(requirements); } + /// + /// The collection of all the for the current authorization action. + /// public IEnumerable Requirements { get; } + + /// + /// The representing the current user. + /// public ClaimsPrincipal User { get; } + + /// + /// The optional resource to evaluate the against. + /// public object Resource { get; } + /// + /// Gets the requirements that have not yet been succeeded. + /// public IEnumerable PendingRequirements { get { return _pendingRequirements; } } + /// + /// Flag indicating whether the current authorization processing has failed. + /// public bool HasFailed { get { return _failCalled; } } + /// + /// Flag indicating whether the current authorization processing has succeeded. + /// public bool HasSucceeded { get @@ -49,11 +75,20 @@ namespace Microsoft.AspNetCore.Authorization } } + /// + /// Called to indicate will + /// never return true, even if all requirements are met. + /// public void Fail() { _failCalled = true; } + /// + /// Called to mark the specified as being + /// successfully evaluated. + /// + /// The requirement whose evaluation has succeeded. public void Succeed(IAuthorizationRequirement requirement) { _succeedCalled = true; diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs index 94799af29b..5031c68b9e 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -14,8 +14,11 @@ namespace Microsoft.AspNetCore.Authorization private IDictionary PolicyMap { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); /// - /// The initial default policy is to require any authenticated user + /// Gets or sets the default authoization policy. /// + /// + /// The default policy is to require any authenticated user. + /// public AuthorizationPolicy DefaultPolicy { get; set; } = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); /// diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs index 171fe014d6..41eb7aadeb 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -8,8 +8,23 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization { + /// + /// Represents a collection of authorization requirements and the scheme or + /// schemes they are evaluated against, all of which must succeed + /// for authorization to succeed. + /// public class AuthorizationPolicy { + /// + /// Creates a new instance of . + /// + /// + /// The list of s which must succeed for + /// this policy to be successful. + /// + /// + /// The authentication schemes the are evaluated against. + /// public AuthorizationPolicy(IEnumerable requirements, IEnumerable authenticationSchemes) { if (requirements == null) @@ -30,9 +45,26 @@ namespace Microsoft.AspNetCore.Authorization AuthenticationSchemes = new List(authenticationSchemes).AsReadOnly(); } + /// + /// Gets a readonly list of s which must succeed for + /// this policy to be successful. + /// public IReadOnlyList Requirements { get; } + + /// + /// Gets a readonly list of rhe authentication schemes the + /// are evaluated against. + /// public IReadOnlyList AuthenticationSchemes { get; } + /// + /// Combines the specified into a single policy. + /// + /// The authorization policies to combine. + /// + /// A new which represents the combination of the + /// specified . + /// public static AuthorizationPolicy Combine(params AuthorizationPolicy[] policies) { if (policies == null) @@ -43,6 +75,14 @@ namespace Microsoft.AspNetCore.Authorization return Combine((IEnumerable)policies); } + /// + /// Combines the specified into a single policy. + /// + /// The authorization policies to combine. + /// + /// A new which represents the combination of the + /// specified . + /// public static AuthorizationPolicy Combine(IEnumerable policies) { if (policies == null) @@ -58,6 +98,16 @@ namespace Microsoft.AspNetCore.Authorization return builder.Build(); } + /// + /// Combines the provided by the specified + /// + /// + /// A which provides the policies to combine. + /// A collection of authorization data used to apply authorization to a resource. + /// + /// A new which represents the combination of the + /// authorization policies provided by specified . + /// public static async Task CombineAsync(IAuthorizationPolicyProvider policyProvider, IEnumerable authorizeData) { if (policyProvider == null) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs index 653727f5ee..37335df8f2 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs @@ -9,21 +9,47 @@ using Microsoft.AspNetCore.Authorization.Infrastructure; namespace Microsoft.AspNetCore.Authorization { + /// + /// Used for building policies during application startup. + /// public class AuthorizationPolicyBuilder { + /// + /// Creates a new instance of + /// + /// An array of authentication schemes the policy should be evaluated against. public AuthorizationPolicyBuilder(params string[] authenticationSchemes) { AddAuthenticationSchemes(authenticationSchemes); } + /// + /// Creates a new instance of . + /// + /// The to build. public AuthorizationPolicyBuilder(AuthorizationPolicy policy) { Combine(policy); } + /// + /// Gets or sets a list of s which must succeed for + /// this policy to be successful. + /// public IList Requirements { get; set; } = new List(); + + /// + /// Gets or sets a list authentication schemes the + /// are evaluated against. + /// public IList AuthenticationSchemes { get; set; } = new List(); + /// + /// Adds the specified authentication to the + /// for this instance. + /// + /// The schemes to add. + /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder AddAuthenticationSchemes(params string[] schemes) { foreach (var authType in schemes) @@ -33,6 +59,12 @@ namespace Microsoft.AspNetCore.Authorization return this; } + /// + /// Adds the specified to the + /// for this instance. + /// + /// The authorization requirements to add. + /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder AddRequirements(params IAuthorizationRequirement[] requirements) { foreach (var req in requirements) @@ -42,6 +74,11 @@ namespace Microsoft.AspNetCore.Authorization return this; } + /// + /// Combines the specified into the current instance. + /// + /// The to combine. + /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder Combine(AuthorizationPolicy policy) { if (policy == null) @@ -54,6 +91,13 @@ namespace Microsoft.AspNetCore.Authorization return this; } + /// + /// Adds a + /// to the current instance. + /// + /// The claim type required. + /// Values the claim must process one or more of for evaluation to succeed. + /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireClaim(string claimType, params string[] requiredValues) { if (claimType == null) @@ -64,6 +108,13 @@ namespace Microsoft.AspNetCore.Authorization return RequireClaim(claimType, (IEnumerable)requiredValues); } + /// + /// Adds a + /// to the current instance. + /// + /// The claim type required. + /// Values the claim must process one or more of for evaluation to succeed. + /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireClaim(string claimType, IEnumerable requiredValues) { if (claimType == null) @@ -75,6 +126,12 @@ namespace Microsoft.AspNetCore.Authorization return this; } + /// + /// Adds a + /// to the current instance. + /// + /// The claim type required, which no restrictions on claim value. + /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireClaim(string claimType) { if (claimType == null) @@ -86,6 +143,12 @@ namespace Microsoft.AspNetCore.Authorization return this; } + /// + /// Adds a + /// to the current instance. + /// + /// The roles required. + /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireRole(params string[] roles) { if (roles == null) @@ -96,6 +159,12 @@ namespace Microsoft.AspNetCore.Authorization return RequireRole((IEnumerable)roles); } + /// + /// Adds a + /// to the current instance. + /// + /// The roles required. + /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireRole(IEnumerable roles) { if (roles == null) @@ -107,6 +176,12 @@ namespace Microsoft.AspNetCore.Authorization return this; } + /// + /// Adds a + /// to the current instance. + /// + /// The user name the current user must possess. + /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireUserName(string userName) { if (userName == null) @@ -118,6 +193,10 @@ namespace Microsoft.AspNetCore.Authorization return this; } + /// + /// Adds a to the current instance. + /// + /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireAuthenticatedUser() { Requirements.Add(new DenyAnonymousAuthorizationRequirement()); @@ -125,37 +204,44 @@ namespace Microsoft.AspNetCore.Authorization } /// - /// Requires that this Function returns true + /// Adds an to the current instance. /// - /// Function that must return true - /// - public AuthorizationPolicyBuilder RequireAssertion(Func assert) + /// The handler to evaluate during authorization. + /// A reference to this instance after the operation has completed. + public AuthorizationPolicyBuilder RequireAssertion(Func handler) { - if (assert == null) + if (handler == null) { - throw new ArgumentNullException(nameof(assert)); + throw new ArgumentNullException(nameof(handler)); } - Requirements.Add(new AssertionRequirement(assert)); + Requirements.Add(new AssertionRequirement(handler)); return this; } /// - /// Requires that this Function returns true + /// Adds an to the current instance. /// - /// Function that must return true - /// - public AuthorizationPolicyBuilder RequireAssertion(Func> assert) + /// The handler to evaluate during authorization. + /// A reference to this instance after the operation has completed. + public AuthorizationPolicyBuilder RequireAssertion(Func> handler) { - if (assert == null) + if (handler == null) { - throw new ArgumentNullException(nameof(assert)); + throw new ArgumentNullException(nameof(handler)); } - Requirements.Add(new AssertionRequirement(assert)); + Requirements.Add(new AssertionRequirement(handler)); return this; } + /// + /// Builds a new from the requirements + /// in this instance. + /// + /// + /// A new built from the requirements in this instance. + /// public AuthorizationPolicy Build() { return new AuthorizationPolicy(Requirements, AuthenticationSchemes.Distinct()); diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs index 8979c5c632..197e89cf8d 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -8,16 +8,22 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization { + /// + /// Extension methods for . + /// public static class AuthorizationServiceExtensions { /// /// Checks if a user meets a specific requirement for the specified resource /// - /// The . - /// - /// - /// - /// + /// The providing authorization. + /// The user to evaluate the policy against. + /// The resource to evaluate the policy against. + /// The requirement to evaluate the policy against. + /// + /// A flag indicating whether requirement evaluation has succeeded or failed. + /// This value is true when the user fulfills the policy otherwise false. + /// public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, IAuthorizationRequirement requirement) { if (service == null) @@ -34,13 +40,16 @@ namespace Microsoft.AspNetCore.Authorization } /// - /// Checks if a user meets a specific authorization policy + /// Checks if a user meets a specific authorization policy against the specified resource. /// - /// The authorization service. - /// The user to check the policy against. - /// The resource the policy should be checked with. - /// The policy to check against a specific context. - /// true when the user fulfills the policy, false otherwise. + /// The providing authorization. + /// The user to evaluate the policy against. + /// The resource to evaluate the policy against. + /// The policy to evaluate. + /// + /// A flag indicating whether policy evaluation has succeeded or failed. + /// This value is true when the user fulfills the policy otherwise false. + /// public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, AuthorizationPolicy policy) { if (service == null) @@ -57,12 +66,15 @@ namespace Microsoft.AspNetCore.Authorization } /// - /// Checks if a user meets a specific authorization policy + /// Checks if a user meets a specific authorization policy against the specified resource. /// - /// The authorization service. - /// The user to check the policy against. - /// The policy to check against a specific context. - /// true when the user fulfills the policy, false otherwise. + /// The providing authorization. + /// The user to evaluate the policy against. + /// The policy to evaluate. + /// + /// A flag indicating whether policy evaluation has succeeded or failed. + /// This value is true when the user fulfills the policy otherwise false. + /// public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, AuthorizationPolicy policy) { if (service == null) @@ -79,12 +91,15 @@ namespace Microsoft.AspNetCore.Authorization } /// - /// Checks if a user meets a specific authorization policy + /// Checks if a user meets a specific authorization policy against the specified resource. /// - /// The authorization service. - /// The user to check the policy against. - /// The name of the policy to check against a specific context. - /// true when the user fulfills the policy, false otherwise. + /// The providing authorization. + /// The user to evaluate the policy against. + /// The name of the policy to evaluate. + /// + /// A flag indicating whether policy evaluation has succeeded or failed. + /// This value is true when the user fulfills the policy otherwise false. + /// public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, string policyName) { if (service == null) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs index cdfab44f17..c911dc56bc 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs @@ -29,7 +29,6 @@ namespace Microsoft.AspNetCore.Authorization public string Policy { get; set; } /// - // REVIEW: can we get rid of the , deliminated in Roles/AuthTypes public string Roles { get; set; } /// diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs index e053e41f95..2c9ea19b5c 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -8,12 +8,17 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authorization { /// - /// A type which can provide a for a particular name. + /// The default implementation of a policy provider, + /// which provides a for a particular name. /// public class DefaultAuthorizationPolicyProvider : IAuthorizationPolicyProvider { private readonly AuthorizationOptions _options; + /// + /// Creates a new instance of . + /// + /// The options used to configure this instance. public DefaultAuthorizationPolicyProvider(IOptions options) { if (options == null) @@ -24,6 +29,10 @@ namespace Microsoft.AspNetCore.Authorization _options = options.Value; } + /// + /// Gets the default authorization policy. + /// + /// The default authorization policy. public Task GetDefaultPolicyAsync() { return Task.FromResult(_options.DefaultPolicy); @@ -32,8 +41,8 @@ namespace Microsoft.AspNetCore.Authorization /// /// Gets a from the given /// - /// - /// + /// The policy name to retrieve. + /// The named . public virtual Task GetPolicyAsync(string policyName) { return Task.FromResult(_options.GetPolicy(policyName)); diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index d90cf18031..4ac87eff45 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -11,12 +11,21 @@ using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Authorization { + /// + /// The default implementation of an . + /// public class DefaultAuthorizationService : IAuthorizationService { private readonly IAuthorizationPolicyProvider _policyProvider; private readonly IList _handlers; private readonly ILogger _logger; + /// + /// Creates a new instance of . + /// + /// The used to provide policies. + /// The handlers used to fufills s. + /// The logger used to log messages, warnings and errors. public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) { if (policyProvider == null) @@ -37,6 +46,16 @@ namespace Microsoft.AspNetCore.Authorization _logger = logger; } + /// + /// Checks if a user meets a specific set of requirements for the specified resource + /// + /// The user to evaluate the requirements against. + /// The resource to evaluate the requirements against. + /// The requirements to evaluate. + /// + /// A flag indicating whether authorization has succeded. + /// This value is true when the user fulfills the policy otherwise false. + /// public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) { if (requirements == null) @@ -84,6 +103,16 @@ namespace Microsoft.AspNetCore.Authorization return (identity as ClaimsIdentity)?.FindFirst(claimsType)?.Value; } + /// + /// Checks if a user meets a specific authorization policy + /// + /// The user to check the policy against. + /// The resource the policy should be checked with. + /// The name of the policy to check against a specific context. + /// + /// A flag indicating whether authorization has succeded. + /// This value is true when the user fulfills the policy otherwise false. + /// public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) { if (policyName == null) diff --git a/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs b/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs index 7593e0ad3c..8531c3daab 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs @@ -3,6 +3,9 @@ namespace Microsoft.AspNetCore.Authorization { + /// + /// Marker interface to enable the . + /// public interface IAllowAnonymous { } diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs index ac141b327d..9e9d0f468a 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs @@ -13,14 +13,14 @@ namespace Microsoft.AspNetCore.Authorization /// /// Gets a from the given /// - /// - /// + /// The policy name to retrieve. + /// The named . Task GetPolicyAsync(string policyName); /// - /// Returns the default . + /// Gets the default authorization policy. /// - /// + /// The default authorization policy. Task GetDefaultPolicyAsync(); } } diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs index 800789a8ca..0bdcaff86a 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs @@ -3,6 +3,9 @@ namespace Microsoft.AspNetCore.Authorization { + /// + /// Represents an authorization requirement. + /// public interface IAuthorizationRequirement { } diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs index e3b9fec91e..369e3b5763 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -15,10 +15,13 @@ namespace Microsoft.AspNetCore.Authorization /// /// Checks if a user meets a specific set of requirements for the specified resource /// - /// - /// - /// - /// + /// The user to evaluate the requirements against. + /// The resource to evaluate the requirements against. + /// The requirements to evaluate. + /// + /// A flag indicating whether authorization has succeded. + /// This value is true when the user fulfills the policy otherwise false. + /// Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements); /// @@ -27,7 +30,10 @@ namespace Microsoft.AspNetCore.Authorization /// The user to check the policy against. /// The resource the policy should be checked with. /// The name of the policy to check against a specific context. - /// true when the user fulfills the policy, false otherwise. + /// + /// A flag indicating whether authorization has succeded. + /// This value is true when the user fulfills the policy otherwise false. + /// Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs index 3371134b48..b48449b5cb 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs @@ -14,10 +14,13 @@ namespace Microsoft.AspNetCore.Authorization string Policy { get; set; } /// - /// Gets or sets a comma-separated list of roles that are allowed to access the resource. + /// Gets or sets a comma delimited list of roles that are allowed to access the resource. /// string Roles { get; set; } + /// + /// Gets or sets a comma delimited list of schemes from which user information is constructed. + /// string ActiveAuthenticationSchemes { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs index 2ddf065266..1c38b800e9 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs @@ -6,33 +6,49 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { + /// + /// Implements an and + /// that takes an user specified assertion. + /// public class AssertionRequirement : IAuthorizationHandler, IAuthorizationRequirement { /// - /// Function that is called to handle this requirement + /// Function that is called to handle this requirement. /// public Func> Handler { get; } - public AssertionRequirement(Func assert) + /// + /// Creates a new instance of . + /// + /// Function that is called to handle this requirement. + public AssertionRequirement(Func handler) { - if (assert == null) + if (handler == null) { - throw new ArgumentNullException(nameof(assert)); + throw new ArgumentNullException(nameof(handler)); } - Handler = context => Task.FromResult(assert(context)); + Handler = context => Task.FromResult(handler(context)); } - public AssertionRequirement(Func> assert) + /// + /// Creates a new instance of . + /// + /// Function that is called to handle this requirement. + public AssertionRequirement(Func> handler) { - if (assert == null) + if (handler == null) { - throw new ArgumentNullException(nameof(assert)); + throw new ArgumentNullException(nameof(handler)); } - Handler = assert; + Handler = handler; } + /// + /// Calls to see if authorization is allowed. + /// + /// The authorization information. public async Task HandleAsync(AuthorizationHandlerContext context) { if (await Handler(context)) diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs index c5a06c2f95..0e28ba0776 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -8,10 +8,19 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { - // Must contain a claim with the specified name, and at least one of the required values - // If AllowedValues is null or empty, that means any claim is valid + /// + /// Implements an and + /// which requires at least one instance of the specified claim type, and, if allowed values are specified, + /// the claim value must be any of the allowed values. + /// public class ClaimsAuthorizationRequirement : AuthorizationHandler, IAuthorizationRequirement { + /// + /// Creates a new instance of . + /// + /// The claim type that must be present. + /// The optional list of claim values, which, if present, + /// the claim must match. public ClaimsAuthorizationRequirement(string claimType, IEnumerable allowedValues) { if (claimType == null) @@ -23,9 +32,22 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure AllowedValues = allowedValues; } + /// + /// Gets the claim type that must be present. + /// public string ClaimType { get; } + + /// + /// Gets the optional list of claim values, which, if present, + /// the claim must match. + /// public IEnumerable AllowedValues { get; } + /// + /// Makes a decision if authorization is allowed based on the claims requirements specified. + /// + /// The authorization context. + /// The requirement to evaluate. protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ClaimsAuthorizationRequirement requirement) { if (context.User != null) diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs index 82d40639bc..7f2671775f 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs @@ -6,8 +6,17 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { + /// + /// Implements an and + /// which requires the current user must be authenticated. + /// public class DenyAnonymousAuthorizationRequirement : AuthorizationHandler, IAuthorizationRequirement { + /// + /// Makes a decision if authorization is allowed based on a specific requirement. + /// + /// The authorization context. + /// The requirement to evaluate. protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, DenyAnonymousAuthorizationRequirement requirement) { var user = context.User; diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs index 3643b1fb7a..aca1920d7d 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs @@ -8,10 +8,15 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { /// - /// Requirement that ensures a specific Name + /// Implements an and + /// which requires the current user name must match the specified value. /// public class NameAuthorizationRequirement : AuthorizationHandler, IAuthorizationRequirement { + /// + /// Constructs a new instance of . + /// + /// The required name that the current user must have. public NameAuthorizationRequirement(string requiredName) { if (requiredName == null) @@ -22,13 +27,20 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure RequiredName = requiredName; } + /// + /// Gets the required name that the current user must have. + /// public string RequiredName { get; } + /// + /// Makes a decision if authorization is allowed based on a specific requirement. + /// + /// The authorization context. + /// The requirement to evaluate. protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, NameAuthorizationRequirement requirement) { if (context.User != null) { - // REVIEW: Do we need to do normalization? casing/loc? if (context.User.Identities.Any(i => string.Equals(i.Name, requirement.RequiredName))) { context.Succeed(requirement); diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs index 455d66ff24..c3f16356d3 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs @@ -3,8 +3,15 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure { + /// + /// A helper class to provide a useful which + /// contains a name. + /// public class OperationAuthorizationRequirement : IAuthorizationRequirement { + /// + /// The name of this instance of . + /// public string Name { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs index d718591ec1..60fd66b85c 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs @@ -6,8 +6,16 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { + /// + /// Infrastructre class which allows an to + /// be its own . + /// public class PassThroughAuthorizationHandler : IAuthorizationHandler { + /// + /// Makes a decision if authorization is allowed. + /// + /// The authorization context. public async Task HandleAsync(AuthorizationHandlerContext context) { foreach (var handler in context.Requirements.OfType()) diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs index 53d6beb167..6e5aa72247 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -8,10 +8,16 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { - // Must belong to with one of specified roles - // If AllowedRoles is null or empty, that means any role is valid + /// + /// Implements an and + /// which requires at least one role claim whose value must be any of the allowed roles. + /// public class RolesAuthorizationRequirement : AuthorizationHandler, IAuthorizationRequirement { + /// + /// Creates a new instance of . + /// + /// A collection of allowed roles. public RolesAuthorizationRequirement(IEnumerable allowedRoles) { if (allowedRoles == null) @@ -26,8 +32,17 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure AllowedRoles = allowedRoles; } + /// + /// Gets the collection of allowed roles. + /// public IEnumerable AllowedRoles { get; } + /// + /// Makes a decision if authorization is allowed based on a specific requirement. + /// + /// The authorization context. + /// The requirement to evaluate. + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RolesAuthorizationRequirement requirement) { if (context.User != null) From 34ee0212d0c6de76a40609b70df77545dbdde3bf Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 10 Jun 2016 15:37:08 -0700 Subject: [PATCH 559/900] Fix misc feedback --- .../AuthorizationHandlerContext.cs | 2 +- .../AuthorizationOptions.cs | 2 +- .../AuthorizationPolicy.cs | 6 +++--- .../AuthorizationServiceExtensions.cs | 8 ++++---- .../DefaultAuthorizationService.cs | 6 +++--- .../Infrastructure/AssertionRequirement.cs | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs index 65aafa2bb6..5dc57c278a 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs @@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Authorization public object Resource { get; } /// - /// Gets the requirements that have not yet been succeeded. + /// Gets the requirements that have not yet been marked as succeeded. /// public IEnumerable PendingRequirements { get { return _pendingRequirements; } } diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs index 5031c68b9e..fa9e9ef1ee 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Authorization private IDictionary PolicyMap { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); /// - /// Gets or sets the default authoization policy. + /// Gets or sets the default authorization policy. /// /// /// The default policy is to require any authenticated user. diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs index 41eb7aadeb..3fe0cdd070 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Authorization public IReadOnlyList Requirements { get; } /// - /// Gets a readonly list of rhe authentication schemes the + /// Gets a readonly list of the authentication schemes the /// are evaluated against. /// public IReadOnlyList AuthenticationSchemes { get; } @@ -100,13 +100,13 @@ namespace Microsoft.AspNetCore.Authorization /// /// Combines the provided by the specified - /// + /// . /// /// A which provides the policies to combine. /// A collection of authorization data used to apply authorization to a resource. /// /// A new which represents the combination of the - /// authorization policies provided by specified . + /// authorization policies provided by the specified . /// public static async Task CombineAsync(IAuthorizationPolicyProvider policyProvider, IEnumerable authorizeData) { diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs index 197e89cf8d..3b78c952eb 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Authorization /// The requirement to evaluate the policy against. /// /// A flag indicating whether requirement evaluation has succeeded or failed. - /// This value is true when the user fulfills the policy otherwise false. + /// This value is true when the user fulfills the policy, otherwise false. /// public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, IAuthorizationRequirement requirement) { @@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Authorization /// The policy to evaluate. /// /// A flag indicating whether policy evaluation has succeeded or failed. - /// This value is true when the user fulfills the policy otherwise false. + /// This value is true when the user fulfills the policy, otherwise false. /// public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, AuthorizationPolicy policy) { @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Authorization /// The policy to evaluate. /// /// A flag indicating whether policy evaluation has succeeded or failed. - /// This value is true when the user fulfills the policy otherwise false. + /// This value is true when the user fulfills the policy, otherwise false. /// public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, AuthorizationPolicy policy) { @@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.Authorization /// The name of the policy to evaluate. /// /// A flag indicating whether policy evaluation has succeeded or failed. - /// This value is true when the user fulfills the policy otherwise false. + /// This value is true when the user fulfills the policy, otherwise false. /// public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, string policyName) { diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 4ac87eff45..6665204eee 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Authorization /// Creates a new instance of . /// /// The used to provide policies. - /// The handlers used to fufills s. + /// The handlers used to fulfill s. /// The logger used to log messages, warnings and errors. public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) { @@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Authorization } /// - /// Checks if a user meets a specific set of requirements for the specified resource + /// Checks if a user meets a specific set of requirements for the specified resource. /// /// The user to evaluate the requirements against. /// The resource to evaluate the requirements against. @@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Authorization } /// - /// Checks if a user meets a specific authorization policy + /// Checks if a user meets a specific authorization policy. /// /// The user to check the policy against. /// The resource the policy should be checked with. diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs index 1c38b800e9..5fa452b733 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs @@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure { /// /// Implements an and - /// that takes an user specified assertion. + /// that takes a user specified assertion. /// public class AssertionRequirement : IAuthorizationHandler, IAuthorizationRequirement { From 666ad0fc3b6027e8efc0df3595abc982d6921478 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 13 Jun 2016 14:10:43 -0700 Subject: [PATCH 560/900] Doc comment update --- .../IAuthorizationService.cs | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs index 369e3b5763..a130c84b0d 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -16,24 +16,39 @@ namespace Microsoft.AspNetCore.Authorization /// Checks if a user meets a specific set of requirements for the specified resource /// /// The user to evaluate the requirements against. - /// The resource to evaluate the requirements against. + /// + /// An optional resource the policy should be checked with. + /// If a resource is not required for policy evaluation you may pass null as the value. + /// /// The requirements to evaluate. /// - /// A flag indicating whether authorization has succeded. - /// This value is true when the user fulfills the policy otherwise false. + /// A flag indicating whether authorization has succeeded. + /// This value is true when the user fulfills the policy; otherwise false. /// + /// + /// Resource is an optional parameter and may be null. Please ensure that you check it is not + /// null before acting upon it. + /// Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements); /// /// Checks if a user meets a specific authorization policy /// /// The user to check the policy against. - /// The resource the policy should be checked with. + /// + /// An optional resource the policy should be checked with. + /// If a resource is not required for policy evaluation you may pass null as the value. + /// /// The name of the policy to check against a specific context. /// - /// A flag indicating whether authorization has succeded. - /// This value is true when the user fulfills the policy otherwise false. + /// A flag indicating whether authorization has succeeded. + /// Returns a flag indicating whether the user, and optional resource has fulfilled the policy. + /// true when the the policy has been fulfilled; otherwise false. /// + /// + /// Resource is an optional parameter and may be null. Please ensure that you check it is not + /// null before acting upon it. + /// Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName); } } \ No newline at end of file From b7bdb39b921cfd86e927fdc5ed585a493dc151d1 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Mon, 13 Jun 2016 15:29:53 -0700 Subject: [PATCH 561/900] Remove direct Microsoft.NETCore.Platforms dependency. - Microsoft.NETCore.App now pulls this package in. aspnet/Coherence-Signed#344 --- samples/CookieSample/project.json | 1 - samples/CookieSessionSample/project.json | 1 - samples/JwtBearerSample/project.json | 1 - samples/OpenIdConnect.AzureAdSample/project.json | 1 - samples/OpenIdConnectSample/project.json | 1 - samples/SocialSample/project.json | 1 - test/Microsoft.AspNetCore.Authentication.Test/project.json | 1 - test/Microsoft.AspNetCore.Authorization.Test/project.json | 1 - test/Microsoft.AspNetCore.CookiePolicy.Test/project.json | 1 - test/Microsoft.Owin.Security.Interop.Test/project.json | 1 - 10 files changed, 10 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index aa38029d98..00dafe618d 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -1,6 +1,5 @@ { "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.DataProtection": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index fb8d16c023..20f7899d41 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -1,6 +1,5 @@ { "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.DataProtection": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 5bf0a928a9..5296a40fb0 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -4,7 +4,6 @@ "emitEntryPoint": true }, "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index ff03a5584b..33fcb0a43b 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -1,6 +1,5 @@ { "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 7e0aa0e5f1..0069f3024e 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -1,6 +1,5 @@ { "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 98ff9263aa..5d61d71c42 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -1,6 +1,5 @@ { "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*", diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 01d03d2b30..57d98ac8e3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -4,7 +4,6 @@ }, "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*", diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 11b3caf4d4..075daedfbc 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -4,7 +4,6 @@ }, "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authorization": "1.0.0-*", "Microsoft.AspNetCore.Testing": "1.0.0-*", "Microsoft.Extensions.DependencyInjection": "1.0.0-*", diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 26cc946be1..0027c57e6b 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -4,7 +4,6 @@ }, "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.CookiePolicy": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index 4dac4d3a28..d728848e59 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -4,7 +4,6 @@ }, "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Owin.Security.Cookies": "3.0.1", From 36023d6dd52167c2da3d5f83a27e67bb1927e1c9 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 14 Jun 2016 16:23:04 -0700 Subject: [PATCH 562/900] Updating to release. --- NuGet.config | 4 ++-- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 5500f6d507..71b9724a09 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..cf8bff13bb 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..f88fe4052e 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 20316e276c08d358e54a720c3bce3c2637e49f59 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Mon, 13 Jun 2016 14:24:45 -0700 Subject: [PATCH 563/900] Update Json.NET to 9.0.1 --- src/Microsoft.AspNetCore.Authentication.OAuth/project.json | 2 +- src/Microsoft.AspNetCore.Authentication.Twitter/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index 971a8d6960..c302892a32 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -22,7 +22,7 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", - "Newtonsoft.Json": "9.0.1-beta1" + "Newtonsoft.Json": "9.0.1" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 7d830ad8c1..a1a7ba5e1f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -22,7 +22,7 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.0.0-*", - "Newtonsoft.Json": "9.0.1-beta1" + "Newtonsoft.Json": "9.0.1" }, "frameworks": { "net451": {}, From d8d408638e861832df90f1b426646777613481bc Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 16 Jun 2016 10:18:34 -0700 Subject: [PATCH 564/900] Updating to dev versions # Conflicts: # src/Microsoft.AspNetCore.Authentication.OAuth/project.json # src/Microsoft.AspNetCore.Authentication.Twitter/project.json --- samples/CookieSample/project.json | 12 ++++---- samples/CookieSessionSample/project.json | 14 +++++----- samples/JwtBearerSample/project.json | 14 +++++----- .../OpenIdConnect.AzureAdSample/project.json | 16 +++++------ samples/OpenIdConnectSample/project.json | 20 ++++++------- samples/SocialSample/project.json | 28 +++++++++---------- .../project.json | 8 +++--- .../project.json | 7 ++--- .../project.json | 7 ++--- .../project.json | 7 ++--- .../project.json | 7 ++--- .../project.json | 4 +-- .../project.json | 7 ++--- .../project.json | 7 ++--- .../project.json | 16 +++++------ .../project.json | 6 ++-- .../project.json | 6 ++-- .../project.json | 4 +-- .../project.json | 18 ++++++------ .../project.json | 8 +++--- .../project.json | 8 +++--- .../project.json | 6 ++-- 22 files changed, 112 insertions(+), 118 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 00dafe618d..57ceb354aa 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -1,11 +1,11 @@ { "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.DataProtection": "1.0.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*" + "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", + "Microsoft.AspNetCore.DataProtection": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*" }, "buildOptions": { "emitEntryPoint": true diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index 20f7899d41..6530e1cf00 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -1,12 +1,12 @@ { "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.DataProtection": "1.0.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.Extensions.Caching.Memory": "1.0.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*" + "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", + "Microsoft.AspNetCore.DataProtection": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.Extensions.Caching.Memory": "1.1.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*" }, "buildOptions": { "emitEntryPoint": true diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 5296a40fb0..21d2365ece 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -1,15 +1,15 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "buildOptions": { "emitEntryPoint": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" + "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.AspNetCore.StaticFiles": "1.1.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*" }, "frameworks": { "net451": {}, diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 33fcb0a43b..adb6a845a0 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -1,16 +1,16 @@ { "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*", "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.11.305310302-alpha" }, "frameworks": { - "net451": { }, + "net451": {}, "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 0069f3024e..6a24f3da60 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -1,15 +1,15 @@ { "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", - "Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*", - "Microsoft.Extensions.Logging.Debug": "1.0.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" + "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", + "Microsoft.Extensions.FileProviders.Embedded": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.Extensions.Logging.Debug": "1.1.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*" }, "frameworks": { "net451": {}, diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 5d61d71c42..227354e518 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -1,24 +1,24 @@ { "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-*", - "Microsoft.AspNetCore.DataProtection": "1.0.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", - "Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*" + "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.Google": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0-*", + "Microsoft.AspNetCore.DataProtection": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", + "Microsoft.Extensions.FileProviders.Embedded": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*" }, "buildOptions": { "emitEntryPoint": true }, "frameworks": { - "net451": { }, + "net451": {}, "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index c98a4bba1c..7ddff7ce8c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core middleware that enables an application to use cookie based authentication.", "packOptions": { "repository": { @@ -21,9 +21,9 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.0.0-*", - "Microsoft.Extensions.Options": "1.0.0-*", - "Microsoft.Extensions.WebEncoders": "1.0.0-*" + "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.Extensions.Options": "1.1.0-*", + "Microsoft.Extensions.WebEncoders": "1.1.0-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 35fedfada5..796b3bf7c5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow.", "packOptions": { "repository": { @@ -21,11 +21,10 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" + "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*" }, "frameworks": { "net451": {}, - "netstandard1.3": { - } + "netstandard1.3": {} } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index 37d91ba542..dde8c3a544 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows.", "packOptions": { "repository": { @@ -21,11 +21,10 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" + "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*" }, "frameworks": { "net451": {}, - "netstandard1.3": { - } + "netstandard1.3": {} } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 2863967e29..2f8ea6072a 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token.", "packOptions": { "repository": { @@ -21,12 +21,11 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.0.0-*", + "Microsoft.AspNetCore.Authentication": "1.1.0-*", "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { "net451": {}, - "netstandard1.4": { - } + "netstandard1.4": {} } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index 81f34b7361..3169adf72d 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow.", "packOptions": { "repository": { @@ -21,11 +21,10 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0-*" + "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*" }, "frameworks": { "net451": {}, - "netstandard1.3": { - } + "netstandard1.3": {} } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index c302892a32..192801ced6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow.", "packOptions": { "repository": { @@ -21,7 +21,7 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.0.0-*", + "Microsoft.AspNetCore.Authentication": "1.1.0-*", "Newtonsoft.Json": "9.0.1" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index b80faf063f..5243a96a73 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow.", "packOptions": { "repository": { @@ -21,12 +21,11 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.0.0-*", + "Microsoft.AspNetCore.Authentication": "1.1.0-*", "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { "net451": {}, - "netstandard1.4": { - } + "netstandard1.4": {} } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index a1a7ba5e1f..8696821dd8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core middleware that enables an application to support Twitter's OAuth 2.0 authentication workflow.", "packOptions": { "repository": { @@ -21,12 +21,11 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.0.0-*", + "Microsoft.AspNetCore.Authentication": "1.1.0-*", "Newtonsoft.Json": "9.0.1" }, "frameworks": { "net451": {}, - "netstandard1.3": { - } + "netstandard1.3": {} } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index dc56181a71..460549c7ba 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core common types used by the various authentication middleware components.", "packOptions": { "repository": { @@ -21,16 +21,16 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.DataProtection": "1.0.0-*", - "Microsoft.AspNetCore.Http": "1.0.0-*", - "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", - "Microsoft.Extensions.Logging.Abstractions": "1.0.0-*", + "Microsoft.AspNetCore.DataProtection": "1.1.0-*", + "Microsoft.AspNetCore.Http": "1.1.0-*", + "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", + "Microsoft.Extensions.Logging.Abstractions": "1.1.0-*", "Microsoft.Extensions.SecurityHelper.Sources": { "type": "build", - "version": "1.0.0-*" + "version": "1.1.0-*" }, - "Microsoft.Extensions.Options": "1.0.0-*", - "Microsoft.Extensions.WebEncoders": "1.0.0-*" + "Microsoft.Extensions.Options": "1.1.0-*", + "Microsoft.Extensions.WebEncoders": "1.1.0-*" }, "frameworks": { "net451": { diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 0f9becfc82..8e72b62f82 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core authorization classes.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Authorization.AllowAnonymousAttribute\r\nMicrosoft.AspNetCore.Authorization.AuthorizeAttribute", "packOptions": { "repository": { @@ -20,8 +20,8 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "1.0.0-*", - "Microsoft.Extensions.Options": "1.0.0-*" + "Microsoft.Extensions.Logging.Abstractions": "1.1.0-*", + "Microsoft.Extensions.Options": "1.1.0-*" }, "frameworks": { "net451": { diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json index 3cd40fd20c..4cf5f4881c 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "description": "ASP.NET Core cookie policy classes to control the behavior of cookies.", "packOptions": { "repository": { @@ -19,8 +19,8 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Http": "1.0.0-*", - "Microsoft.Extensions.Options": "1.0.0-*" + "Microsoft.AspNetCore.Http": "1.1.0-*", + "Microsoft.Extensions.Options": "1.1.0-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.Owin.Security.Interop/project.json b/src/Microsoft.Owin.Security.Interop/project.json index f94978e52a..c7b3326a01 100644 --- a/src/Microsoft.Owin.Security.Interop/project.json +++ b/src/Microsoft.Owin.Security.Interop/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", @@ -18,7 +18,7 @@ ] }, "dependencies": { - "Microsoft.AspNetCore.DataProtection.Extensions": "1.0.0-*", + "Microsoft.AspNetCore.DataProtection.Extensions": "1.1.0-*", "Microsoft.Owin.Security": "3.0.1" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 57d98ac8e3..2536d14252 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -4,15 +4,15 @@ }, "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-*", - "Microsoft.AspNetCore.TestHost": "1.0.0-*", - "Microsoft.AspNetCore.Testing": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.Google": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0-*", + "Microsoft.AspNetCore.TestHost": "1.1.0-*", + "Microsoft.AspNetCore.Testing": "1.1.0-*", "xunit": "2.1.0" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 075daedfbc..adffd1e587 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -4,10 +4,10 @@ }, "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.AspNetCore.Authorization": "1.0.0-*", - "Microsoft.AspNetCore.Testing": "1.0.0-*", - "Microsoft.Extensions.DependencyInjection": "1.0.0-*", - "Microsoft.Extensions.Logging": "1.0.0-*", + "Microsoft.AspNetCore.Authorization": "1.1.0-*", + "Microsoft.AspNetCore.Testing": "1.1.0-*", + "Microsoft.Extensions.DependencyInjection": "1.1.0-*", + "Microsoft.Extensions.Logging": "1.1.0-*", "xunit": "2.1.0" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 0027c57e6b..2fc65d73d6 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -4,10 +4,10 @@ }, "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.CookiePolicy": "1.0.0-*", - "Microsoft.AspNetCore.TestHost": "1.0.0-*", - "Microsoft.Extensions.DependencyInjection": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", + "Microsoft.AspNetCore.CookiePolicy": "1.1.0-*", + "Microsoft.AspNetCore.TestHost": "1.1.0-*", + "Microsoft.Extensions.DependencyInjection": "1.1.0-*", "xunit": "2.1.0" }, "frameworks": { diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index d728848e59..3178f9bbe8 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -4,10 +4,10 @@ }, "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", - "Microsoft.AspNetCore.TestHost": "1.0.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", + "Microsoft.AspNetCore.TestHost": "1.1.0-*", "Microsoft.Owin.Security.Cookies": "3.0.1", - "Microsoft.Owin.Security.Interop": "1.0.0-*", + "Microsoft.Owin.Security.Interop": "1.1.0-*", "Microsoft.Owin.Testing": "3.0.1", "xunit": "2.1.0" }, From b4342b1604260591ff0b508a1efb393989bb5fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Tue, 7 Jun 2016 00:20:35 +0200 Subject: [PATCH 565/900] Replace magic strings by the new constants introduced in IdentityModel --- .../OpenIdConnectHandler.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 4189ee262c..6488d10d72 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -112,17 +112,19 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // If the identifier cannot be found, bypass the session identifier checks: this may indicate that the // authentication cookie was already cleared, that the session identifier was lost because of a lossy // external/application cookie conversion or that the identity provider doesn't support sessions. - var sid = (await Context.Authentication.AuthenticateAsync(Options.SignOutScheme))?.FindFirst("sid")?.Value; + var sid = (await Context.Authentication.AuthenticateAsync(Options.SignOutScheme)) + ?.FindFirst(JwtRegisteredClaimNames.Sid) + ?.Value; if (!string.IsNullOrEmpty(sid)) { // Ensure a 'sid' parameter was sent by the identity provider. - if (string.IsNullOrEmpty(message.GetParameter("sid"))) + if (string.IsNullOrEmpty(message.Sid)) { Logger.RemoteSignOutSessionIdMissing(); return true; } // Ensure the 'sid' parameter corresponds to the 'sid' stored in the authentication ticket. - if (!string.Equals(sid, message.GetParameter("sid"), StringComparison.Ordinal)) + if (!string.Equals(sid, message.Sid, StringComparison.Ordinal)) { Logger.RemoteSignOutSessionIdInvalid(); return true; From 7323e75d5d0536410e95144b8784a0c80e190aac Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Tue, 5 Jul 2016 21:28:47 -0700 Subject: [PATCH 566/900] Updating to RTM builds of xunit and Moq --- .../project.json | 23 ++++-------------- .../project.json | 23 ++++-------------- .../project.json | 24 ++++--------------- .../project.json | 11 +++------ 4 files changed, 18 insertions(+), 63 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 2536d14252..0feac5dd91 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -3,7 +3,7 @@ "warningsAsErrors": true }, "dependencies": { - "dotnet-test-xunit": "1.0.0-*", + "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0-*", "Microsoft.AspNetCore.Authentication.Google": "1.1.0-*", @@ -13,7 +13,7 @@ "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0-*", "Microsoft.AspNetCore.TestHost": "1.1.0-*", "Microsoft.AspNetCore.Testing": "1.1.0-*", - "xunit": "2.1.0" + "xunit": "2.2.0-*" }, "frameworks": { "netcoreapp1.0": { @@ -21,23 +21,10 @@ "Microsoft.NETCore.App": { "version": "1.0.0-*", "type": "platform" - }, - "System.Diagnostics.Process": "4.1.0-*" - }, - "imports": [ - "dnxcore50", - "portable-net451+win8" - ] - }, - "net451": { - "frameworkAssemblies": { - "System.Runtime": "", - "System.Threading.Tasks": "" - }, - "dependencies": { - "xunit.runner.console": "2.1.0" + } } - } + }, + "net451": {} }, "testRunner": "xunit" } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index adffd1e587..f8fda41e34 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -3,12 +3,12 @@ "warningsAsErrors": true }, "dependencies": { - "dotnet-test-xunit": "1.0.0-*", + "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.Authorization": "1.1.0-*", "Microsoft.AspNetCore.Testing": "1.1.0-*", "Microsoft.Extensions.DependencyInjection": "1.1.0-*", "Microsoft.Extensions.Logging": "1.1.0-*", - "xunit": "2.1.0" + "xunit": "2.2.0-*" }, "frameworks": { "netcoreapp1.0": { @@ -16,23 +16,10 @@ "Microsoft.NETCore.App": { "version": "1.0.0-*", "type": "platform" - }, - "System.Diagnostics.Process": "4.1.0-*" - }, - "imports": [ - "dnxcore50", - "portable-net451+win8" - ] - }, - "net451": { - "frameworkAssemblies": { - "System.Runtime": "", - "System.Threading.Tasks": "" - }, - "dependencies": { - "xunit.runner.console": "2.1.0" + } } - } + }, + "net451": {} }, "testRunner": "xunit" } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 2fc65d73d6..89673d8488 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -3,12 +3,12 @@ "warningsAsErrors": true }, "dependencies": { - "dotnet-test-xunit": "1.0.0-*", + "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", "Microsoft.AspNetCore.CookiePolicy": "1.1.0-*", "Microsoft.AspNetCore.TestHost": "1.1.0-*", "Microsoft.Extensions.DependencyInjection": "1.1.0-*", - "xunit": "2.1.0" + "xunit": "2.2.0-*" }, "frameworks": { "netcoreapp1.0": { @@ -16,24 +16,10 @@ "Microsoft.NETCore.App": { "version": "1.0.0-*", "type": "platform" - }, - "System.Diagnostics.Process": "4.1.0-*" - }, - "imports": [ - "dnxcore50", - "portable-net451+win8" - ] - }, - "net451": { - "frameworkAssemblies": { - "System.Runtime": "", - "System.Threading.Tasks": "", - "System.Xml.Linq": "" - }, - "dependencies": { - "xunit.runner.console": "2.1.0" + } } - } + }, + "net451": {} }, "testRunner": "xunit" } \ No newline at end of file diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index 3178f9bbe8..e622bd746f 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -3,21 +3,16 @@ "warningsAsErrors": true }, "dependencies": { - "dotnet-test-xunit": "1.0.0-*", + "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", "Microsoft.AspNetCore.TestHost": "1.1.0-*", "Microsoft.Owin.Security.Cookies": "3.0.1", "Microsoft.Owin.Security.Interop": "1.1.0-*", "Microsoft.Owin.Testing": "3.0.1", - "xunit": "2.1.0" + "xunit": "2.2.0-*" }, "frameworks": { - "net451": { - "frameworkAssemblies": { - "System.Runtime": "", - "System.Threading.Tasks": "" - } - } + "net451": {} }, "testRunner": "xunit" } \ No newline at end of file From 792b316950acee424e67af00540e247e94b07b4c Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 7 Jul 2016 12:40:05 -0700 Subject: [PATCH 567/900] One build to rule them all - well, at least VS and command-line builds will share output - part of aspnet/Coherence-Signed#277 --- samples/CookieSample/CookieSample.xproj | 4 ++-- samples/CookieSessionSample/CookieSessionSample.xproj | 4 ++-- samples/JwtBearerSample/JwtBearerSample.xproj | 5 +++-- .../OpenIdConnect.AzureAdSample.xproj | 5 +++-- samples/OpenIdConnectSample/OpenIdConnectSample.xproj | 4 ++-- samples/SocialSample/SocialSample.xproj | 4 ++-- .../Microsoft.AspNetCore.Authentication.Cookies.xproj | 4 ++-- .../Microsoft.AspNetCore.Authentication.Facebook.xproj | 4 ++-- .../Microsoft.AspNetCore.Authentication.Google.xproj | 4 ++-- .../Microsoft.AspNetCore.Authentication.JwtBearer.xproj | 4 ++-- ...icrosoft.AspNetCore.Authentication.MicrosoftAccount.xproj | 4 ++-- .../Microsoft.AspNetCore.Authentication.OAuth.xproj | 4 ++-- .../Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj | 4 ++-- .../Microsoft.AspNetCore.Authentication.Twitter.xproj | 4 ++-- .../Microsoft.AspNetCore.Authentication.xproj | 4 ++-- .../Microsoft.AspNetCore.Authorization.xproj | 4 ++-- .../Microsoft.AspNetCore.CookiePolicy.xproj | 4 ++-- .../Microsoft.Owin.Security.Interop.xproj | 4 ++-- .../Microsoft.AspNetCore.Authentication.Test.xproj | 4 ++-- .../Microsoft.AspNetCore.Authorization.Test.xproj | 4 ++-- .../Microsoft.AspNetCore.CookiePolicy.Test.xproj | 4 ++-- .../Microsoft.Owin.Security.Interop.Test.xproj | 4 ++-- 22 files changed, 46 insertions(+), 44 deletions(-) diff --git a/samples/CookieSample/CookieSample.xproj b/samples/CookieSample/CookieSample.xproj index bb23e6481a..f6575c3e0a 100644 --- a/samples/CookieSample/CookieSample.xproj +++ b/samples/CookieSample/CookieSample.xproj @@ -7,8 +7,8 @@ 558c2c2a-aed8-49de-bb60-d5f8ae06c714 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/samples/CookieSessionSample/CookieSessionSample.xproj b/samples/CookieSessionSample/CookieSessionSample.xproj index c81393af16..1c347c845f 100644 --- a/samples/CookieSessionSample/CookieSessionSample.xproj +++ b/samples/CookieSessionSample/CookieSessionSample.xproj @@ -7,8 +7,8 @@ 19711880-46da-4a26-9e0f-9b2e41d27651 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/samples/JwtBearerSample/JwtBearerSample.xproj b/samples/JwtBearerSample/JwtBearerSample.xproj index ed0c9b32bd..97f5837ce5 100644 --- a/samples/JwtBearerSample/JwtBearerSample.xproj +++ b/samples/JwtBearerSample/JwtBearerSample.xproj @@ -7,8 +7,8 @@ d399b84f-591b-4e98-92ba-b0f63e7b6957 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 @@ -17,6 +17,7 @@ + \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj index e3495a2118..26e9f9030b 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj @@ -7,8 +7,8 @@ 3a7ad414-ebde-4f92-b307-4e8f19b6117e - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 @@ -17,6 +17,7 @@ + \ No newline at end of file diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.xproj b/samples/OpenIdConnectSample/OpenIdConnectSample.xproj index 905bce8e3b..9029ad0f13 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.xproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.xproj @@ -7,8 +7,8 @@ bef0f5c3-ef4e-4649-9c49-d5e279a3ca2b - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/samples/SocialSample/SocialSample.xproj b/samples/SocialSample/SocialSample.xproj index 775eebbc26..b439f74d10 100644 --- a/samples/SocialSample/SocialSample.xproj +++ b/samples/SocialSample/SocialSample.xproj @@ -7,8 +7,8 @@ 8c73d216-332d-41d8-bfd0-45bc4bc36552 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj index 8c4f3cd41f..238c0cec67 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj @@ -7,8 +7,8 @@ fc152cc4-054b-457e-8d91-389c5de3c561 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj index 3952592121..caa72075ed 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj @@ -7,8 +7,8 @@ eeaaee68-607b-4e33-af3e-45c66b4dba5a - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj index ff412f08ae..ab60488729 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj @@ -7,8 +7,8 @@ 76579c39-b829-490d-b8be-1bd35fe8412e - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj index 8d87a04b76..738458398d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj @@ -7,8 +7,8 @@ 2755BFE5-7421-4A31-A644-F817DF5CAA98 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj index 52dd6cb676..a4ccc98630 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj @@ -7,8 +7,8 @@ acb45e19-f520-4d0c-8916-b0ceb9c017fe - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj index 34a397bd59..20b825dca0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj @@ -7,8 +7,8 @@ 1657c79e-7755-4aee-9d61-571295b69a30 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj index 2f970b5136..6a07e81203 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj @@ -7,8 +7,8 @@ 35115d55-b69e-46d4-bb33-c9e9e6ec5e7a - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj index 5fba7a9742..b72a631fa9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj @@ -7,8 +7,8 @@ 0330fff6-b4b5-42dd-8c99-26a789569000 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj index e03db08476..b3345c6cfc 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj @@ -7,8 +7,8 @@ 2286250a-52c8-4126-9f93-b1e45f0ad078 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj index c6a57567b4..cc6041f8f4 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj @@ -7,8 +7,8 @@ 6ab3e514-5894-4131-9399-dc7d5284addb - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj index 5ffad968d9..0cd49f3242 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj @@ -7,8 +7,8 @@ 86183dc3-02a8-4a68-8b60-71ecec066e79 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj index c6b01504ae..052e998161 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj @@ -7,8 +7,8 @@ a7922dd8-09f1-43e4-938b-cc523ea08898 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj index aec10ee939..1050a47adb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj @@ -7,8 +7,8 @@ 8da26cd1-1302-4cfd-9270-9fa1b7c6138b - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj index d596a5bb47..59bcbc9c4a 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj @@ -7,8 +7,8 @@ 7af5ad96-eb6e-4d0e-8abe-c0b543c0f4c2 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj index cf42659a08..06582d576f 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj @@ -7,8 +7,8 @@ 1790e052-646f-4529-b90e-6fea95520d69 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj index 96d5b6c5a0..d7f7c9d958 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj @@ -7,8 +7,8 @@ a2b5dc39-68d5-4145-a8cc-6aeab7d33a24 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 From 61d03b9316bc81d24f9e0f561a26e4eea064bb6a Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 11 Jul 2016 11:46:33 -0700 Subject: [PATCH 568/900] Update OIDC Azure Sample 1. Add set up instructions. 2. Add user secret tools. 3. Clean up codes. --- .../OpenIdConnect.AzureAdSample/Program.cs | 1 - samples/OpenIdConnect.AzureAdSample/Readme.md | 20 +++++++++++++++++++ .../OpenIdConnect.AzureAdSample/Startup.cs | 3 +-- .../OpenIdConnect.AzureAdSample/project.json | 5 +++-- 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 samples/OpenIdConnect.AzureAdSample/Readme.md diff --git a/samples/OpenIdConnect.AzureAdSample/Program.cs b/samples/OpenIdConnect.AzureAdSample/Program.cs index 254668022d..11d1fbeafb 100644 --- a/samples/OpenIdConnect.AzureAdSample/Program.cs +++ b/samples/OpenIdConnect.AzureAdSample/Program.cs @@ -1,6 +1,5 @@ using System.IO; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; namespace OpenIdConnect.AzureAdSample { diff --git a/samples/OpenIdConnect.AzureAdSample/Readme.md b/samples/OpenIdConnect.AzureAdSample/Readme.md new file mode 100644 index 0000000000..37dda75a72 --- /dev/null +++ b/samples/OpenIdConnect.AzureAdSample/Readme.md @@ -0,0 +1,20 @@ +# How to set up the sample locally + +## Set up [Azure Active Directory](https://azure.microsoft.com/en-us/documentation/services/active-directory/) + +1. Create your own Azure Active Directory (AD). Save the "tenent name". +2. Add a new Application: in the Azure AD portal, select Application, and click Add in the drawer. +3. Set the sign-on url to `http://localhost:42023`. +4. Select the newly created Application, navigate to the Configure tab. +5. Find and save the "Client Id" +8. In the keys section add a new key. A key value will be generated. Save the value as "Client Secret" + +## Configure the local environment +1. Set environment ASPNETCORE_ENVIRONMENT to DEVELOPMENMT. ([Working with Multiple Environments](https://docs.asp.net/en/latest/fundamentals/environments.html)) +2. Set up user secrets: +``` +dotnet user-secrets set oidc:clientid +dotnet user-secrets set oidc:clientsecret +dotnet user-secrets set oidc:authority https://login.windows.net/.onmicrosoft.com +``` + diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index f27a524928..8a2b7f4412 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Extensions; -using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -88,7 +87,7 @@ namespace OpenIdConnect.AzureAdSample { var request = context.HttpContext.Request; var currentUri = UriHelper.BuildAbsolute(request.Scheme, request.Host, request.PathBase, request.Path); - var credential = new ClientCredential(clientId, clientSecret); + var credential = new ClientCredential(clientId, clientSecret); var authContext = new AuthenticationContext(authority, AuthPropertiesTokenCache.ForCodeRedemption(context.Properties)); var result = await authContext.AcquireTokenByAuthorizationCodeAsync( diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index adb6a845a0..6aee5073f2 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -31,9 +31,10 @@ }, "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318", "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*", + "Microsoft.Extensions.SecretManager.Tools": "1.0.0-*" }, "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" } -} \ No newline at end of file +} From 6cee57752f81f2e5989d03c0daa5957f0d127cd6 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 11 Jul 2016 15:35:38 -0700 Subject: [PATCH 569/900] Update OpenIdConnectSample 1. Add instruction for OpenIdConnectSample 2. Clear unused using statements 3. Hardcoded server URL in `Program.cs` --- samples/OpenIdConnectSample/Program.cs | 1 + samples/OpenIdConnectSample/Readme.md | 44 ++++++++++++++++++++++++ samples/OpenIdConnectSample/Startup.cs | 3 ++ samples/OpenIdConnectSample/project.json | 5 +-- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 samples/OpenIdConnectSample/Readme.md diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs index fe77dd1a7c..b370c85a9e 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -17,6 +17,7 @@ namespace OpenIdConnectSample var serverCertificate = LoadCertificate(); options.UseHttps(serverCertificate); }) + .UseUrls("https://localhost:44318") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/samples/OpenIdConnectSample/Readme.md b/samples/OpenIdConnectSample/Readme.md new file mode 100644 index 0000000000..293820759d --- /dev/null +++ b/samples/OpenIdConnectSample/Readme.md @@ -0,0 +1,44 @@ +# How to set up the sample locally + +The OpenIdConnect sample supports multilpe authentication providers. In these instruction, we will explore how to set up this sample with both Azure Active Directory and Google Identity Platform + +## Determine your development environment and a few key variables + +This sample is configured to run on port __44318__ locally. In Visual Studio, the setting is carried out in `.\properties\launchSettings.json`. When the application is run from command line, the URL is coded in `Program.cs`. + +If the application is run from command line or terminal, environment variable ASPNETCORE_ENVIRONMENT should be set to DEVELOPMENT to enable user secret. + +## Configure the Authorization server + +### Configure with Azure Active Directory + +1. Set up a new Azure Active Directory (AAD) in your Azure Subscription. +2. Open the newly created AAD in Azure web portal +3. Navigate to the Applications tab +4. Add a new Application to the AAD. Set the "Sign-on URL" to sample application's URL. +5. Naigate to the Application, and click the Configure tab. +6. Find and save the "Client Id". +7. Add a new key in the "Keys" section. Save value of the key, which is the "Client Secret". +8. Click the "View Endpoints" on the drawer, a dialog will shows six endpoint URLs. Copy the "OAuth 2.0 Authorization Endpoint" to a text editor and remove the "/oauth2/authorize" from the string. The remaining part is the __authority URL__. It looks like __https://login.microsoftonline.com/__ + +### Configure with Google Identity Platform + +1. Create a new project through [Google APIs](console.developers.google.com) +2. In the sidebar choose "Credentials" +3. Navigate to "OAuth consent screen" tab, fill in the project name and save. +4. Navigate to "Credentials" tab. Click "Create credentials". Choose "OAuth client ID". +5. Select "Web application" as the application type. Fill in the "Authorized redirect URIs" with __https://localhost:44318/signin-oidc__ +6. Save the "Client ID" and "Client Secret" shown in the dialog. +7. Save the "Authority URL" for Google Authentication is __https://accounts.google.com/ + +## Configure the sample application + +1. Restore the application. +2. Set user secrets + +``` +dotnet user-secrets set oidc:clientid +dotnet user-secrets set oidc:clientsecret +dotnet user-secrets set oidc:authority +``` + diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 3a39919032..32d4739d19 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -86,6 +86,7 @@ namespace OpenIdConnectSample await context.Response.WriteAsync($""); return; } + if (context.Request.Path.Equals("/signout")) { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); @@ -95,6 +96,7 @@ namespace OpenIdConnectSample await context.Response.WriteAsync($""); return; } + if (context.Request.Path.Equals("/signout-remote")) { // Redirects @@ -105,6 +107,7 @@ namespace OpenIdConnectSample }); return; } + if (context.Request.Path.Equals("/Account/AccessDenied")) { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 6a24f3da60..a6a16a29fc 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -33,9 +33,10 @@ }, "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318", "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*", + "Microsoft.Extensions.SecretManager.Tools": "1.0.0-*" }, "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" } -} \ No newline at end of file +} From 5637e0c917d11ed0d2949ac146f641e5e43ebfc5 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 11 Jul 2016 22:51:41 -0700 Subject: [PATCH 570/900] Remove unused using statements --- samples/CookieSample/Program.cs | 1 - .../Events/EventResultState.cs | 2 -- .../Properties/Resources.Designer.cs | 1 - .../SharedAuthenticationOptions.cs | 3 --- src/Microsoft.AspNetCore.Authentication/Win32.cs | 1 - 5 files changed, 8 deletions(-) diff --git a/samples/CookieSample/Program.cs b/samples/CookieSample/Program.cs index df74352e7c..7deed359e1 100644 --- a/samples/CookieSample/Program.cs +++ b/samples/CookieSample/Program.cs @@ -1,6 +1,5 @@ using System.IO; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; namespace CookieSample { diff --git a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs b/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs index 80a6f949ab..b11dec93f1 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs @@ -1,8 +1,6 @@ // 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.AspNetCore.Authentication { public enum EventResultState diff --git a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs index 29dd7c67e2..a6cf910462 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs @@ -1,7 +1,6 @@ // namespace Microsoft.AspNetCore.Authentication { - using System.Globalization; using System.Reflection; using System.Resources; diff --git a/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs index bf30cae9e3..8b168c9a0a 100644 --- a/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs @@ -1,9 +1,6 @@ // 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.AspNetCore.Authentication { public class SharedAuthenticationOptions diff --git a/src/Microsoft.AspNetCore.Authentication/Win32.cs b/src/Microsoft.AspNetCore.Authentication/Win32.cs index 0e757e42a6..8752c3b734 100644 --- a/src/Microsoft.AspNetCore.Authentication/Win32.cs +++ b/src/Microsoft.AspNetCore.Authentication/Win32.cs @@ -3,7 +3,6 @@ using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace Microsoft.Win32 From 4927ad6b7413c5ef6d91fb264c00e350e3a15a8b Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 14 Jul 2016 16:24:33 -0700 Subject: [PATCH 571/900] Remove win32.cs --- .../Win32.cs | 96 ------------------- 1 file changed, 96 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication/Win32.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Win32.cs b/src/Microsoft.AspNetCore.Authentication/Win32.cs deleted file mode 100644 index 8752c3b734..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/Win32.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - - -using System; -using System.Runtime.InteropServices; - -namespace Microsoft.Win32 -{ - // TODO: ? [Localizable(false)] - internal static class NativeMethods - { - // ReSharper disable InconsistentNaming - public const int X509_ASN_ENCODING = 0x00000001; - public const int X509_PUBLIC_KEY_INFO = 8; - // ReSharper restore InconsistentNaming - - /// - /// Encodes a structure of the type indicated by the value of the lpszStructType parameter. - /// - /// Type of encoding used. - /// The high-order word is zero, the low-order word specifies the integer identifier for the type of the specified structure so - /// we can use the constants in http://msdn.microsoft.com/en-us/library/windows/desktop/aa378145%28v=vs.85%29.aspx - /// A pointer to the structure to be encoded. - /// A pointer to a buffer to receive the encoded structure. This parameter can be NULL to retrieve the size of this information for memory allocation purposes. - /// A pointer to a DWORD variable that contains the size, in bytes, of the buffer pointed to by the pbEncoded parameter. - /// - [DllImport("crypt32.dll", CharSet = CharSet.Ansi, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CryptEncodeObject( - UInt32 dwCertEncodingType, - IntPtr lpszStructType, - ref CERT_PUBLIC_KEY_INFO pvStructInfo, - byte[] pbEncoded, - ref UInt32 pcbEncoded); - - // ReSharper disable InconsistentNaming - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct CRYPT_BLOB - { - public Int32 cbData; - public IntPtr pbData; - } - - [StructLayout(LayoutKind.Sequential)] - internal struct CERT_CONTEXT - { - public Int32 dwCertEncodingType; - public IntPtr pbCertEncoded; - public Int32 cbCertEncoded; - public IntPtr pCertInfo; - public IntPtr hCertStore; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - internal struct CRYPT_ALGORITHM_IDENTIFIER - { - public string pszObjId; - public CRYPT_BLOB Parameters; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - internal struct CRYPT_BIT_BLOB - { - public Int32 cbData; - public IntPtr pbData; - public Int32 cUnusedBits; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct CERT_PUBLIC_KEY_INFO - { - public CRYPT_ALGORITHM_IDENTIFIER Algorithm; - public CRYPT_BIT_BLOB PublicKey; - } - - [StructLayout(LayoutKind.Sequential)] - internal class CERT_INFO - { - public Int32 dwVersion; - public CRYPT_BLOB SerialNumber; - public CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm; - public CRYPT_BLOB Issuer; - public System.Runtime.InteropServices.ComTypes.FILETIME NotBefore; - public System.Runtime.InteropServices.ComTypes.FILETIME NotAfter; - public CRYPT_BLOB Subject; - public CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo; - public CRYPT_BIT_BLOB IssuerUniqueId; - public CRYPT_BIT_BLOB SubjectUniqueId; - public Int32 cExtension; - public IntPtr rgExtension; - } - - // ReSharper restore InconsistentNaming - } -} From 6cd46a5c10094ba9f4379fbccc3b9c05a01bf034 Mon Sep 17 00:00:00 2001 From: Derek Date: Tue, 19 Jul 2016 17:18:42 -0500 Subject: [PATCH 572/900] Remote auth expiration fix (#893) Remote auth expiration fix, and move ISystemClock to the base AuthenticationProperties --- .../CookieAuthenticationOptions.cs | 6 ------ .../JwtBearerOptions.cs | 6 ------ .../OAuthHandler.cs | 5 +---- .../OAuthOptions.cs | 6 ------ .../OpenIdConnectHandler.cs | 5 +---- .../OpenIdConnectOptions.cs | 6 ------ .../TwitterHandler.cs | 8 +++----- .../TwitterOptions.cs | 6 ------ .../AuthenticationOptions.cs | 8 ++++++++ .../RemoteAuthenticationHandler.cs | 2 +- 10 files changed, 14 insertions(+), 44 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index f9455f23a5..b425612508 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -138,12 +138,6 @@ namespace Microsoft.AspNetCore.Builder /// public ISecureDataFormat TicketDataFormat { get; set; } - /// - /// For testing purposes only. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public ISystemClock SystemClock { get; set; } - /// /// The component used to get cookies from the request or set them on the response. /// diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs index 1d73b843ee..2aedf30d52 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -95,12 +95,6 @@ namespace Microsoft.AspNetCore.Builder /// public bool RefreshOnIssuerKeyNotFound { get; set; } = true; - /// - /// For testing purposes only. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public ISystemClock SystemClock { get; set; } = new SystemClock(); - /// /// Gets the ordered list of used to validate access tokens. /// diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index ddd26d9f01..12b85ae7e6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -175,10 +175,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth throw new ArgumentNullException(nameof(context)); } - var properties = new AuthenticationProperties(context.Properties) - { - ExpiresUtc = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout) - }; + var properties = new AuthenticationProperties(context.Properties); if (string.IsNullOrEmpty(properties.RedirectUri)) { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs index 57ecba2f48..9591d9c44d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -64,11 +64,5 @@ namespace Microsoft.AspNetCore.Builder /// Gets or sets the type used to secure data handled by the middleware. /// public ISecureDataFormat StateDataFormat { get; set; } - - /// - /// For testing purposes only. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public ISystemClock SystemClock { get; set; } = new SystemClock(); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 6488d10d72..df7caf3317 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -259,10 +259,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // order for local RedirectUri // 1. challenge.Properties.RedirectUri // 2. CurrentUri if RedirectUri is not set) - var properties = new AuthenticationProperties(context.Properties) - { - ExpiresUtc = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout) - }; + var properties = new AuthenticationProperties(context.Properties); if (string.IsNullOrEmpty(properties.RedirectUri)) { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index b5f6c03daa..181444b055 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -202,11 +202,5 @@ namespace Microsoft.AspNetCore.Builder /// This is disabled by default. /// public bool SkipUnrecognizedRequests { get; set; } = false; - - /// - /// For testing purposes only. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public ISystemClock SystemClock { get; set; } = new SystemClock(); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 4fbf35aaa1..20d06beafc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -131,10 +131,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter throw new ArgumentNullException(nameof(context)); } - var properties = new AuthenticationProperties(context.Properties) - { - ExpiresUtc = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout) - }; + var properties = new AuthenticationProperties(context.Properties); if (string.IsNullOrEmpty(properties.RedirectUri)) { @@ -148,7 +145,8 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var cookieOptions = new CookieOptions { HttpOnly = true, - Secure = Request.IsHttps + Secure = Request.IsHttps, + Expires = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 8ab399a8f9..bf54b7fbb9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -59,11 +59,5 @@ namespace Microsoft.AspNetCore.Builder get { return (ITwitterEvents)base.Events; } set { base.Events = value; } } - - /// - /// For testing purposes only. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public ISystemClock SystemClock { get; set; } = new SystemClock(); } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs index 04d050b06e..34ec577f18 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs @@ -1,7 +1,9 @@ // 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.AspNetCore.Authentication; using Microsoft.AspNetCore.Http.Authentication; +using System.ComponentModel; namespace Microsoft.AspNetCore.Builder { @@ -47,5 +49,11 @@ namespace Microsoft.AspNetCore.Builder /// Additional information about the authentication type which is made available to the application. /// public AuthenticationDescription Description { get; set; } = new AuthenticationDescription(); + + /// + /// For testing purposes only. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ISystemClock SystemClock { get; set; } = new SystemClock(); } } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index f1ad0d0559..72a4fe5900 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -149,7 +149,7 @@ namespace Microsoft.AspNetCore.Authentication { HttpOnly = true, Secure = Request.IsHttps, - Expires = properties.ExpiresUtc + Expires = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; properties.Items[CorrelationProperty] = correlationId; From a1f82783819fe06485c7b31b7f24b83b364a8385 Mon Sep 17 00:00:00 2001 From: Petr Onderka Date: Wed, 20 Jul 2016 19:35:12 +0200 Subject: [PATCH 573/900] Improve sample README * fixed broken link * improved formatting * added missing full stops --- samples/OpenIdConnectSample/Readme.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/OpenIdConnectSample/Readme.md b/samples/OpenIdConnectSample/Readme.md index 293820759d..846e3f8e6a 100644 --- a/samples/OpenIdConnectSample/Readme.md +++ b/samples/OpenIdConnectSample/Readme.md @@ -1,6 +1,6 @@ # How to set up the sample locally -The OpenIdConnect sample supports multilpe authentication providers. In these instruction, we will explore how to set up this sample with both Azure Active Directory and Google Identity Platform +The OpenIdConnect sample supports multilpe authentication providers. In these instruction, we will explore how to set up this sample with both Azure Active Directory and Google Identity Platform. ## Determine your development environment and a few key variables @@ -13,30 +13,30 @@ If the application is run from command line or terminal, environment variable AS ### Configure with Azure Active Directory 1. Set up a new Azure Active Directory (AAD) in your Azure Subscription. -2. Open the newly created AAD in Azure web portal -3. Navigate to the Applications tab +2. Open the newly created AAD in Azure web portal. +3. Navigate to the Applications tab. 4. Add a new Application to the AAD. Set the "Sign-on URL" to sample application's URL. 5. Naigate to the Application, and click the Configure tab. 6. Find and save the "Client Id". 7. Add a new key in the "Keys" section. Save value of the key, which is the "Client Secret". -8. Click the "View Endpoints" on the drawer, a dialog will shows six endpoint URLs. Copy the "OAuth 2.0 Authorization Endpoint" to a text editor and remove the "/oauth2/authorize" from the string. The remaining part is the __authority URL__. It looks like __https://login.microsoftonline.com/__ +8. Click the "View Endpoints" on the drawer, a dialog will shows six endpoint URLs. Copy the "OAuth 2.0 Authorization Endpoint" to a text editor and remove the "/oauth2/authorize" from the string. The remaining part is the __authority URL__. It looks like `https://login.microsoftonline.com/`. ### Configure with Google Identity Platform -1. Create a new project through [Google APIs](console.developers.google.com) -2. In the sidebar choose "Credentials" +1. Create a new project through [Google APIs](https://console.developers.google.com). +2. In the sidebar choose "Credentials". 3. Navigate to "OAuth consent screen" tab, fill in the project name and save. 4. Navigate to "Credentials" tab. Click "Create credentials". Choose "OAuth client ID". -5. Select "Web application" as the application type. Fill in the "Authorized redirect URIs" with __https://localhost:44318/signin-oidc__ +5. Select "Web application" as the application type. Fill in the "Authorized redirect URIs" with `https://localhost:44318/signin-oidc`. 6. Save the "Client ID" and "Client Secret" shown in the dialog. -7. Save the "Authority URL" for Google Authentication is __https://accounts.google.com/ +7. The "Authority URL" for Google Authentication is `https://accounts.google.com/`. ## Configure the sample application 1. Restore the application. -2. Set user secrets +2. Set user secrets: -``` + ``` dotnet user-secrets set oidc:clientid dotnet user-secrets set oidc:clientsecret dotnet user-secrets set oidc:authority From 651815c282bfc594762346f4445afd9e6b48bb1e Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 25 Jul 2016 16:31:27 -0700 Subject: [PATCH 574/900] Remove OfType allocations (#906) --- .../AuthorizationPolicy.cs | 12 ++++++------ .../DefaultAuthorizationPolicyProvider.cs | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs index 3fe0cdd070..5cba0fd9e3 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -122,28 +122,28 @@ namespace Microsoft.AspNetCore.Authorization var policyBuilder = new AuthorizationPolicyBuilder(); var any = false; - foreach (var authorizeAttribute in authorizeData.OfType()) + foreach (var authorizeDatum in authorizeData) { any = true; var useDefaultPolicy = true; - if (!string.IsNullOrWhiteSpace(authorizeAttribute.Policy)) + if (!string.IsNullOrWhiteSpace(authorizeDatum.Policy)) { - var policy = await policyProvider.GetPolicyAsync(authorizeAttribute.Policy); + var policy = await policyProvider.GetPolicyAsync(authorizeDatum.Policy); if (policy == null) { - throw new InvalidOperationException(Resources.FormatException_AuthorizationPolicyNotFound(authorizeAttribute.Policy)); + throw new InvalidOperationException(Resources.FormatException_AuthorizationPolicyNotFound(authorizeDatum.Policy)); } policyBuilder.Combine(policy); useDefaultPolicy = false; } - var rolesSplit = authorizeAttribute.Roles?.Split(','); + var rolesSplit = authorizeDatum.Roles?.Split(','); if (rolesSplit != null && rolesSplit.Any()) { var trimmedRolesSplit = rolesSplit.Where(r => !string.IsNullOrWhiteSpace(r)).Select(r => r.Trim()); policyBuilder.RequireRole(trimmedRolesSplit); useDefaultPolicy = false; } - var authTypesSplit = authorizeAttribute.ActiveAuthenticationSchemes?.Split(','); + var authTypesSplit = authorizeDatum.ActiveAuthenticationSchemes?.Split(','); if (authTypesSplit != null && authTypesSplit.Any()) { foreach (var authType in authTypesSplit) diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs index 2c9ea19b5c..6fb8bd68dc 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -45,6 +45,7 @@ namespace Microsoft.AspNetCore.Authorization /// The named . public virtual Task GetPolicyAsync(string policyName) { + // MVC relies on DefaultAuthorizationPolicyProvider providing the same policy for the same requests. return Task.FromResult(_options.GetPolicy(policyName)); } } From 7b7da43fd819830151aa70b9e4dc951d835d19de Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 25 Jul 2016 20:33:12 -0700 Subject: [PATCH 575/900] Update comments in RemoteAuthenticationOptions --- .../RemoteAuthenticationOptions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index a78c14bbec..e990abd05a 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Builder public class RemoteAuthenticationOptions : AuthenticationOptions { /// - /// Gets or sets timeout value in milliseconds for back channel communications with the remote provider. + /// Gets or sets timeout value in milliseconds for back channel communications with the remote identity provider. /// /// /// The back channel timeout. @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Builder public TimeSpan BackchannelTimeout { get; set; } = TimeSpan.FromSeconds(60); /// - /// The HttpMessageHandler used to communicate with Twitter. + /// The HttpMessageHandler used to communicate with remote identity provider. /// This cannot be set at the same time as BackchannelCertificateValidator unless the value /// can be downcast to a WebRequestHandler. /// @@ -66,4 +66,4 @@ namespace Microsoft.AspNetCore.Builder /// public bool SaveTokens { get; set; } } -} \ No newline at end of file +} From eabdd4581604d4e0f8d668c30bd5aa5e92e78a8f Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 25 Jul 2016 22:28:26 -0700 Subject: [PATCH 576/900] Improve code readability for Authentication.Google --- .../GoogleAppBuilderExtensions.cs | 7 +++++-- .../GoogleDefaults.cs | 5 ++++- .../GoogleHandler.cs | 15 +++++++++++---- .../GoogleHelper.cs | 1 - .../GoogleMiddleware.cs | 5 ++++- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs index fe693a61b7..85a193d82b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -13,7 +13,8 @@ namespace Microsoft.AspNetCore.Builder public static class GoogleAppBuilderExtensions { /// - /// Adds the middleware to the specified , which enables Google authentication capabilities. + /// Adds the middleware to the specified , + /// which enables Google authentication capabilities. /// /// The to add the middleware to. /// A reference to this instance after the operation has completed. @@ -28,7 +29,8 @@ namespace Microsoft.AspNetCore.Builder } /// - /// Adds the middleware to the specified , which enables Google authentication capabilities. + /// Adds the middleware to the specified , + /// which enables Google authentication capabilities. /// /// The to add the middleware to. /// A that specifies options for the middleware. @@ -39,6 +41,7 @@ namespace Microsoft.AspNetCore.Builder { throw new ArgumentNullException(nameof(app)); } + if (options == null) { throw new ArgumentNullException(nameof(options)); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs index c17ff6b2ab..ef6fae9bc1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -3,9 +3,12 @@ namespace Microsoft.AspNetCore.Authentication.Google { + /// + /// Default values for Google authentication + /// public static class GoogleDefaults { - public const string AuthenticationScheme = "Google"; + public static readonly string AuthenticationScheme = "Google"; public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/auth"; diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index affde917aa..6e3ee36939 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -22,7 +22,10 @@ namespace Microsoft.AspNetCore.Authentication.Google { } - protected override async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) + protected override async Task CreateTicketAsync( + ClaimsIdentity identity, + AuthenticationProperties properties, + OAuthTokenResponse tokens) { // Get the Google user var request = new HttpRequestMessage(HttpMethod.Get, Options.UserInformationEndpoint); @@ -33,7 +36,8 @@ namespace Microsoft.AspNetCore.Authentication.Google var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Options.AuthenticationScheme); + var principal = new ClaimsPrincipal(identity); + var ticket = new AuthenticationTicket(principal, properties, Options.AuthenticationScheme); var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens, payload); var identifier = GoogleHelper.GetId(payload); @@ -100,8 +104,11 @@ namespace Microsoft.AspNetCore.Authentication.Google return authorizationEndpoint; } - private static void AddQueryString(IDictionary queryStrings, AuthenticationProperties properties, - string name, string defaultValue = null) + private static void AddQueryString( + IDictionary queryStrings, + AuthenticationProperties properties, + string name, + string defaultValue = null) { string value; if (!properties.Items.TryGetValue(name, out value)) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs index 0a763d5696..336536c512 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Extensions.Internal; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.Google diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs index eb98e447b3..5f8afaff2f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs @@ -69,7 +69,10 @@ namespace Microsoft.AspNetCore.Authentication.Google /// /// Provides the object for processing authentication-related requests. /// - /// An configured with the supplied to the constructor. + /// + /// An configured with the + /// supplied to the constructor. + /// protected override AuthenticationHandler CreateHandler() { return new GoogleHandler(Backchannel); From ecb3b909846c1ab14e60e7f8463e6c54c8eb419b Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 26 Jul 2016 09:19:42 -0700 Subject: [PATCH 577/900] Undo change to the GoogleDefaults --- .../GoogleDefaults.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs index ef6fae9bc1..77d68aed93 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Authentication.Google /// public static class GoogleDefaults { - public static readonly string AuthenticationScheme = "Google"; + public const string AuthenticationScheme = "Google"; public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/auth"; From 312edaafb4f7d4a189b376c3c380b620aa063b8d Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Wed, 20 Jul 2016 16:15:58 -0700 Subject: [PATCH 578/900] Handle back channel failure gracefully 1. Check the response states code. If it is out of 2XX range, compose a readable message and throw in an exception. 2. Capture the exception in HandleRemoteAuthenticateAsync and translate it into AuthenticateResult. --- .../FacebookHandler.cs | 9 +++++++-- .../GoogleHandler.cs | 6 +++++- .../MicrosoftAccountHandler.cs | 7 ++++++- .../OAuthHandler.cs | 10 +++++++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 675ae51494..0df42597dd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.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.Globalization; using System.Net.Http; using System.Security.Claims; @@ -35,7 +36,11 @@ namespace Microsoft.AspNetCore.Authentication.Facebook } var response = await Backchannel.GetAsync(endpoint, Context.RequestAborted); - response.EnsureSuccessStatusCode(); + if (!response.IsSuccessStatusCode) + { + var errorMessage = $"Failed to retrived Facebook user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Google API is enabled."; + throw new InvalidOperationException(errorMessage); + } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); @@ -119,7 +124,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { identity.AddClaim(new Claim(ClaimTypes.Name, name, ClaimValueTypes.String, Options.ClaimsIssuer)); } - + var timeZone = FacebookHelper.GetTimeZone(payload); if (!string.IsNullOrEmpty(timeZone)) { diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 6e3ee36939..4a81744b05 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -32,7 +32,11 @@ namespace Microsoft.AspNetCore.Authentication.Google request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken); var response = await Backchannel.SendAsync(request, Context.RequestAborted); - response.EnsureSuccessStatusCode(); + if (!response.IsSuccessStatusCode) + { + var errorMessage = $"Failed to retrived Google user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Google API is enabled."; + throw new InvalidOperationException(errorMessage); + } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 8b9177625c..18f5df9d4a 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.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.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; @@ -25,7 +26,11 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken); var response = await Backchannel.SendAsync(request, Context.RequestAborted); - response.EnsureSuccessStatusCode(); + if (!response.IsSuccessStatusCode) + { + var errorMessage = $"Failed to retrived Microsoft user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Google API is enabled."; + throw new InvalidOperationException(errorMessage); + } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 12b85ae7e6..29d46367db 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -119,7 +119,15 @@ namespace Microsoft.AspNetCore.Authentication.OAuth properties.StoreTokens(authTokens); } - return AuthenticateResult.Success(await CreateTicketAsync(identity, properties, tokens)); + try + { + var ticket = await CreateTicketAsync(identity, properties, tokens); + return AuthenticateResult.Success(ticket); + } + catch (Exception ex) + { + return AuthenticateResult.Fail(ex); + } } protected virtual async Task ExchangeCodeAsync(string code, string redirectUri) From 988bcc81ee88f4decef967047e58e0c2b842e6be Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Wed, 20 Jul 2016 16:36:33 -0700 Subject: [PATCH 579/900] Update comments for HandleRemoteAuthenticateAsync method --- .../RemoteAuthenticationHandler.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 72a4fe5900..5891a005d3 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -87,6 +87,12 @@ namespace Microsoft.AspNetCore.Authentication return true; } + /// + /// Authenticate the user identity with the identity provider. + /// + /// This could be done through a back channel communication with the identity provider. Exception thrown during + /// the authenticating should be saved to the AuthenticateResult. + /// protected abstract Task HandleRemoteAuthenticateAsync(); protected override async Task HandleAuthenticateAsync() From 5de4816f59a87d00436bf386b23d9ff10e9f6bf6 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 25 Jul 2016 22:02:42 -0700 Subject: [PATCH 580/900] Update the RemoteAuthenticationHandler error handling 1. Exeption will be still thrown from CreateTicketAsync to avoid breaking change. 2. OAuthHandler won't try to capture the exception. 3. OAuthHandler will check if the AuthenticateTicket is null. 4. RemoteAuthenticationHandler's error handling flow is improved to cover the exception thrown from HandleRemoteAuthenticateAsync. The exeption thrown from it will go throw the user error handling logic, too. --- .../FacebookHandler.cs | 3 +- .../GoogleHandler.cs | 3 +- .../MicrosoftAccountHandler.cs | 3 +- .../OAuthHandler.cs | 9 ++-- .../RemoteAuthenticationHandler.cs | 42 +++++++++++++++---- 5 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 0df42597dd..4deec4df7d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -38,8 +38,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var response = await Backchannel.GetAsync(endpoint, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - var errorMessage = $"Failed to retrived Facebook user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Google API is enabled."; - throw new InvalidOperationException(errorMessage); + throw new HttpRequestException($"Failed to retrived Facebook user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Facebook API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 4a81744b05..b9a24f58c2 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -34,8 +34,7 @@ namespace Microsoft.AspNetCore.Authentication.Google var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - var errorMessage = $"Failed to retrived Google user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Google API is enabled."; - throw new InvalidOperationException(errorMessage); + throw new HttpRequestException($"An error occurred when retrieving user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Google API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 18f5df9d4a..ad4ceb81f7 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -28,8 +28,7 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - var errorMessage = $"Failed to retrived Microsoft user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Google API is enabled."; - throw new InvalidOperationException(errorMessage); + throw new HttpRequestException($"Failed to retrived Microsoft user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Microsoft API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 29d46367db..353b2b5847 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; +using System.Threading; namespace Microsoft.AspNetCore.Authentication.OAuth { @@ -119,14 +120,14 @@ namespace Microsoft.AspNetCore.Authentication.OAuth properties.StoreTokens(authTokens); } - try + var ticket = await CreateTicketAsync(identity, properties, tokens); + if (ticket != null) { - var ticket = await CreateTicketAsync(identity, properties, tokens); return AuthenticateResult.Success(ticket); } - catch (Exception ex) + else { - return AuthenticateResult.Fail(ex); + return AuthenticateResult.Fail("Failed to retrieve user information from remote server."); } } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 5891a005d3..f152ff1cfb 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.Extensions.Logging; +using System.Net.Http; namespace Microsoft.AspNetCore.Authentication { @@ -31,26 +32,49 @@ namespace Microsoft.AspNetCore.Authentication protected virtual async Task HandleRemoteCallbackAsync() { - var authResult = await HandleRemoteAuthenticateAsync(); - if (authResult != null && authResult.Skipped) + AuthenticateResult authResult = null; + Exception exception = null; + + try { - return false; + authResult = await HandleRemoteAuthenticateAsync(); + if (authResult != null && authResult.Skipped == true) + { + return false; + } + else if (authResult == null) + { + exception = new InvalidOperationException("Invalide return state, unable to redirect."); + } + else if (!authResult.Succeeded) + { + exception = authResult?.Failure ?? + new InvalidOperationException("Invalide return state, unable to redirect."); + } } - if (authResult == null || !authResult.Succeeded) + catch (Exception ex) { - var errorContext = new FailureContext(Context, authResult?.Failure ?? new Exception("Invalid return state, unable to redirect.")); - Logger.RemoteAuthenticationError(errorContext.Failure.Message); + exception = ex; + } + + if (exception != null) + { + Logger.RemoteAuthenticationError(exception.Message); + var errorContext = new FailureContext(Context, exception); await Options.Events.RemoteFailure(errorContext); + if (errorContext.HandledResponse) { return true; } - if (errorContext.Skipped) + else if (errorContext.Skipped) { return false; } - - throw new AggregateException("Unhandled remote failure.", errorContext.Failure); + else + { + throw new AggregateException("Unhandled remote failure.", exception); + } } // We have a ticket if we get here From cd9e9fa498188d110cd548775e6d50fae5e643da Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 25 Jul 2016 22:06:44 -0700 Subject: [PATCH 581/900] Update comment on HandleRemoteAuthenticateAsync --- .../RemoteAuthenticationHandler.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index f152ff1cfb..b1e2aa1c82 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -114,8 +114,7 @@ namespace Microsoft.AspNetCore.Authentication /// /// Authenticate the user identity with the identity provider. /// - /// This could be done through a back channel communication with the identity provider. Exception thrown during - /// the authenticating should be saved to the AuthenticateResult. + /// This could be done through a back channel communication with the identity provider. /// protected abstract Task HandleRemoteAuthenticateAsync(); From 5211f22f44bec19ba76a86294f335d7926309e43 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 26 Jul 2016 09:00:35 -0700 Subject: [PATCH 582/900] Update comment on HandleRemoteAuthenticateAsync --- .../RemoteAuthenticationHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index b1e2aa1c82..895a954dac 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -112,9 +112,9 @@ namespace Microsoft.AspNetCore.Authentication } /// - /// Authenticate the user identity with the identity provider. + /// Authenticate the user identity with the identity provider. /// - /// This could be done through a back channel communication with the identity provider. + /// The method process the request on the endpoint defined by CallbackPath. /// protected abstract Task HandleRemoteAuthenticateAsync(); From 6f46bc94f868f711ba8c499d5007e1df57cacf71 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 26 Jul 2016 09:02:06 -0700 Subject: [PATCH 583/900] Sort using statements --- src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs | 2 +- .../RemoteAuthenticationHandler.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 353b2b5847..b235d9358f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -8,6 +8,7 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; using System.Text; +using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http.Authentication; @@ -15,7 +16,6 @@ using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; -using System.Threading; namespace Microsoft.AspNetCore.Authentication.OAuth { diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 895a954dac..564064e409 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Net.Http; using System.Security.Cryptography; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; @@ -9,7 +10,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.Extensions.Logging; -using System.Net.Http; namespace Microsoft.AspNetCore.Authentication { From 210c4b2061267ab765fe5b0659f6691031258f04 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 26 Jul 2016 09:02:41 -0700 Subject: [PATCH 584/900] Fix incorrect exception messages --- .../RemoteAuthenticationHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 564064e409..65ad981a9c 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -44,12 +44,12 @@ namespace Microsoft.AspNetCore.Authentication } else if (authResult == null) { - exception = new InvalidOperationException("Invalide return state, unable to redirect."); + exception = new InvalidOperationException("Invalid return state, unable to redirect."); } else if (!authResult.Succeeded) { exception = authResult?.Failure ?? - new InvalidOperationException("Invalide return state, unable to redirect."); + new InvalidOperationException("Invalid return state, unable to redirect."); } } catch (Exception ex) From 1c17bddc0299251b92a24a9f2cd5a9bf829dde50 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 26 Jul 2016 09:09:58 -0700 Subject: [PATCH 585/900] Update HandleRemoteCallbackAsync readability --- .../OAuthHandler.cs | 1 - .../RemoteAuthenticationHandler.cs | 20 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index b235d9358f..dbfa1ef92b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -8,7 +8,6 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; using System.Text; -using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http.Authentication; diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 65ad981a9c..452a15a9dc 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Net.Http; using System.Security.Cryptography; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; @@ -32,17 +31,18 @@ namespace Microsoft.AspNetCore.Authentication protected virtual async Task HandleRemoteCallbackAsync() { - AuthenticateResult authResult = null; + AuthenticationTicket ticket = null; Exception exception = null; try { - authResult = await HandleRemoteAuthenticateAsync(); + var authResult = await HandleRemoteAuthenticateAsync(); if (authResult != null && authResult.Skipped == true) { return false; } - else if (authResult == null) + + if (authResult == null) { exception = new InvalidOperationException("Invalid return state, unable to redirect."); } @@ -51,6 +51,8 @@ namespace Microsoft.AspNetCore.Authentication exception = authResult?.Failure ?? new InvalidOperationException("Invalid return state, unable to redirect."); } + + ticket = authResult.Ticket; } catch (Exception ex) { @@ -67,18 +69,16 @@ namespace Microsoft.AspNetCore.Authentication { return true; } - else if (errorContext.Skipped) + + if (errorContext.Skipped) { return false; } - else - { - throw new AggregateException("Unhandled remote failure.", exception); - } + + throw new AggregateException("Unhandled remote failure.", exception); } // We have a ticket if we get here - var ticket = authResult.Ticket; var context = new TicketReceivedContext(Context, Options, ticket) { ReturnUri = ticket.Properties.RedirectUri, From 0d216d726a686cef8d84e0d83eb4a57dcdbb3b26 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 26 Jul 2016 13:58:07 -0700 Subject: [PATCH 586/900] Minor fixes in RemoteAuthenticationHandler and FacebookHandler --- .../FacebookHandler.cs | 2 +- .../RemoteAuthenticationHandler.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 4deec4df7d..29906e7e3f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var response = await Backchannel.GetAsync(endpoint, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - throw new HttpRequestException($"Failed to retrived Facebook user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Facebook API is enabled."); + throw new HttpRequestException($"Failed to retrived Facebook user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Facebook Graph API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 452a15a9dc..9d236decd9 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Authentication try { var authResult = await HandleRemoteAuthenticateAsync(); - if (authResult != null && authResult.Skipped == true) + if (authResult != null && authResult.Skipped) { return false; } From 0e855b25a8d7af1ef6df836f01e1a7fe92dc46a0 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 26 Jul 2016 14:16:16 -0700 Subject: [PATCH 587/900] Update Google and Microsoft Account Handler exception message --- .../GoogleHandler.cs | 4 ++-- .../MicrosoftAccountHandler.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index b9a24f58c2..68cc6054f1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Authentication.Google var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - throw new HttpRequestException($"An error occurred when retrieving user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Google API is enabled."); + throw new HttpRequestException($"An error occurred when retrieving user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Google+ API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); @@ -132,4 +132,4 @@ namespace Microsoft.AspNetCore.Authentication.Google queryStrings[name] = value; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index ad4ceb81f7..21f567d15e 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - throw new HttpRequestException($"Failed to retrived Microsoft user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Microsoft API is enabled."); + throw new HttpRequestException($"Failed to retrived Microsoft user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Microsoft Account API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); From 763df65c14081ac2efb5a5997f49217cf6ace501 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 26 Jul 2016 16:27:28 -0700 Subject: [PATCH 588/900] Revise if-else order in RemoteAuthenticateHandler --- .../RemoteAuthenticationHandler.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 9d236decd9..4dfcc3662c 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -37,18 +37,17 @@ namespace Microsoft.AspNetCore.Authentication try { var authResult = await HandleRemoteAuthenticateAsync(); - if (authResult != null && authResult.Skipped) - { - return false; - } - if (authResult == null) { exception = new InvalidOperationException("Invalid return state, unable to redirect."); } + else if (authResult.Skipped) + { + return false; + } else if (!authResult.Succeeded) { - exception = authResult?.Failure ?? + exception = authResult.Failure ?? new InvalidOperationException("Invalid return state, unable to redirect."); } From c16fc06cb9fd28c21556f83855498985739e41e8 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 28 Jul 2016 16:55:08 -0700 Subject: [PATCH 589/900] Modify warning about policy behavior (#924) --- .../DefaultAuthorizationPolicyProvider.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs index 6fb8bd68dc..0e4329dcc0 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -45,7 +45,9 @@ namespace Microsoft.AspNetCore.Authorization /// The named . public virtual Task GetPolicyAsync(string policyName) { - // MVC relies on DefaultAuthorizationPolicyProvider providing the same policy for the same requests. + // MVC caches policies specifically for this class, so this method MUST return the same policy per + // policyName for every request or it could allow undesired access. It also must return synchronously. + // A change to either of these behaviors would require shipping a patch of MVC as well. return Task.FromResult(_options.GetPolicy(policyName)); } } From 2a6ab2be8c195a67ecd58200c808cbf7f15f383c Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 29 Jul 2016 13:26:25 -0700 Subject: [PATCH 590/900] Add UpdateTokenValue API --- .../TokenExtensions.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs b/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs index 8065139baf..9f5c96cc11 100644 --- a/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs @@ -63,6 +63,26 @@ namespace Microsoft.AspNetCore.Authentication : null; } + public static bool UpdateTokenValue(this AuthenticationProperties properties, string tokenName, string tokenValue) + { + if (properties == null) + { + throw new ArgumentNullException(nameof(properties)); + } + if (tokenName == null) + { + throw new ArgumentNullException(nameof(tokenName)); + } + + var tokenKey = TokenKeyPrefix + tokenName; + if (!properties.Items.ContainsKey(tokenKey)) + { + return false; + } + properties.Items[tokenKey] = tokenValue; + return true; + } + public static IEnumerable GetTokens(this AuthenticationProperties properties) { if (properties == null) From 137e18f39d6f9e0932916fa9e3a8c296e8dd8978 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 29 Jul 2016 13:26:36 -0700 Subject: [PATCH 591/900] Add test --- .../TokenExtensionTests.cs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs index e8f2c16578..028cf67607 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -81,6 +81,51 @@ namespace Microsoft.AspNetCore.Authentication Assert.Equal(3, props.GetTokens().Count()); } + [Fact] + public void CanUpdateTokenValues() + { + var props = new AuthenticationProperties(); + var tokens = new List(); + var tok1 = new AuthenticationToken { Name = "One", Value = "1" }; + var tok2 = new AuthenticationToken { Name = "Two", Value = "2" }; + var tok3 = new AuthenticationToken { Name = "Three", Value = "3" }; + tokens.Add(tok1); + tokens.Add(tok2); + tokens.Add(tok3); + props.StoreTokens(tokens); + + Assert.True(props.UpdateTokenValue("One", ".11")); + Assert.True(props.UpdateTokenValue("Two", ".22")); + Assert.True(props.UpdateTokenValue("Three", ".33")); + + Assert.Equal(".11", props.GetTokenValue("One")); + Assert.Equal(".22", props.GetTokenValue("Two")); + Assert.Equal(".33", props.GetTokenValue("Three")); + Assert.Equal(3, props.GetTokens().Count()); + } + + [Fact] + public void UpdateTokenValueReturnsFalseForUnknownToken() + { + var props = new AuthenticationProperties(); + var tokens = new List(); + var tok1 = new AuthenticationToken { Name = "One", Value = "1" }; + var tok2 = new AuthenticationToken { Name = "Two", Value = "2" }; + var tok3 = new AuthenticationToken { Name = "Three", Value = "3" }; + tokens.Add(tok1); + tokens.Add(tok2); + tokens.Add(tok3); + props.StoreTokens(tokens); + + Assert.False(props.UpdateTokenValue("ONE", ".11")); + Assert.False(props.UpdateTokenValue("Jigglypuff", ".11")); + + Assert.Null(props.GetTokenValue("ONE")); + Assert.Null(props.GetTokenValue("Jigglypuff")); + Assert.Equal(3, props.GetTokens().Count()); + + } + public class TestAuthHandler : IAuthenticationHandler { private readonly AuthenticationProperties _props; From 882e790bff1d514dd16a8a5422be5323dc36d9b0 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Tue, 2 Aug 2016 13:05:55 -0700 Subject: [PATCH 592/900] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ceb3c7b67b..efc1a57214 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,6 @@ branches: - dev - /^(.*\/)?ci-.*$/ before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; brew link --force openssl; fi + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: - - ./build.sh verify \ No newline at end of file + - ./build.sh verify From 706566e2531245fdc2a2b8115373b66d5bf16799 Mon Sep 17 00:00:00 2001 From: Christian Weiss Date: Thu, 4 Aug 2016 18:02:09 +0200 Subject: [PATCH 593/900] Typo "Failed to retrived" -> "Failed to retrieve" --- .../FacebookHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 29906e7e3f..be1c8f8f83 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var response = await Backchannel.GetAsync(endpoint, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - throw new HttpRequestException($"Failed to retrived Facebook user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Facebook Graph API is enabled."); + throw new HttpRequestException($"Failed to retrieve Facebook user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Facebook Graph API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); @@ -157,4 +157,4 @@ namespace Microsoft.AspNetCore.Authentication.Facebook return string.Join(",", Options.Scope); } } -} \ No newline at end of file +} From 0314632696464efaa9d34d08233e0a292336361d Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 2 Aug 2016 11:56:31 -0700 Subject: [PATCH 594/900] JwtBearer Token: Catch exception during unauthorized flow --- .../CookieAuthenticationHandler.cs | 1 - .../JwtBearerHandler.cs | 4 +- .../AuthenticationHandler.cs | 32 +++++++++- .../JwtBearer/JwtBearerMiddlewareTests.cs | 59 +++++++++++++++++-- 4 files changed, 87 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index eecd03065a..302010429b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -323,7 +323,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies await Options.Events.RedirectToReturnUrl(redirectContext); } } - } private static bool IsHostRelative(string path) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 34b13562a5..ee5575251d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -185,11 +185,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { - var authResult = await HandleAuthenticateOnceAsync(); + var authResult = await HandleAuthenticateOnceSafeAsync(); var eventContext = new JwtBearerChallengeContext(Context, Options, new AuthenticationProperties(context.Properties)) { - AuthenticateFailure = authResult?.Failure, + AuthenticateFailure = authResult?.Failure }; // Avoid returning error=invalid_token if the error is not caused by an authentication failure (e.g missing token). diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 639be0103a..9141e8811d 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -233,15 +233,43 @@ namespace Microsoft.AspNetCore.Authentication } } + /// + /// Handle the authentication for once. + /// + /// If the authentication has been done before returns the last authentication result. + /// protected Task HandleAuthenticateOnceAsync() { if (_authenticateTask == null) { _authenticateTask = HandleAuthenticateAsync(); } + return _authenticateTask; } + /// + /// Handle the authentication for once. + /// + /// If the authentication has been done before returns the last authentication result. + /// This method won't throw exception. Any exception thrown during the authentication will be convert + /// to a AuthenticateResult. + /// + protected Task HandleAuthenticateOnceSafeAsync() + { + try + { + return HandleAuthenticateOnceAsync().ContinueWith( + task => task.IsFaulted ? AuthenticateResult.Fail(task.Exception) : task.Result + ); + } + catch (Exception ex) + { + // capture exception which is thrown before the task is actually started + return Task.FromResult(AuthenticateResult.Fail(ex)); + } + } + protected abstract Task HandleAuthenticateAsync(); public async Task SignInAsync(SignInContext context) @@ -313,7 +341,7 @@ namespace Microsoft.AspNetCore.Authentication { case ChallengeBehavior.Automatic: // If there is a principal already, invoke the forbidden code path - var result = await HandleAuthenticateOnceAsync(); + var result = await HandleAuthenticateOnceSafeAsync(); if (result?.Ticket?.Principal != null) { goto case ChallengeBehavior.Forbidden; @@ -350,4 +378,4 @@ namespace Microsoft.AspNetCore.Authentication auth.Handler = PriorHandler; } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index b1f0ce4fed..fea01b36fe 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -59,6 +59,46 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } + [Fact] + public async Task ThrowAtAuthenticationFailedEvent() + { + var options = new JwtBearerOptions + { + Events = new JwtBearerEvents + { + OnAuthenticationFailed = context => + { + context.Response.StatusCode = 401; + throw new Exception(); + }, + OnMessageReceived = context => + { + context.Token = "something"; + return Task.FromResult(0); + } + } + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Insert(0, new InvalidTokenValidator()); + + var server = CreateServer(options, async (context, next) => + { + try + { + await next(); + Assert.False(true, "Expected exception is not thrown"); + } + catch (Exception) + { + context.Response.StatusCode = 401; + await context.Response.WriteAsync("i got this"); + } + }); + + var transaction = await server.SendAsync("https://example.com/signIn"); + + Assert.Equal(HttpStatusCode.Unauthorized, transaction.Response.StatusCode); + } [Fact] public async Task CustomHeaderReceived() @@ -104,7 +144,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer public async Task HeaderWithoutBearerReceived() { var server = CreateServer(new JwtBearerOptions()); - var response = await SendAsync(server, "http://example.com/oauth","Token"); + var response = await SendAsync(server, "http://example.com/oauth", "Token"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); } @@ -347,7 +387,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); Assert.Equal(HttpStatusCode.Forbidden, response.Response.StatusCode); } - + [Fact] public async Task BearerDoesNothingTo401IfNotAuthenticated() { @@ -522,7 +562,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer public string AuthenticationScheme { get; } public bool CanValidateToken => true; - + public int MaximumTokenSizeInBytes { get @@ -558,11 +598,21 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } } - private static TestServer CreateServer(JwtBearerOptions options, Func handler = null) + private static TestServer CreateServer(JwtBearerOptions options) + { + return CreateServer(options, handlerBeforeAuth: null); + } + + private static TestServer CreateServer(JwtBearerOptions options, Func, Task> handlerBeforeAuth) { var builder = new WebHostBuilder() .Configure(app => { + if (handlerBeforeAuth != null) + { + app.Use(handlerBeforeAuth); + } + if (options != null) { app.UseJwtBearerAuthentication(options); @@ -622,6 +672,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer }); }) .ConfigureServices(services => services.AddAuthentication()); + return new TestServer(builder); } From 926c7fab4bac4b5b5ec58adc08d069edafc21132 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Fri, 5 Aug 2016 14:34:36 -0700 Subject: [PATCH 595/900] Use async-wait pattern in HandleAuthenticateOnceSafeAsync --- .../AuthenticationHandler.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 9141e8811d..d0528186c0 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -255,18 +255,15 @@ namespace Microsoft.AspNetCore.Authentication /// This method won't throw exception. Any exception thrown during the authentication will be convert /// to a AuthenticateResult. /// - protected Task HandleAuthenticateOnceSafeAsync() + protected async Task HandleAuthenticateOnceSafeAsync() { try { - return HandleAuthenticateOnceAsync().ContinueWith( - task => task.IsFaulted ? AuthenticateResult.Fail(task.Exception) : task.Result - ); + return await HandleAuthenticateOnceAsync(); } catch (Exception ex) { - // capture exception which is thrown before the task is actually started - return Task.FromResult(AuthenticateResult.Fail(ex)); + return AuthenticateResult.Fail(ex); } } From a344684d062ace8691185633a8c233d3e9592cf3 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Fri, 5 Aug 2016 15:27:37 -0700 Subject: [PATCH 596/900] Use HandleAuthenticateOnceSafeAsync in Cookie auth --- .../CookieAuthenticationHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 302010429b..9a26667aca 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -165,7 +165,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } // REVIEW: Should this check if there was an error, and then if that error was already handled?? - var ticket = (await HandleAuthenticateOnceAsync())?.Ticket; + var ticket = (await HandleAuthenticateOnceSafeAsync())?.Ticket; if (ticket != null) { if (_refreshIssuedUtc.HasValue) From 74e5777435503e37e7129dbbf49871b5fbd1f997 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Fri, 5 Aug 2016 22:00:37 -0700 Subject: [PATCH 597/900] Update comments --- .../CookieAuthenticationHandler.cs | 1 - .../AuthenticationHandler.cs | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 9a26667aca..b147181af4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -164,7 +164,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies return; } - // REVIEW: Should this check if there was an error, and then if that error was already handled?? var ticket = (await HandleAuthenticateOnceSafeAsync())?.Ticket; if (ticket != null) { diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index d0528186c0..1e642d82dd 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -234,9 +234,8 @@ namespace Microsoft.AspNetCore.Authentication } /// - /// Handle the authentication for once. - /// - /// If the authentication has been done before returns the last authentication result. + /// Used to ensure HandleAuthenticateAsync is only invoked once. The subsequent calls + /// will return the same authenticate result. /// protected Task HandleAuthenticateOnceAsync() { @@ -249,11 +248,9 @@ namespace Microsoft.AspNetCore.Authentication } /// - /// Handle the authentication for once. - /// - /// If the authentication has been done before returns the last authentication result. - /// This method won't throw exception. Any exception thrown during the authentication will be convert - /// to a AuthenticateResult. + /// Used to ensure HandleAuthenticateAsync is only invoked once safely. The subsequent + /// calls will return the same authentication result. Any exceptions will be converted + /// into a failed authenticatoin result containing the exception. /// protected async Task HandleAuthenticateOnceSafeAsync() { From 2bc207fa8c15eda49db12cbc4c9d7de9332e5194 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 9 Aug 2016 15:11:18 -0700 Subject: [PATCH 598/900] Switching to dotnet.myget.org feed --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index 5500f6d507..0fd623ffdd 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@  - + From 6a9f1f9887ec5983da5c20b4d8b788929d7b1b32 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 9 Aug 2016 11:15:40 -0700 Subject: [PATCH 599/900] Honor AuthenticationProperties.RedirectUri in CookieAuthenticationHandler --- .../CookieAuthenticationHandler.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index b147181af4..528e11c85b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -311,14 +311,24 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Response.Headers[HeaderNames.CacheControl] = HeaderValueNoCache; Response.Headers[HeaderNames.Pragma] = HeaderValueNoCache; Response.Headers[HeaderNames.Expires] = HeaderValueMinusOne; + if (shouldRedirectToReturnUrl && Response.StatusCode == 200) { + CookieRedirectContext redirectContext = null; + var query = Request.Query; var redirectUri = query[Options.ReturnUrlParameter]; - if (!StringValues.IsNullOrEmpty(redirectUri) - && IsHostRelative(redirectUri)) + if (!StringValues.IsNullOrEmpty(redirectUri) && IsHostRelative(redirectUri)) + { + redirectContext = new CookieRedirectContext(Context, Options, redirectUri, properties); + } + else if (!string.IsNullOrEmpty(properties.RedirectUri) && IsHostRelative(properties.RedirectUri)) + { + redirectContext = new CookieRedirectContext(Context, Options, properties.RedirectUri, properties); + } + + if (redirectContext != null) { - var redirectContext = new CookieRedirectContext(Context, Options, redirectUri, properties); await Options.Events.RedirectToReturnUrl(redirectContext); } } From 1ef62a40b38be955baddb88029b4a69184bc9b25 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 9 Aug 2016 16:15:49 -0700 Subject: [PATCH 600/900] Add test for CookieAuthentication --- .../Cookies/CookieMiddlewareTests.cs | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index fa4a4502ff..a5283c80f1 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -90,7 +90,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.True(responded.Single().StartsWith("http://example.com/Account/Login")); } - [Theory] [InlineData(true)] [InlineData(false)] @@ -1052,6 +1051,53 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal("?ReturnUrl=%2F", location.Query); } + [Fact] + public async Task RedirectUriIsHoneredAfterSignin() + { + var options = new CookieAuthenticationOptions + { + LoginPath = "/testpath", + CookieName = "TestCookie" + }; + + var server = CreateServer(options, async context => + { + await context.Authentication.SignInAsync( + CookieAuthenticationDefaults.AuthenticationScheme, + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme))), + new AuthenticationProperties { RedirectUri = "/redirect_test" }); + }); + var transaction = await SendAsync(server, "http://example.com/testpath"); + + Assert.NotEmpty(transaction.SetCookie); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/redirect_test", transaction.Response.Headers.Location.ToString()); + } + + [Fact] + public async Task EnsurePrecedenceOfRedirectUriAfterSignin() + { + var options = new CookieAuthenticationOptions + { + LoginPath = "/testpath", + ReturnUrlParameter = "return", + CookieName = "TestCookie" + }; + + var server = CreateServer(options, async context => + { + await context.Authentication.SignInAsync( + CookieAuthenticationDefaults.AuthenticationScheme, + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme))), + new AuthenticationProperties { RedirectUri = "/redirect_test" }); + }); + var transaction = await SendAsync(server, "http://example.com/testpath?return=%2Fret_path_2"); + + Assert.NotEmpty(transaction.SetCookie); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/ret_path_2", transaction.Response.Headers.Location.ToString()); + } + [Fact] public async Task NestedMapWillNotAffectAccessDenied() { From 97afe4acc8a07c8c64da03b69aa3718cd1dbebbb Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Wed, 10 Aug 2016 09:42:24 -0700 Subject: [PATCH 601/900] Adjust the redirect URI precedence in cookie auth --- .../CookieAuthenticationHandler.cs | 23 +++++++++-------- .../Cookies/CookieMiddlewareTests.cs | 25 ++++++++++++++++++- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 528e11c85b..e9eff38ac4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -315,20 +315,23 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (shouldRedirectToReturnUrl && Response.StatusCode == 200) { CookieRedirectContext redirectContext = null; - - var query = Request.Query; - var redirectUri = query[Options.ReturnUrlParameter]; - if (!StringValues.IsNullOrEmpty(redirectUri) && IsHostRelative(redirectUri)) + + // set redirect uri in order: + // 1. properties.RedirectUri + // 2. query parameter ReturnUrlParameter + var redirectUri = properties.RedirectUri; + if (string.IsNullOrEmpty(redirectUri) || !IsHostRelative(redirectUri)) { - redirectContext = new CookieRedirectContext(Context, Options, redirectUri, properties); - } - else if (!string.IsNullOrEmpty(properties.RedirectUri) && IsHostRelative(properties.RedirectUri)) - { - redirectContext = new CookieRedirectContext(Context, Options, properties.RedirectUri, properties); + redirectUri = Request.Query[Options.ReturnUrlParameter]; + if (string.IsNullOrEmpty(redirectUri) || !IsHostRelative(redirectUri)) + { + redirectUri = null; + } } - if (redirectContext != null) + if (redirectUri != null) { + redirectContext = new CookieRedirectContext(Context, Options, redirectUri, properties); await Options.Events.RedirectToReturnUrl(redirectContext); } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index a5283c80f1..9fc36e6d9c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -1074,6 +1074,29 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal("/redirect_test", transaction.Response.Headers.Location.ToString()); } + [Fact] + public async Task RedirectUriInQueryIsHoneredAfterSignin() + { + var options = new CookieAuthenticationOptions + { + LoginPath = "/testpath", + ReturnUrlParameter = "return", + CookieName = "TestCookie" + }; + + var server = CreateServer(options, async context => + { + await context.Authentication.SignInAsync( + CookieAuthenticationDefaults.AuthenticationScheme, + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme)))); + }); + var transaction = await SendAsync(server, "http://example.com/testpath?return=%2Fret_path_2"); + + Assert.NotEmpty(transaction.SetCookie); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/ret_path_2", transaction.Response.Headers.Location.ToString()); + } + [Fact] public async Task EnsurePrecedenceOfRedirectUriAfterSignin() { @@ -1095,7 +1118,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.NotEmpty(transaction.SetCookie); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal("/ret_path_2", transaction.Response.Headers.Location.ToString()); + Assert.Equal("/redirect_test", transaction.Response.Headers.Location.ToString()); } [Fact] From 4600451dc673574a7705cd5110ed375a83155b1d Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 11 Aug 2016 08:48:47 -0700 Subject: [PATCH 602/900] Allow absolute uri in authentication properties for cookie auth redirect --- .../CookieAuthenticationHandler.cs | 2 +- .../Cookies/CookieMiddlewareTests.cs | 32 ++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index e9eff38ac4..ff77815ce4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -320,7 +320,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies // 1. properties.RedirectUri // 2. query parameter ReturnUrlParameter var redirectUri = properties.RedirectUri; - if (string.IsNullOrEmpty(redirectUri) || !IsHostRelative(redirectUri)) + if (string.IsNullOrEmpty(redirectUri)) { redirectUri = Request.Query[Options.ReturnUrlParameter]; if (string.IsNullOrEmpty(redirectUri) || !IsHostRelative(redirectUri)) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 9fc36e6d9c..4a4d19a021 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -1051,8 +1051,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal("?ReturnUrl=%2F", location.Query); } - [Fact] - public async Task RedirectUriIsHoneredAfterSignin() + [Theory] + [InlineData("/redirect_test")] + [InlineData("http://example.com/redirect_to")] + public async Task RedirectUriIsHoneredAfterSignin(string redirectUrl) { var options = new CookieAuthenticationOptions { @@ -1065,13 +1067,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies await context.Authentication.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme))), - new AuthenticationProperties { RedirectUri = "/redirect_test" }); + new AuthenticationProperties { RedirectUri = redirectUrl }); }); var transaction = await SendAsync(server, "http://example.com/testpath"); Assert.NotEmpty(transaction.SetCookie); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal("/redirect_test", transaction.Response.Headers.Location.ToString()); + Assert.Equal(redirectUrl, transaction.Response.Headers.Location.ToString()); } [Fact] @@ -1097,6 +1099,28 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal("/ret_path_2", transaction.Response.Headers.Location.ToString()); } + [Fact] + public async Task AbsoluteRedirectUriIsRejected() + { + var options = new CookieAuthenticationOptions + { + LoginPath = "/testpath", + ReturnUrlParameter = "return", + CookieName = "TestCookie" + }; + + var server = CreateServer(options, async context => + { + await context.Authentication.SignInAsync( + CookieAuthenticationDefaults.AuthenticationScheme, + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme)))); + }); + var transaction = await SendAsync(server, "http://example.com/testpath?return=http%3A%2F%2Fexample.com%2Fredirect_to"); + + Assert.NotEmpty(transaction.SetCookie); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + [Fact] public async Task EnsurePrecedenceOfRedirectUriAfterSignin() { From 26a7c7016db3b83dfcc7aab4ccfa25fc9e21a850 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 11 Aug 2016 10:15:07 -0700 Subject: [PATCH 603/900] Minor updates to CookieAuthenticationHandler and its tests 1. Remove unnecessary variable declaration. 2. Update test name to a more accurate description. --- .../CookieAuthenticationHandler.cs | 7 ++----- .../Cookies/CookieMiddlewareTests.cs | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index ff77815ce4..9b45738756 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Authentication.Cookies @@ -314,8 +313,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (shouldRedirectToReturnUrl && Response.StatusCode == 200) { - CookieRedirectContext redirectContext = null; - // set redirect uri in order: // 1. properties.RedirectUri // 2. query parameter ReturnUrlParameter @@ -331,8 +328,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (redirectUri != null) { - redirectContext = new CookieRedirectContext(Context, Options, redirectUri, properties); - await Options.Events.RedirectToReturnUrl(redirectContext); + await Options.Events.RedirectToReturnUrl( + new CookieRedirectContext(Context, Options, redirectUri, properties)); } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 4a4d19a021..942b1c4a5f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -1100,7 +1100,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } [Fact] - public async Task AbsoluteRedirectUriIsRejected() + public async Task AbsoluteRedirectUriInQueryStringIsRejected() { var options = new CookieAuthenticationOptions { From fb0a577dd1ef5faf44aee7bb1dabb9376e45c8b9 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 11 Aug 2016 14:03:17 -0700 Subject: [PATCH 604/900] Add comments to CookieAuthenticationHandler --- .../CookieAuthenticationHandler.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 9b45738756..f11f69e1c9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -316,6 +316,9 @@ namespace Microsoft.AspNetCore.Authentication.Cookies // set redirect uri in order: // 1. properties.RedirectUri // 2. query parameter ReturnUrlParameter + // + // Absolute uri is not allowed if it is from query string as query string is not + // a trusted source. var redirectUri = properties.RedirectUri; if (string.IsNullOrEmpty(redirectUri)) { From 936a4f6092810dd43a91aea18b222ed5a3ec303f Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Wed, 17 Aug 2016 16:20:56 -0700 Subject: [PATCH 605/900] Update OpenId Connect Configuration tests 1. Move configuration related tests to their own class; 2. Add tests to cover missing options scenarios; 3. Add TestDefaultValues class for default values used in OpenId connect tests. --- .../Infrastructure/TestDefaultValues.cs | 10 ++ .../OpenIdConnectConfigurationTests.cs | 121 ++++++++++++++++++ .../OpenIdConnectMiddlewareTests.cs | 94 +++----------- 3 files changed, 149 insertions(+), 76 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/Infrastructure/TestDefaultValues.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/Infrastructure/TestDefaultValues.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/Infrastructure/TestDefaultValues.cs new file mode 100644 index 0000000000..de921bb96a --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/Infrastructure/TestDefaultValues.cs @@ -0,0 +1,10 @@ +// 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.AspNetCore.Authentication.Tests.OpenIdConnect.Infrastructre +{ + internal class TestDefaultValues + { + public static readonly string DefaultAuthority = @"https://example.com/common"; + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs new file mode 100644 index 0000000000..4ada6ff859 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -0,0 +1,121 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect.Infrastructre; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +{ + public class OpenIdConnectConfigurationTests + { + [Fact] + public void MetadataAddressIsGeneratedFromAuthorityWhenMissing() + { + var options = new OpenIdConnectOptions + { + Authority = TestDefaultValues.DefaultAuthority, + ClientId = Guid.NewGuid().ToString(), + SignInScheme = Guid.NewGuid().ToString() + }; + + BuildTestServer(options); + + Assert.Equal($"{options.Authority}/.well-known/openid-configuration", options.MetadataAddress); + } + + public void ThrowsWhenSignInSchemeIsMissing() + { + TestConfigurationException( + new OpenIdConnectOptions + { + Authority = TestDefaultValues.DefaultAuthority, + ClientId = Guid.NewGuid().ToString() + }, + ex => Assert.Equal("SignInScheme", ex.ParamName)); + } + + [Fact] + public void ThrowsWhenClientIdIsMissing() + { + TestConfigurationException( + new OpenIdConnectOptions + { + SignInScheme = "TestScheme", + Authority = TestDefaultValues.DefaultAuthority, + }, + ex => Assert.Equal("ClientId", ex.ParamName)); + } + + [Fact] + public void ThrowsWhenAuthorityIsMissing() + { + TestConfigurationException( + new OpenIdConnectOptions + { + SignInScheme = "TestScheme", + ClientId = "Test Id", + }, + ex => Assert.Equal("Provide Authority, MetadataAddress, Configuration, or ConfigurationManager to OpenIdConnectOptions", ex.Message) + ); + } + + [Fact] + public void ThrowsWhenAuthorityIsNotHttps() + { + TestConfigurationException( + new OpenIdConnectOptions + { + SignInScheme = "TestScheme", + ClientId = "Test Id", + Authority = "http://example.com" + }, + ex => Assert.Equal("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false.", ex.Message) + ); + } + + [Fact] + public void ThrowsWhenMetadataAddressIsNotHttps() + { + TestConfigurationException( + new OpenIdConnectOptions + { + SignInScheme = "TestScheme", + ClientId = "Test Id", + MetadataAddress = "http://example.com" + }, + ex => Assert.Equal("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false.", ex.Message) + ); + } + + private TestServer BuildTestServer(OpenIdConnectOptions options) + { + var builder = new WebHostBuilder() + .ConfigureServices(services => services.AddAuthentication()) + .Configure(app => app.UseOpenIdConnectAuthentication(options)); + + return new TestServer(builder); + } + + private void TestConfigurationException( + OpenIdConnectOptions options, + Action verifyException) + where T : Exception + { + var builder = new WebHostBuilder() + .ConfigureServices(services => services.AddAuthentication()) + .Configure(app => app.UseOpenIdConnectAuthentication(options)); + + var exception = Assert.Throws(() => + { + new TestServer(builder); + }); + + verifyException(exception); + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 41154820b9..5853e38967 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -13,6 +13,7 @@ using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect.Infrastructre; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -32,7 +33,6 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect const string ChallengeWithOutContext = "/challengeWithOutContext"; const string ChallengeWithProperties = "/challengeWithProperties"; const string DefaultHost = @"https://example.com"; - const string DefaultAuthority = @"https://example.com/common"; const string ExpectedAuthorizeRequest = @"https://example.com/common/oauth2/signin"; const string ExpectedLogoutRequest = @"https://example.com/common/oauth2/logout"; const string Logout = "/logout"; @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { var server = CreateServer(new OpenIdConnectOptions { - Authority = DefaultAuthority, + Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", Configuration = TestUtilities.DefaultOpenIdConnectConfiguration, AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost @@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public async Task ChallengeWillSetDefaults() { var stateDataFormat = new AuthenticationPropertiesFormaterKeyValue(); - var queryValues = ExpectedQueryValues.Defaults(DefaultAuthority); + var queryValues = ExpectedQueryValues.Defaults(TestDefaultValues.DefaultAuthority); queryValues.State = OpenIdConnectDefaults.AuthenticationPropertiesKey + "=" + stateDataFormat.Protect(new AuthenticationProperties()); var server = CreateServer(GetOptions(DefaultParameters(), queryValues)); @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { var server = CreateServer(new OpenIdConnectOptions { - Authority = DefaultAuthority, + Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", Configuration = TestUtilities.DefaultOpenIdConnectConfiguration }); @@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Fact] public async Task ChallengeWillUseOptionsProperties() { - var queryValues = new ExpectedQueryValues(DefaultAuthority); + var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority); var server = CreateServer(GetOptions(DefaultParameters(), queryValues)); var transaction = await SendAsync(server, DefaultHost + Challenge); @@ -111,14 +111,14 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect AuthorizationEndpoint = ExpectedAuthorizeRequest, }; - var queryValues = new ExpectedQueryValues(DefaultAuthority, configuration) + var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority, configuration) { RequestType = OpenIdConnectRequestType.Authentication }; var server = CreateServer(GetProtocolMessageOptions()); var transaction = await SendAsync(server, DefaultHost + Challenge); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - queryValues.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, new string[] {}); + queryValues.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, new string[] { }); } /// @@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect EndSessionEndpoint = ExpectedLogoutRequest }; - var queryValues = new ExpectedQueryValues(DefaultAuthority, configuration) + var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority, configuration) { RequestType = OpenIdConnectRequestType.Logout }; @@ -198,7 +198,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Theory, MemberData("StateDataSet")] public async Task ChallengeSettingState(string userState, string challenge) { - var queryValues = new ExpectedQueryValues(DefaultAuthority); + var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority); var stateDataFormat = new AuthenticationPropertiesFormaterKeyValue(); var properties = new AuthenticationProperties(); if (challenge == ChallengeWithProperties) @@ -255,8 +255,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Fact] public async Task ChallengeWillUseEvents() { - var queryValues = new ExpectedQueryValues(DefaultAuthority); - var queryValuesSetInEvent = new ExpectedQueryValues(DefaultAuthority); + var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority); + var queryValuesSetInEvent = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority); var options = GetOptions(DefaultParameters(), queryValues); options.Events = new OpenIdConnectEvents() { @@ -285,10 +285,12 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect options.ClientId = queryValues.ClientId; else if (param.Equals(OpenIdConnectParameterNames.Resource)) options.Resource = queryValues.Resource; - else if (param.Equals(OpenIdConnectParameterNames.Scope)) { + else if (param.Equals(OpenIdConnectParameterNames.Scope)) + { options.Scope.Clear(); - foreach (var scope in queryValues.Scope.Split(' ')) { + foreach (var scope in queryValues.Scope.Split(' ')) + { options.Scope.Add(scope); } } @@ -333,7 +335,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var configuration = TestUtilities.DefaultOpenIdConnectConfiguration; var server = CreateServer(new OpenIdConnectOptions { - Authority = DefaultAuthority, + Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", Configuration = configuration }); @@ -349,7 +351,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var configuration = TestUtilities.DefaultOpenIdConnectConfiguration; var server = CreateServer(new OpenIdConnectOptions { - Authority = DefaultAuthority, + Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", Configuration = configuration, PostLogoutRedirectUri = "https://example.com/logout" @@ -366,7 +368,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var configuration = TestUtilities.DefaultOpenIdConnectConfiguration; var server = CreateServer(new OpenIdConnectOptions { - Authority = DefaultAuthority, + Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", Configuration = configuration, PostLogoutRedirectUri = "https://example.com/logout" @@ -553,65 +555,5 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect return nonceTime; } - [Fact] - public void ThrowsWithNoClientId() - { - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions - { - SignInScheme = "TestScheme", - Authority = DefaultAuthority, - Configuration = TestUtilities.DefaultOpenIdConnectConfiguration, - AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost - }); - }).ConfigureServices(services => - { - services.AddAuthentication(); - }); - - try - { - var server = new TestServer(builder); - } - catch (ArgumentException e) - { - Assert.Equal("ClientId", e.ParamName); - return; - } - - Assert.True(false); - } - - [Fact] - public void ThrowsWithNoConfigurationValues() - { - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions - { - SignInScheme = "TestScheme", - ClientId = "Test Id", - AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost - }); - }).ConfigureServices(services => - { - services.AddAuthentication(); - }); - - try - { - var server = new TestServer(builder); - } - catch (InvalidOperationException e) - { - Assert.Equal("Provide Authority, MetadataAddress, Configuration, or ConfigurationManager to OpenIdConnectOptions", e.Message); - return; - } - - Assert.True(false); - } } } \ No newline at end of file From 6f15d616a8954420bcb277ed938de1b14f6dbd6f Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 1 Aug 2016 16:59:57 -0700 Subject: [PATCH 606/900] Add IAuthorizationEvaluator --- ...uthorizationServiceCollectionExtensions.cs | 1 + .../DefaultAuthorizationEvaluator.cs | 31 +++++++++++++++++++ .../DefaultAuthorizationService.cs | 19 ++++++++++-- .../IAuthorizationEvaluator.cs | 25 +++++++++++++++ .../DefaultAuthorizationServiceTests.cs | 25 +++++++++++++++ 5 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs index c92be6232e..f56ea5c19e 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -27,6 +27,7 @@ namespace Microsoft.Extensions.DependencyInjection services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); + services.TryAdd(ServiceDescriptor.Transient()); services.TryAddEnumerable(ServiceDescriptor.Transient()); return services; } diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs new file mode 100644 index 0000000000..64cc695b88 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs @@ -0,0 +1,31 @@ +// 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.AspNetCore.Authorization +{ + /// + /// Determines whether an authorization request was successful or not. + /// + public class DefaultAuthorizationEvaluator : IAuthorizationEvaluator + { + /// + /// Returns true, if authorization has failed. + /// + /// The authorization information. + /// True if authorization has failed. + public virtual bool HasFailed(AuthorizationHandlerContext context) + { + return context.HasFailed; + } + + /// + /// Returns true, if authorization has succeeded. + /// + /// The authorization information. + /// True if authorization has succeeded. + public virtual bool HasSucceeded(AuthorizationHandlerContext context) + { + return context.HasSucceeded; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 6665204eee..45ee4aa4a2 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -16,6 +16,7 @@ namespace Microsoft.AspNetCore.Authorization /// public class DefaultAuthorizationService : IAuthorizationService { + private readonly IAuthorizationEvaluator _evaluator; private readonly IAuthorizationPolicyProvider _policyProvider; private readonly IList _handlers; private readonly ILogger _logger; @@ -26,7 +27,16 @@ namespace Microsoft.AspNetCore.Authorization /// The used to provide policies. /// The handlers used to fulfill s. /// The logger used to log messages, warnings and errors. - public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) + public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) : this(policyProvider, handlers, logger, new DefaultAuthorizationEvaluator()) { } + + /// + /// Creates a new instance of . + /// + /// The used to provide policies. + /// The handlers used to fulfill s. + /// The logger used to log messages, warnings and errors. + /// The used to determine if authorzation was successful. + public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger, IAuthorizationEvaluator evaluator) { if (policyProvider == null) { @@ -40,10 +50,15 @@ namespace Microsoft.AspNetCore.Authorization { throw new ArgumentNullException(nameof(logger)); } + if (evaluator == null) + { + throw new ArgumentNullException(nameof(evaluator)); + } _handlers = handlers.ToArray(); _policyProvider = policyProvider; _logger = logger; + _evaluator = evaluator; } /// @@ -69,7 +84,7 @@ namespace Microsoft.AspNetCore.Authorization await handler.HandleAsync(authContext); } - if (authContext.HasSucceeded) + if (_evaluator.HasSucceeded(authContext)) { _logger.UserAuthorizationSucceeded(GetUserNameForLogging(user)); return true; diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs new file mode 100644 index 0000000000..7b2c5d1bc5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs @@ -0,0 +1,25 @@ +// 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.AspNetCore.Authorization +{ + /// + /// Determines whether an authorization request was successful or not. + /// + public interface IAuthorizationEvaluator + { + /// + /// Returns true, if authorization has failed. + /// + /// The authorization information. + /// True if authorization has failed. + bool HasFailed(AuthorizationHandlerContext context); + + /// + /// Returns true, if authorization has succeeded. + /// + /// The authorization information. + /// True if authorization has succeeded. + bool HasSucceeded(AuthorizationHandlerContext context); + } +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 19bd761e05..749a11dc34 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -1019,5 +1019,30 @@ namespace Microsoft.AspNetCore.Authorization.Test Assert.True(await authorizationService.AuthorizeAsync(user, "2")); Assert.False(await authorizationService.AuthorizeAsync(user, "3")); } + + public class SuccessEvaluator : IAuthorizationEvaluator + { + public bool HasFailed(AuthorizationHandlerContext context) + { + return false; + } + + public bool HasSucceeded(AuthorizationHandlerContext context) + { + return true; + } + } + + [Fact] + public async Task CanUseCustomEvaluatorThatOverridesRequirement() + { + var authorizationService = BuildAuthorizationService(services => + { + // This will ignore the policy options + services.AddSingleton(); + services.AddAuthorization(options => options.AddPolicy("Fail", p => p.RequireAssertion(c => false))); + }); + Assert.True(await authorizationService.AuthorizeAsync(null, "Fail")); + } } } \ No newline at end of file From d291bb7c249ae989ea848c8ff378186ae42606d1 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 2 Aug 2016 17:55:10 -0700 Subject: [PATCH 607/900] Add AuthZHandlerContextFactory --- .../AuthorizationHandlerContext.cs | 16 +++---- ...uthorizationServiceCollectionExtensions.cs | 1 + ...faultAuthorizationHandlerContextFactory.cs | 29 +++++++++++++ .../DefaultAuthorizationService.cs | 13 ++++-- .../IAuthorizationHandlerContextFactory.cs | 26 +++++++++++ .../DefaultAuthorizationServiceTests.cs | 43 ++++++++++++++++++- 6 files changed, 116 insertions(+), 12 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerContextFactory.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerContextFactory.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs index 5dc57c278a..b6378e4073 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs @@ -42,32 +42,32 @@ namespace Microsoft.AspNetCore.Authorization /// /// The collection of all the for the current authorization action. /// - public IEnumerable Requirements { get; } + public virtual IEnumerable Requirements { get; } /// /// The representing the current user. /// - public ClaimsPrincipal User { get; } + public virtual ClaimsPrincipal User { get; } /// /// The optional resource to evaluate the against. /// - public object Resource { get; } + public virtual object Resource { get; } /// /// Gets the requirements that have not yet been marked as succeeded. /// - public IEnumerable PendingRequirements { get { return _pendingRequirements; } } + public virtual IEnumerable PendingRequirements { get { return _pendingRequirements; } } /// /// Flag indicating whether the current authorization processing has failed. /// - public bool HasFailed { get { return _failCalled; } } + public virtual bool HasFailed { get { return _failCalled; } } /// /// Flag indicating whether the current authorization processing has succeeded. /// - public bool HasSucceeded + public virtual bool HasSucceeded { get { @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Authorization /// Called to indicate will /// never return true, even if all requirements are met. /// - public void Fail() + public virtual void Fail() { _failCalled = true; } @@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Authorization /// successfully evaluated. /// /// The requirement whose evaluation has succeeded. - public void Succeed(IAuthorizationRequirement requirement) + public virtual void Succeed(IAuthorizationRequirement requirement) { _succeedCalled = true; _pendingRequirements.Remove(requirement); diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs index f56ea5c19e..a9961b69ef 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -28,6 +28,7 @@ namespace Microsoft.Extensions.DependencyInjection services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); + services.TryAdd(ServiceDescriptor.Transient()); services.TryAddEnumerable(ServiceDescriptor.Transient()); return services; } diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerContextFactory.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerContextFactory.cs new file mode 100644 index 0000000000..2dae5e5e73 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerContextFactory.cs @@ -0,0 +1,29 @@ +// 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.Collections.Generic; +using System.Security.Claims; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// A type used to provide a used for authorization. + /// + public class DefaultAuthorizationHandlerContextFactory : IAuthorizationHandlerContextFactory + { + /// + /// Creates a used for authorization. + /// + /// The requirements to evaluate. + /// The user to evaluate the requirements against. + /// + /// An optional resource the policy should be checked with. + /// If a resource is not required for policy evaluation you may pass null as the value. + /// + /// The . + public virtual AuthorizationHandlerContext CreateContext(IEnumerable requirements, ClaimsPrincipal user, object resource) + { + return new AuthorizationHandlerContext(requirements, user, resource); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 45ee4aa4a2..89777eab01 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -16,6 +16,7 @@ namespace Microsoft.AspNetCore.Authorization /// public class DefaultAuthorizationService : IAuthorizationService { + private readonly IAuthorizationHandlerContextFactory _contextFactory; private readonly IAuthorizationEvaluator _evaluator; private readonly IAuthorizationPolicyProvider _policyProvider; private readonly IList _handlers; @@ -27,7 +28,7 @@ namespace Microsoft.AspNetCore.Authorization /// The used to provide policies. /// The handlers used to fulfill s. /// The logger used to log messages, warnings and errors. - public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) : this(policyProvider, handlers, logger, new DefaultAuthorizationEvaluator()) { } + public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) : this(policyProvider, handlers, logger, new DefaultAuthorizationHandlerContextFactory(), new DefaultAuthorizationEvaluator()) { } /// /// Creates a new instance of . @@ -35,8 +36,9 @@ namespace Microsoft.AspNetCore.Authorization /// The used to provide policies. /// The handlers used to fulfill s. /// The logger used to log messages, warnings and errors. + /// The used to create the context to handle the authorization. /// The used to determine if authorzation was successful. - public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger, IAuthorizationEvaluator evaluator) + public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger, IAuthorizationHandlerContextFactory contextFactory, IAuthorizationEvaluator evaluator) { if (policyProvider == null) { @@ -50,6 +52,10 @@ namespace Microsoft.AspNetCore.Authorization { throw new ArgumentNullException(nameof(logger)); } + if (contextFactory == null) + { + throw new ArgumentNullException(nameof(contextFactory)); + } if (evaluator == null) { throw new ArgumentNullException(nameof(evaluator)); @@ -59,6 +65,7 @@ namespace Microsoft.AspNetCore.Authorization _policyProvider = policyProvider; _logger = logger; _evaluator = evaluator; + _contextFactory = contextFactory; } /// @@ -78,7 +85,7 @@ namespace Microsoft.AspNetCore.Authorization throw new ArgumentNullException(nameof(requirements)); } - var authContext = new AuthorizationHandlerContext(requirements, user, resource); + var authContext = _contextFactory.CreateContext(requirements, user, resource); foreach (var handler in _handlers) { await handler.HandleAsync(authContext); diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerContextFactory.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerContextFactory.cs new file mode 100644 index 0000000000..272109eea9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerContextFactory.cs @@ -0,0 +1,26 @@ +// 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.Collections.Generic; +using System.Security.Claims; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// A type used to provide a used for authorization. + /// + public interface IAuthorizationHandlerContextFactory + { + /// + /// Creates a used for authorization. + /// + /// The requirements to evaluate. + /// The user to evaluate the requirements against. + /// + /// An optional resource the policy should be checked with. + /// If a resource is not required for policy evaluation you may pass null as the value. + /// + /// The . + AuthorizationHandlerContext CreateContext(IEnumerable requirements, ClaimsPrincipal user, object resource); + } +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 749a11dc34..7f9e5642ae 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -1038,11 +1038,52 @@ namespace Microsoft.AspNetCore.Authorization.Test { var authorizationService = BuildAuthorizationService(services => { - // This will ignore the policy options services.AddSingleton(); services.AddAuthorization(options => options.AddPolicy("Fail", p => p.RequireAssertion(c => false))); }); Assert.True(await authorizationService.AuthorizeAsync(null, "Fail")); } + + + public class BadContextMaker : IAuthorizationHandlerContextFactory + { + public AuthorizationHandlerContext CreateContext(IEnumerable requirements, ClaimsPrincipal user, object resource) + { + return new BadContext(); + } + } + + public class BadContext : AuthorizationHandlerContext + { + public BadContext() : base(new List(), null, null) { } + + public override bool HasFailed + { + get + { + return true; + } + } + + public override bool HasSucceeded + { + get + { + return false; + } + } + } + + [Fact] + public async Task CanUseCustomContextThatAlwaysFails() + { + var authorizationService = BuildAuthorizationService(services => + { + services.AddSingleton(); + services.AddAuthorization(options => options.AddPolicy("Success", p => p.RequireAssertion(c => true))); + }); + Assert.False(await authorizationService.AuthorizeAsync(null, "Success")); + } + } } \ No newline at end of file From 6ca981e4dfae5e17dafc4c5b89313b2a9591ef83 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Wed, 17 Aug 2016 13:02:28 -0700 Subject: [PATCH 608/900] Refine OIDC sample 1. Add signout remote scenario 2. Use bootstrap to enhance the view 3. Improve readability --- .../OpenIdConnect.AzureAdSample/Startup.cs | 107 +++++++++++++----- 1 file changed, 76 insertions(+), 31 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 8a2b7f4412..f0c2f7c221 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Builder; @@ -103,47 +105,90 @@ namespace OpenIdConnect.AzureAdSample if (context.Request.Path.Equals("/signout")) { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync($"Signing out {context.User.Identity.Name}
{Environment.NewLine}"); - await context.Response.WriteAsync("Sign In"); - await context.Response.WriteAsync($""); - return; + await WriteHtmlAsync(context.Response, + response => response.WriteAsync($"

Signed out locally: {context.User.Identity.Name}

Sign In")); } - - if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) + else if (context.Request.Path.Equals("/signout-remote")) { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" }); - return; + await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties + { + RedirectUri = "/remote-signedout" + }); } - - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync($"Hello Authenticated User {context.User.Identity.Name}
{Environment.NewLine}"); - await context.Response.WriteAsync("Claims:
" + Environment.NewLine); - foreach (var claim in context.User.Claims) + else if (context.Request.Path.Equals("/remote-signedout")) { - await context.Response.WriteAsync($"{claim.Type}: {claim.Value}
{Environment.NewLine}"); + await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await WriteHtmlAsync(context.Response, + response => response.WriteAsync($"

Signed out remotely: {context.User.Identity.Name}

Sign In")); } - - await context.Response.WriteAsync("Tokens:
" + Environment.NewLine); - try + else { - // Use ADAL to get the right token - var authContext = new AuthenticationContext(authority, AuthPropertiesTokenCache.ForApiCalls(context, CookieAuthenticationDefaults.AuthenticationScheme)); - var credential = new ClientCredential(clientId, clientSecret); - string userObjectID = context.User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; - var result = await authContext.AcquireTokenSilentAsync(resource, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId)); + if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) + { + await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" }); + return; + } - await context.Response.WriteAsync($"access_token: {result.AccessToken}
{Environment.NewLine}"); - } - catch (Exception ex) - { - await context.Response.WriteAsync($"AquireToken error: {ex.Message}
{Environment.NewLine}"); - } + await WriteHtmlAsync(context.Response, async response => + { + await response.WriteAsync($"

Hello Authenticated User {context.User.Identity.Name}

"); + await response.WriteAsync("Sign Out Locally"); + await response.WriteAsync("Sign Out Remotely"); - await context.Response.WriteAsync("Sign Out"); - await context.Response.WriteAsync($""); + await response.WriteAsync("

Claims:

"); + await WriteTableHeader(response, new string[] { "Claim Type", "Value" }, context.User.Claims.Select(c => new string[] { c.Type, c.Value })); + + await response.WriteAsync("

Tokens:

"); + try + { + // Use ADAL to get the right token + var authContext = new AuthenticationContext(authority, AuthPropertiesTokenCache.ForApiCalls(context, CookieAuthenticationDefaults.AuthenticationScheme)); + var credential = new ClientCredential(clientId, clientSecret); + string userObjectID = context.User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; + var result = await authContext.AcquireTokenSilentAsync(resource, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId)); + + await response.WriteAsync($"

access_token

{result.AccessToken}
"); + } + catch (Exception ex) + { + await response.WriteAsync($"AquireToken error: {ex.Message}
{Environment.NewLine}"); + } + }); + } }); } + + private static async Task WriteHtmlAsync(HttpResponse response, Func writeContent) + { + var bootstrap = ""; + + response.ContentType = "text/html"; + await response.WriteAsync($"{bootstrap}
"); + await writeContent(response); + await response.WriteAsync("
"); + } + + private static async Task WriteTableHeader(HttpResponse response, IEnumerable columns, IEnumerable> data) + { + await response.WriteAsync(""); + await response.WriteAsync(""); + foreach (var column in columns) + { + await response.WriteAsync($""); + } + await response.WriteAsync(""); + foreach (var row in data) + { + await response.WriteAsync(""); + foreach (var column in row) + { + await response.WriteAsync($""); + } + await response.WriteAsync(""); + } + await response.WriteAsync("
{column}
{column}
"); + } } } From 91e5de4d690adb2469872776442db6e8c9b9658d Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 18 Aug 2016 16:51:46 -0700 Subject: [PATCH 609/900] Add HTML encoding to OpenIdConnect AzureSample --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index f0c2f7c221..45304e1bd6 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; @@ -106,7 +107,7 @@ namespace OpenIdConnect.AzureAdSample { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await WriteHtmlAsync(context.Response, - response => response.WriteAsync($"

Signed out locally: {context.User.Identity.Name}

Sign In")); + response => response.WriteAsync($"

Signed out locally: {HtmlEncode(context.User.Identity.Name)}

Sign In")); } else if (context.Request.Path.Equals("/signout-remote")) { @@ -120,7 +121,7 @@ namespace OpenIdConnect.AzureAdSample { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await WriteHtmlAsync(context.Response, - response => response.WriteAsync($"

Signed out remotely: {context.User.Identity.Name}

Sign In")); + response => response.WriteAsync($"

Signed out remotely: {HtmlEncode(context.User.Identity.Name)}

Sign In")); } else { @@ -132,7 +133,7 @@ namespace OpenIdConnect.AzureAdSample await WriteHtmlAsync(context.Response, async response => { - await response.WriteAsync($"

Hello Authenticated User {context.User.Identity.Name}

"); + await response.WriteAsync($"

Hello Authenticated User {HtmlEncode(context.User.Identity.Name)}

"); await response.WriteAsync("Sign Out Locally"); await response.WriteAsync("Sign Out Remotely"); @@ -152,7 +153,7 @@ namespace OpenIdConnect.AzureAdSample } catch (Exception ex) { - await response.WriteAsync($"AquireToken error: {ex.Message}
{Environment.NewLine}"); + await response.WriteAsync($"AquireToken error: {ex.Message}"); } }); } @@ -189,6 +190,9 @@ namespace OpenIdConnect.AzureAdSample } await response.WriteAsync(""); } + + private static string HtmlEncode(string content) => + string.IsNullOrEmpty(content) ? string.Empty : HtmlEncoder.Default.Encode(content); } } From 7ea76f5e54a740ce6a4c2b56f2b0eaf685a586e1 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 22 Aug 2016 22:27:37 -0700 Subject: [PATCH 610/900] Update OpenID connect Azure sample --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 45304e1bd6..0645b995ed 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -107,7 +107,11 @@ namespace OpenIdConnect.AzureAdSample { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await WriteHtmlAsync(context.Response, - response => response.WriteAsync($"

Signed out locally: {HtmlEncode(context.User.Identity.Name)}

Sign In")); + async response => + { + await response.WriteAsync($"

Signed out locally: {HtmlEncode(context.User.Identity.Name)}

"); + await response.WriteAsync("Sign In"); + }); } else if (context.Request.Path.Equals("/signout-remote")) { @@ -121,7 +125,11 @@ namespace OpenIdConnect.AzureAdSample { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await WriteHtmlAsync(context.Response, - response => response.WriteAsync($"

Signed out remotely: {HtmlEncode(context.User.Identity.Name)}

Sign In")); + async response => + { + await response.WriteAsync($"

Signed out remotely: {HtmlEncode(context.User.Identity.Name)}

"); + await response.WriteAsync("Sign In"); + }); } else { From 62f0f6e857c5648bc6573af20fe85d45abd4ac16 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 22 Aug 2016 22:30:11 -0700 Subject: [PATCH 611/900] HtmlEncode all user input in Azure OpenID sample --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 0645b995ed..fcfc7b4df0 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -157,7 +157,7 @@ namespace OpenIdConnect.AzureAdSample string userObjectID = context.User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; var result = await authContext.AcquireTokenSilentAsync(resource, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId)); - await response.WriteAsync($"

access_token

{result.AccessToken}
"); + await response.WriteAsync($"

access_token

{HtmlEncode(result.AccessToken)}
"); } catch (Exception ex) { @@ -184,7 +184,7 @@ namespace OpenIdConnect.AzureAdSample await response.WriteAsync(""); foreach (var column in columns) { - await response.WriteAsync($"{column}"); + await response.WriteAsync($"{HtmlEncode(column)}"); } await response.WriteAsync(""); foreach (var row in data) @@ -192,7 +192,7 @@ namespace OpenIdConnect.AzureAdSample await response.WriteAsync(""); foreach (var column in row) { - await response.WriteAsync($"{column}"); + await response.WriteAsync($"{HtmlEncode(column)}"); } await response.WriteAsync(""); } From abc1b37ee1c912bb3b3d478ae94a543564e77255 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 22 Aug 2016 14:47:30 -0700 Subject: [PATCH 612/900] Update OpenId Connect Challenge Tests 1. Expand the test coverage: add tests covers events work flow. 2. Move OpenID connect challenge tests to their own class. 3. Further refactory the test settings and utilities. --- ...uthenticationPropertiesFormaterKeyValue.cs | 70 --- .../OpenIdConnect/ExpectedQueryValues.cs | 175 ------- .../Infrastructure/TestDefaultValues.cs | 10 - .../OpenIdConnect/MockOpenIdConnectMessage.cs | 21 + .../OpenIdConnectChallengeTests.cs | 322 +++++++++++++ .../OpenIdConnectConfigurationTests.cs | 1 - .../OpenIdConnectMiddlewareTests.cs | 451 +----------------- .../OpenIdConnect/TestDefaultValues.cs | 48 ++ .../OpenIdConnect/TestServerBuilder.cs | 97 ++++ .../OpenIdConnect/TestSettings.cs | 230 +++++++++ .../OpenIdConnect/TestTransaction.cs | 77 +++ .../OpenIdConnect/TestUtilities.cs | 37 -- 12 files changed, 817 insertions(+), 722 deletions(-) delete mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs delete mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs delete mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/Infrastructure/TestDefaultValues.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestDefaultValues.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs delete mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestUtilities.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs deleted file mode 100644 index 1be4b80bca..0000000000 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/AuthenticationPropertiesFormaterKeyValue.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. 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.Text; -using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Http.Authentication; - -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect -{ - /// - /// This formatter creates an easy to read string of the format: "'key1' 'value1' ..." - /// - public class AuthenticationPropertiesFormaterKeyValue : ISecureDataFormat - { - string _protectedString = Guid.NewGuid().ToString(); - - public string Protect(AuthenticationProperties data) - { - if (data == null || data.Items.Count == 0) - { - return "null"; - } - - var sb = new StringBuilder(); - foreach(var item in data.Items) - { - sb.Append(Uri.EscapeDataString(item.Key) + " " + Uri.EscapeDataString(item.Value) + " "); - } - - return sb.ToString(); - } - public string Protect(AuthenticationProperties data, string purpose) - { - return Protect(data); - } - - public AuthenticationProperties Unprotect(string protectedText) - { - if (string.IsNullOrEmpty(protectedText)) - { - return null; - } - - if (protectedText == "null") - { - return new AuthenticationProperties(); - } - - string[] items = protectedText.Split(' '); - if (items.Length % 2 != 0) - { - return null; - } - - var propeties = new AuthenticationProperties(); - for (int i = 0; i < items.Length - 1; i+=2) - { - propeties.Items.Add(items[i], items[i + 1]); - } - - return propeties; - } - - public AuthenticationProperties Unprotect(string protectedText, string purpose) - { - return Unprotect(protectedText); - } - } -} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs deleted file mode 100644 index 98df02ee61..0000000000 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/ExpectedQueryValues.cs +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; -using System.Text.Encodings.Web; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect -{ - /// - /// This helper class is used to check that query string parameters are as expected. - /// - public class ExpectedQueryValues - { - public ExpectedQueryValues(string authority, OpenIdConnectConfiguration configuration = null) - { - Authority = authority; - Configuration = configuration ?? TestUtilities.DefaultOpenIdConnectConfiguration; - } - - public static ExpectedQueryValues Defaults(string authority) - { - var result = new ExpectedQueryValues(authority); - result.Scope = OpenIdConnectScope.OpenIdProfile; - result.ResponseType = OpenIdConnectResponseType.CodeIdToken; - return result; - } - - public void CheckValues(string query, IEnumerable parameters) - { - var errors = new List(); - if (!query.StartsWith(ExpectedAuthority)) - { - errors.Add("ExpectedAuthority: " + ExpectedAuthority); - } - - foreach(var str in parameters) - { - if (str == OpenIdConnectParameterNames.ClientId) - { - if (!query.Contains(ExpectedClientId)) - errors.Add("ExpectedClientId: " + ExpectedClientId); - - continue; - } - - if (str == OpenIdConnectParameterNames.RedirectUri) - { - if(!query.Contains(ExpectedRedirectUri)) - errors.Add("ExpectedRedirectUri: " + ExpectedRedirectUri); - - continue; - } - - if (str == OpenIdConnectParameterNames.Resource) - { - if(!query.Contains(ExpectedResource)) - errors.Add("ExpectedResource: " + ExpectedResource); - - continue; - } - - if (str == OpenIdConnectParameterNames.ResponseMode) - { - if(!query.Contains(ExpectedResponseMode)) - errors.Add("ExpectedResponseMode: " + ExpectedResponseMode); - - continue; - } - - if (str == OpenIdConnectParameterNames.Scope) - { - if (!query.Contains(ExpectedScope)) - errors.Add("ExpectedScope: " + ExpectedScope); - - continue; - } - - if (str == OpenIdConnectParameterNames.State) - { - if (!query.Contains(ExpectedState)) - errors.Add("ExpectedState: " + ExpectedState); - - continue; - } - } - - if (errors.Count > 0) - { - var sb = new StringBuilder(); - sb.AppendLine("query string not as expected: " + Environment.NewLine + query + Environment.NewLine); - foreach (var str in errors) - { - sb.AppendLine(str); - } - - Debug.WriteLine(sb.ToString()); - Assert.True(false, sb.ToString()); - } - } - - public UrlEncoder Encoder { get; set; } = UrlEncoder.Default; - - public string Authority { get; set; } - - public string ClientId { get; set; } = Guid.NewGuid().ToString(); - - public string RedirectUri { get; set; } = Guid.NewGuid().ToString(); - - public OpenIdConnectRequestType RequestType { get; set; } = OpenIdConnectRequestType.Authentication; - - public string Resource { get; set; } = Guid.NewGuid().ToString(); - - public string ResponseMode { get; set; } = OpenIdConnectResponseMode.FormPost; - - public string ResponseType { get; set; } = Guid.NewGuid().ToString(); - - public string Scope { get; set; } = Guid.NewGuid().ToString(); - - public string State { get; set; } = Guid.NewGuid().ToString(); - - public string ExpectedAuthority - { - get - { - if (RequestType == OpenIdConnectRequestType.Token) - { - return Configuration?.EndSessionEndpoint ?? Authority + @"/oauth2/token"; - } - else if (RequestType == OpenIdConnectRequestType.Logout) - { - return Configuration?.TokenEndpoint ?? Authority + @"/oauth2/logout"; - } - - return Configuration?.AuthorizationEndpoint ?? Authority + (@"/oauth2/authorize"); - } - } - - public OpenIdConnectConfiguration Configuration { get; set; } - - public string ExpectedClientId - { - get { return OpenIdConnectParameterNames.ClientId + "=" + Encoder.Encode(ClientId); } - } - - public string ExpectedRedirectUri - { - get { return OpenIdConnectParameterNames.RedirectUri + "=" + Encoder.Encode(RedirectUri); } - } - - public string ExpectedResource - { - get { return OpenIdConnectParameterNames.Resource + "=" + Encoder.Encode(Resource); } - } - - public string ExpectedResponseMode - { - get { return OpenIdConnectParameterNames.ResponseMode + "=" + Encoder.Encode(ResponseMode); } - } - - public string ExpectedScope - { - get { return OpenIdConnectParameterNames.Scope + "=" + Encoder.Encode(Scope); } - } - - public string ExpectedState - { - get { return Encoder.Encode(State); } - } - } -} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/Infrastructure/TestDefaultValues.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/Infrastructure/TestDefaultValues.cs deleted file mode 100644 index de921bb96a..0000000000 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/Infrastructure/TestDefaultValues.cs +++ /dev/null @@ -1,10 +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.AspNetCore.Authentication.Tests.OpenIdConnect.Infrastructre -{ - internal class TestDefaultValues - { - public static readonly string DefaultAuthority = @"https://example.com/common"; - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs new file mode 100644 index 0000000000..432980f771 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs @@ -0,0 +1,21 @@ +using Microsoft.IdentityModel.Protocols.OpenIdConnect; + +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +{ + internal class MockOpenIdConnectMessage : OpenIdConnectMessage + { + public string TestAuthorizeEndpoint { get; set; } + + public string TestLogoutRequest { get; set; } + + public override string CreateAuthenticationRequestUrl() + { + return TestAuthorizeEndpoint ?? base.CreateAuthenticationRequestUrl(); + } + + public override string CreateLogoutRequestUrl() + { + return TestLogoutRequest ?? base.CreateLogoutRequestUrl(); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs new file mode 100644 index 0000000000..b2e2514d61 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -0,0 +1,322 @@ +// 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.Linq; +using System.Net; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +{ + public class OpenIdConnectChallengeTests + { + [Fact] + public async Task ChallengeIsIssuedCorrectly() + { + var settings = new TestSettings( + opt => opt.AuthenticationMethod = OpenIdConnectRedirectBehavior.RedirectGet); + + var server = settings.CreateTestServer(); + var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + + settings.ValidateChallengeRedirect( + res.Headers.Location, + OpenIdConnectParameterNames.ClientId, + OpenIdConnectParameterNames.ResponseType, + OpenIdConnectParameterNames.ResponseMode, + OpenIdConnectParameterNames.Scope, + OpenIdConnectParameterNames.RedirectUri); + } + + /* + Example of a form post + +
+ + + + + + + + +
+ + + */ + [Fact] + public async Task ChallengeIssueedCorrectlyForFormPost() + { + var settings = new TestSettings( + opt => opt.AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost); + + var server = settings.CreateTestServer(); + var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + + var res = transaction.Response; + Assert.Equal(HttpStatusCode.OK, res.StatusCode); + Assert.Equal("text/html", transaction.Response.Content.Headers.ContentType.MediaType); + + var body = await res.Content.ReadAsStringAsync(); + settings.ValidateChallengeFormPost( + body, + OpenIdConnectParameterNames.ClientId, + OpenIdConnectParameterNames.ResponseType, + OpenIdConnectParameterNames.ResponseMode, + OpenIdConnectParameterNames.Scope, + OpenIdConnectParameterNames.RedirectUri); + } + + [Theory] + [InlineData("sample_user_state")] + [InlineData(null)] + public async Task ChallengeCanSetUserStateThroughProperties(string userState) + { + var settings = new TestSettings(); + + var properties = new AuthenticationProperties(); + properties.Items.Add(OpenIdConnectDefaults.UserstatePropertiesKey, userState); + + var server = TestServerBuilder.CreateServer(settings.Options, handler: null, properties: properties); + var transaction = await TestTransaction.SendAsync(server, TestDefaultValues.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + + var values = settings.ValidateChallengeRedirect(res.Headers.Location); + var actualState = values[OpenIdConnectParameterNames.State]; + var actualProperties = settings.Options.StateDataFormat.Unprotect(actualState); + + Assert.Equal(userState ?? string.Empty, actualProperties.Items[OpenIdConnectDefaults.UserstatePropertiesKey]); + } + + [Theory] + [InlineData("sample_user_state")] + [InlineData(null)] + public async Task OnRedirectToIdentityProviderEventCanSetState(string userState) + { + var settings = new TestSettings(opt => + { + opt.Events = new OpenIdConnectEvents() + { + OnRedirectToIdentityProvider = context => + { + context.ProtocolMessage.State = userState; + return Task.FromResult(0); + } + }; + }); + + var server = settings.CreateTestServer(); + var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + + var values = settings.ValidateChallengeRedirect(res.Headers.Location); + var actualState = values[OpenIdConnectParameterNames.State]; + var actualProperties = settings.Options.StateDataFormat.Unprotect(actualState); + + if (userState != null) + { + Assert.Equal(userState, actualProperties.Items[OpenIdConnectDefaults.UserstatePropertiesKey]); + } + else + { + Assert.False(actualProperties.Items.ContainsKey(OpenIdConnectDefaults.UserstatePropertiesKey)); + } + } + + [Fact] + public async Task OnRedirectToIdentityProviderEventIsHit() + { + var eventIsHit = false; + var settings = new TestSettings( + opts => + { + opts.Events = new OpenIdConnectEvents() + { + OnRedirectToIdentityProvider = context => + { + eventIsHit = true; + return Task.FromResult(0); + } + }; + } + ); + + var server = settings.CreateTestServer(); + var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + + Assert.True(eventIsHit); + + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + + settings.ValidateChallengeRedirect( + res.Headers.Location, + OpenIdConnectParameterNames.ClientId, + OpenIdConnectParameterNames.ResponseType, + OpenIdConnectParameterNames.ResponseMode, + OpenIdConnectParameterNames.Scope, + OpenIdConnectParameterNames.RedirectUri); + } + + + [Fact] + public async Task OnRedirectToIdentityProviderEventCanReplaceValues() + { + var newClientId = Guid.NewGuid().ToString(); + + var settings = new TestSettings( + opts => + { + opts.Events = new OpenIdConnectEvents() + { + OnRedirectToIdentityProvider = context => + { + context.ProtocolMessage.ClientId = newClientId; + + return Task.FromResult(0); + } + }; + } + ); + + var server = settings.CreateTestServer(); + var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + + settings.ValidateChallengeRedirect( + res.Headers.Location, + OpenIdConnectParameterNames.ResponseType, + OpenIdConnectParameterNames.ResponseMode, + OpenIdConnectParameterNames.Scope, + OpenIdConnectParameterNames.RedirectUri); + + var actual = res.Headers.Location.Query.Trim('?').Split('&').Single(seg => seg.StartsWith($"{OpenIdConnectParameterNames.ClientId}=")); + Assert.Equal($"{OpenIdConnectParameterNames.ClientId}={newClientId}", actual); + } + + [Fact] + public async Task OnRedirectToIdentityProviderEventCanReplaceMessage() + { + var newMessage = new MockOpenIdConnectMessage + { + TestAuthorizeEndpoint = $"http://example.com/{Guid.NewGuid()}/oauth2/signin" + }; + + var settings = new TestSettings( + opts => + { + opts.Events = new OpenIdConnectEvents() + { + OnRedirectToIdentityProvider = context => + { + context.ProtocolMessage = newMessage; + + return Task.FromResult(0); + } + }; + } + ); + + var server = settings.CreateTestServer(); + var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + + // The CreateAuthenticationRequestUrl method is overridden MockOpenIdConnectMessage where + // query string is not generated and the authorization endpoint is replaced. + Assert.Equal(newMessage.TestAuthorizeEndpoint, res.Headers.Location.AbsoluteUri); + } + [Fact] + public async Task OnRedirectToIdentityProviderEventHandlesResponse() + { + var settings = new TestSettings( + opts => + { + opts.Events = new OpenIdConnectEvents() + { + OnRedirectToIdentityProvider = context => + { + context.HandleResponse(); + return Task.FromResult(0); + } + }; + } + ); + + var server = settings.CreateTestServer(); + var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + + var res = transaction.Response; + Assert.Equal(HttpStatusCode.OK, res.StatusCode); + Assert.Null(res.Headers.Location); + } + + // This test can be further refined. When one auth middleware skips, the authentication responsibility + // will be flowed to the next one. A dummy auth middleware can be added to ensure the correct logic. + [Fact] + public async Task OnRedirectToIdentityProviderEventSkipResponse() + { + var settings = new TestSettings( + opts => + { + opts.Events = new OpenIdConnectEvents() + { + OnRedirectToIdentityProvider = context => + { + context.SkipToNextMiddleware(); + return Task.FromResult(0); + } + }; + } + ); + + var server = settings.CreateTestServer(); + var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + + var res = transaction.Response; + Assert.Equal(HttpStatusCode.OK, res.StatusCode); + Assert.Null(res.Headers.Location); + } + + [Fact] + public async Task ChallengeSetsNonceAndStateCookies() + { + var settings = new TestSettings(); + var server = settings.CreateTestServer(); + var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + + var firstCookie = transaction.SetCookie.First(); + Assert.Contains(OpenIdConnectDefaults.CookieNoncePrefix, firstCookie); + Assert.Contains("expires", firstCookie); + + var secondCookie = transaction.SetCookie.Skip(1).First(); + Assert.StartsWith(".AspNetCore.Correlation.OpenIdConnect.", secondCookie); + Assert.Contains("expires", secondCookie); + } + + private static string ChallengeEndpoint => TestDefaultValues.TestHost + TestServerBuilder.Challenge; + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 4ada6ff859..3603c2bf40 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect.Infrastructre; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 5853e38967..4a750ea41d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -2,24 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Net; -using System.Net.Http; -using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; -using System.Xml.Linq; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect.Infrastructre; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; @@ -29,318 +16,47 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { static string noncePrefix = "OpenIdConnect." + "Nonce."; static string nonceDelimiter = "."; - const string Challenge = "/challenge"; - const string ChallengeWithOutContext = "/challengeWithOutContext"; - const string ChallengeWithProperties = "/challengeWithProperties"; const string DefaultHost = @"https://example.com"; - const string ExpectedAuthorizeRequest = @"https://example.com/common/oauth2/signin"; - const string ExpectedLogoutRequest = @"https://example.com/common/oauth2/logout"; const string Logout = "/logout"; - const string Signin = "/signin"; - const string Signout = "/signout"; - - [Fact] - public async Task ChallengeWillIssueHtmlFormWhenEnabled() - { - var server = CreateServer(new OpenIdConnectOptions - { - Authority = TestDefaultValues.DefaultAuthority, - ClientId = "Test Id", - Configuration = TestUtilities.DefaultOpenIdConnectConfiguration, - AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost - }); - var transaction = await SendAsync(server, DefaultHost + Challenge); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.Equal("text/html", transaction.Response.Content.Headers.ContentType.MediaType); - Assert.Contains("form", transaction.ResponseText); - } - - [Fact] - public async Task ChallengeWillSetDefaults() - { - var stateDataFormat = new AuthenticationPropertiesFormaterKeyValue(); - var queryValues = ExpectedQueryValues.Defaults(TestDefaultValues.DefaultAuthority); - queryValues.State = OpenIdConnectDefaults.AuthenticationPropertiesKey + "=" + stateDataFormat.Protect(new AuthenticationProperties()); - var server = CreateServer(GetOptions(DefaultParameters(), queryValues)); - - var transaction = await SendAsync(server, DefaultHost + Challenge); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - queryValues.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, DefaultParameters()); - } - - [Fact] - public async Task ChallengeWillSetNonceAndStateCookies() - { - var server = CreateServer(new OpenIdConnectOptions - { - Authority = TestDefaultValues.DefaultAuthority, - ClientId = "Test Id", - Configuration = TestUtilities.DefaultOpenIdConnectConfiguration - }); - var transaction = await SendAsync(server, DefaultHost + Challenge); - - var firstCookie = transaction.SetCookie.First(); - Assert.Contains(OpenIdConnectDefaults.CookieNoncePrefix, firstCookie); - Assert.Contains("expires", firstCookie); - - var secondCookie = transaction.SetCookie.Skip(1).First(); - Assert.StartsWith(".AspNetCore.Correlation.OpenIdConnect.", secondCookie); - Assert.Contains("expires", secondCookie); - } - - [Fact] - public async Task ChallengeWillUseOptionsProperties() - { - var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority); - var server = CreateServer(GetOptions(DefaultParameters(), queryValues)); - - var transaction = await SendAsync(server, DefaultHost + Challenge); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - queryValues.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, DefaultParameters()); - } - - /// - /// Tests RedirectForAuthenticationContext replaces the OpenIdConnectMesssage correctly. - /// - /// Task - [Fact] - public async Task ChallengeSettingMessage() - { - var configuration = new OpenIdConnectConfiguration - { - AuthorizationEndpoint = ExpectedAuthorizeRequest, - }; - - var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority, configuration) - { - RequestType = OpenIdConnectRequestType.Authentication - }; - var server = CreateServer(GetProtocolMessageOptions()); - var transaction = await SendAsync(server, DefaultHost + Challenge); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - queryValues.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, new string[] { }); - } /// /// Tests RedirectForSignOutContext replaces the OpenIdConnectMesssage correctly. - /// + /// summary> /// Task [Fact] public async Task SignOutSettingMessage() { - var configuration = new OpenIdConnectConfiguration + var setting = new TestSettings(opt => { - EndSessionEndpoint = ExpectedLogoutRequest - }; - - var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority, configuration) - { - RequestType = OpenIdConnectRequestType.Logout - }; - var server = CreateServer(GetProtocolMessageOptions()); - var transaction = await SendAsync(server, DefaultHost + Signout); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - queryValues.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, new string[] { }); - } - - private static OpenIdConnectOptions GetProtocolMessageOptions() - { - var options = new OpenIdConnectOptions(); - var fakeOpenIdRequestMessage = new FakeOpenIdConnectMessage(ExpectedAuthorizeRequest, ExpectedLogoutRequest); - options.AutomaticChallenge = true; - options.Events = new OpenIdConnectEvents() - { - OnRedirectToIdentityProvider = (context) => + opt.Configuration = new OpenIdConnectConfiguration { - context.ProtocolMessage = fakeOpenIdRequestMessage; - return Task.FromResult(0); - }, - OnRedirectToIdentityProviderForSignOut = (context) => - { - context.ProtocolMessage = fakeOpenIdRequestMessage; - return Task.FromResult(0); - } - }; - options.ClientId = "Test Id"; - options.Configuration = TestUtilities.DefaultOpenIdConnectConfiguration; - return options; - } - - private class FakeOpenIdConnectMessage : OpenIdConnectMessage - { - private readonly string _authorizeRequest; - private readonly string _logoutRequest; - - public FakeOpenIdConnectMessage(string authorizeRequest, string logoutRequest) - { - _authorizeRequest = authorizeRequest; - _logoutRequest = logoutRequest; - } - - public override string CreateAuthenticationRequestUrl() - { - return _authorizeRequest; - } - - public override string CreateLogoutRequestUrl() - { - return _logoutRequest; - } - } - - /// - /// Tests for users who want to add 'state'. There are two ways to do it. - /// 1. Users set 'state' (OpenIdConnectMessage.State) in the event. The runtime appends to that state. - /// 2. Users add to the AuthenticationProperties (context.AuthenticationProperties), values will be serialized. - /// - /// - /// - [Theory, MemberData("StateDataSet")] - public async Task ChallengeSettingState(string userState, string challenge) - { - var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority); - var stateDataFormat = new AuthenticationPropertiesFormaterKeyValue(); - var properties = new AuthenticationProperties(); - if (challenge == ChallengeWithProperties) - { - properties.Items.Add("item1", Guid.NewGuid().ToString()); - } - - var options = GetOptions(DefaultParameters(new string[] { OpenIdConnectParameterNames.State }), queryValues, stateDataFormat); - options.AutomaticChallenge = challenge.Equals(ChallengeWithOutContext); - options.Events = new OpenIdConnectEvents() - { - OnRedirectToIdentityProvider = context => - { - context.ProtocolMessage.State = userState; - context.ProtocolMessage.RedirectUri = queryValues.RedirectUri; - return Task.FromResult(null); - } - - }; - var server = CreateServer(options, null, properties); - - var transaction = await SendAsync(server, DefaultHost + challenge); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - - if (challenge != ChallengeWithProperties) - { - if (userState != null) - { - properties.Items.Add(OpenIdConnectDefaults.UserstatePropertiesKey, userState); - } - properties.Items.Add(OpenIdConnectDefaults.RedirectUriForCodePropertiesKey, queryValues.RedirectUri); - } - - queryValues.State = stateDataFormat.Protect(properties); - queryValues.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, DefaultParameters(new string[] { OpenIdConnectParameterNames.State })); - } - - public static TheoryData StateDataSet - { - get - { - var dataset = new TheoryData(); - dataset.Add(Guid.NewGuid().ToString(), Challenge); - dataset.Add(null, Challenge); - dataset.Add(Guid.NewGuid().ToString(), ChallengeWithOutContext); - dataset.Add(null, ChallengeWithOutContext); - dataset.Add(Guid.NewGuid().ToString(), ChallengeWithProperties); - dataset.Add(null, ChallengeWithProperties); - - return dataset; - } - } - - [Fact] - public async Task ChallengeWillUseEvents() - { - var queryValues = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority); - var queryValuesSetInEvent = new ExpectedQueryValues(TestDefaultValues.DefaultAuthority); - var options = GetOptions(DefaultParameters(), queryValues); - options.Events = new OpenIdConnectEvents() - { - OnRedirectToIdentityProvider = context => - { - context.ProtocolMessage.ClientId = queryValuesSetInEvent.ClientId; - context.ProtocolMessage.RedirectUri = queryValuesSetInEvent.RedirectUri; - context.ProtocolMessage.Resource = queryValuesSetInEvent.Resource; - context.ProtocolMessage.Scope = queryValuesSetInEvent.Scope; - return Task.FromResult(null); - } - }; - var server = CreateServer(options); - - var transaction = await SendAsync(server, DefaultHost + Challenge); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - queryValuesSetInEvent.CheckValues(transaction.Response.Headers.Location.AbsoluteUri, DefaultParameters()); - } - - private OpenIdConnectOptions GetOptions(List parameters, ExpectedQueryValues queryValues, ISecureDataFormat secureDataFormat = null) - { - var options = new OpenIdConnectOptions(); - foreach (var param in parameters) - { - if (param.Equals(OpenIdConnectParameterNames.ClientId)) - options.ClientId = queryValues.ClientId; - else if (param.Equals(OpenIdConnectParameterNames.Resource)) - options.Resource = queryValues.Resource; - else if (param.Equals(OpenIdConnectParameterNames.Scope)) - { - options.Scope.Clear(); - - foreach (var scope in queryValues.Scope.Split(' ')) - { - options.Scope.Add(scope); - } - } - } - - options.Authority = queryValues.Authority; - options.Configuration = queryValues.Configuration; - options.StateDataFormat = secureDataFormat ?? new AuthenticationPropertiesFormaterKeyValue(); - - return options; - } - - private List DefaultParameters(string[] additionalParams = null) - { - var parameters = - new List - { - OpenIdConnectParameterNames.ClientId, - OpenIdConnectParameterNames.Resource, - OpenIdConnectParameterNames.ResponseMode, - OpenIdConnectParameterNames.Scope, + EndSessionEndpoint = "https://example.com/signout_test/signout_request" }; + }); - if (additionalParams != null) - parameters.AddRange(additionalParams); + var server = setting.CreateTestServer(); - return parameters; - } + var transaction = await TestTransaction.SendAsync(server, DefaultHost + TestServerBuilder.Signout); + var res = transaction.Response; - private static void DefaultChallengeOptions(OpenIdConnectOptions options) - { - options.AuthenticationScheme = "OpenIdConnectHandlerTest"; - options.AutomaticChallenge = true; - options.ClientId = Guid.NewGuid().ToString(); - options.ConfigurationManager = TestUtilities.DefaultOpenIdConnectConfigurationManager; - options.StateDataFormat = new AuthenticationPropertiesFormaterKeyValue(); + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + + setting.ValidateSignoutRedirect(transaction.Response.Headers.Location); } [Fact] public async Task SignOutWithDefaultRedirectUri() { - var configuration = TestUtilities.DefaultOpenIdConnectConfiguration; - var server = CreateServer(new OpenIdConnectOptions + var configuration = TestDefaultValues.CreateDefaultOpenIdConnectConfiguration(); + var server = TestServerBuilder.CreateServer(new OpenIdConnectOptions { Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", Configuration = configuration }); - var transaction = await SendAsync(server, DefaultHost + Signout); + var transaction = await TestTransaction.SendAsync(server, DefaultHost + TestServerBuilder.Signout); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal(configuration.EndSessionEndpoint, transaction.Response.Headers.Location.AbsoluteUri); } @@ -348,8 +64,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Fact] public async Task SignOutWithCustomRedirectUri() { - var configuration = TestUtilities.DefaultOpenIdConnectConfiguration; - var server = CreateServer(new OpenIdConnectOptions + var configuration = TestDefaultValues.CreateDefaultOpenIdConnectConfiguration(); + var server = TestServerBuilder.CreateServer(new OpenIdConnectOptions { Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", @@ -357,7 +73,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect PostLogoutRedirectUri = "https://example.com/logout" }); - var transaction = await SendAsync(server, DefaultHost + Signout); + var transaction = await TestTransaction.SendAsync(server, DefaultHost + TestServerBuilder.Signout); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Contains(UrlEncoder.Default.Encode("https://example.com/logout"), transaction.Response.Headers.Location.AbsoluteUri); } @@ -365,8 +81,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Fact] public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properites() { - var configuration = TestUtilities.DefaultOpenIdConnectConfiguration; - var server = CreateServer(new OpenIdConnectOptions + var configuration = TestDefaultValues.CreateDefaultOpenIdConnectConfiguration(); + var server = TestServerBuilder.CreateServer(new OpenIdConnectOptions { Authority = TestDefaultValues.DefaultAuthority, ClientId = "Test Id", @@ -374,136 +90,13 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect PostLogoutRedirectUri = "https://example.com/logout" }); - var transaction = await SendAsync(server, "https://example.com/signout_with_specific_redirect_uri"); + var transaction = await TestTransaction.SendAsync(server, "https://example.com/signout_with_specific_redirect_uri"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Contains(UrlEncoder.Default.Encode("http://www.example.com/specific_redirect_uri"), transaction.Response.Headers.Location.AbsoluteUri); } - private static TestServer CreateServer(OpenIdConnectOptions options, Func handler = null, AuthenticationProperties properties = null) - { - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme - }); - app.UseOpenIdConnectAuthentication(options); - app.Use(async (context, next) => - { - var req = context.Request; - var res = context.Response; - - if (req.Path == new PathString(Challenge)) - { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme); - } - else if (req.Path == new PathString(ChallengeWithProperties)) - { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, properties); - } - else if (req.Path == new PathString(ChallengeWithOutContext)) - { - res.StatusCode = 401; - } - else if (req.Path == new PathString(Signin)) - { - // REVIEW: this used to just be res.SignIn() - await context.Authentication.SignInAsync(OpenIdConnectDefaults.AuthenticationScheme, new ClaimsPrincipal()); - } - else if (req.Path == new PathString(Signout)) - { - await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); - } - else if (req.Path == new PathString("/signout_with_specific_redirect_uri")) - { - await context.Authentication.SignOutAsync( - OpenIdConnectDefaults.AuthenticationScheme, - new AuthenticationProperties() { RedirectUri = "http://www.example.com/specific_redirect_uri" }); - } - else if (handler != null) - { - await handler(context); - } - else - { - await next(); - } - }); - }) - .ConfigureServices(services => - { - services.AddAuthentication(); - services.Configure(authOptions => - { - authOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - }); - return new TestServer(builder); - } - - private static async Task SendAsync(TestServer server, string uri, string cookieHeader = null) - { - var request = new HttpRequestMessage(HttpMethod.Get, uri); - if (!string.IsNullOrEmpty(cookieHeader)) - { - request.Headers.Add("Cookie", cookieHeader); - } - - var transaction = new Transaction - { - Request = request, - Response = await server.CreateClient().SendAsync(request), - }; - - if (transaction.Response.Headers.Contains("Set-Cookie")) - { - transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").ToList(); - } - - transaction.ResponseText = await transaction.Response.Content.ReadAsStringAsync(); - if (transaction.Response.Content != null && - transaction.Response.Content.Headers.ContentType != null && - transaction.Response.Content.Headers.ContentType.MediaType == "text/xml") - { - transaction.ResponseElement = XElement.Parse(transaction.ResponseText); - } - - return transaction; - } - - private class Transaction - { - public HttpRequestMessage Request { get; set; } - - public HttpResponseMessage Response { get; set; } - - public IList SetCookie { get; set; } - - public string ResponseText { get; set; } - - public XElement ResponseElement { get; set; } - - public string AuthenticationCookieValue - { - get - { - if (SetCookie != null && SetCookie.Count > 0) - { - var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNetCore.Cookie=")); - if (authCookie != null) - { - return authCookie.Substring(0, authCookie.IndexOf(';')); - } - } - - return null; - } - } - } - - [Fact] // Test Cases for calculating the expiration time of cookie from cookie name + [Fact] public void NonceCookieExpirationTime() { DateTime utcNow = DateTime.UtcNow; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestDefaultValues.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestDefaultValues.cs new file mode 100644 index 0000000000..c3e92a9042 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestDefaultValues.cs @@ -0,0 +1,48 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; + +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +{ + internal class TestDefaultValues + { + public static readonly string DefaultAuthority = @"https://login.microsoftonline.com/common"; + + public static readonly string TestHost = @"https://example.com"; + + public static OpenIdConnectOptions CreateOpenIdConnectOptions() => + new OpenIdConnectOptions + { + Authority = TestDefaultValues.DefaultAuthority, + ClientId = Guid.NewGuid().ToString(), + Configuration = TestDefaultValues.CreateDefaultOpenIdConnectConfiguration() + }; + + public static OpenIdConnectOptions CreateOpenIdConnectOptions(Action update) + { + var options = CreateOpenIdConnectOptions(); + + if (update != null) + { + update(options); + } + + return options; + } + + public static OpenIdConnectConfiguration CreateDefaultOpenIdConnectConfiguration() => + new OpenIdConnectConfiguration() + { + AuthorizationEndpoint = DefaultAuthority + "/oauth2/authorize", + EndSessionEndpoint = DefaultAuthority + "/oauth2/endsessionendpoint", + TokenEndpoint = DefaultAuthority + "/oauth2/token" + }; + + public static IConfigurationManager CreateDefaultOpenIdConnectConfigurationManager() => + new StaticConfigurationManager(CreateDefaultOpenIdConnectConfiguration()); + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs new file mode 100644 index 0000000000..f8ab6fdb09 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -0,0 +1,97 @@ +// 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.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; + +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +{ + internal class TestServerBuilder + { + public static readonly string Challenge = "/challenge"; + public static readonly string ChallengeWithOutContext = "/challengeWithOutContext"; + public static readonly string ChallengeWithProperties = "/challengeWithProperties"; + public static readonly string Signin = "/signin"; + public static readonly string Signout = "/signout"; + + public static TestServer CreateServer(OpenIdConnectOptions options) + { + return CreateServer(options, handler: null, properties: null); + } + + public static TestServer CreateServer( + OpenIdConnectOptions options, + Func handler, + AuthenticationProperties properties) + { + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme + }); + + app.UseOpenIdConnectAuthentication(options); + + app.Use(async (context, next) => + { + var req = context.Request; + var res = context.Response; + + if (req.Path == new PathString(Challenge)) + { + await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme); + } + else if (req.Path == new PathString(ChallengeWithProperties)) + { + await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, properties); + } + else if (req.Path == new PathString(ChallengeWithOutContext)) + { + res.StatusCode = 401; + } + else if (req.Path == new PathString(Signin)) + { + // REVIEW: this used to just be res.SignIn() + await context.Authentication.SignInAsync(OpenIdConnectDefaults.AuthenticationScheme, new ClaimsPrincipal()); + } + else if (req.Path == new PathString(Signout)) + { + await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); + } + else if (req.Path == new PathString("/signout_with_specific_redirect_uri")) + { + await context.Authentication.SignOutAsync( + OpenIdConnectDefaults.AuthenticationScheme, + new AuthenticationProperties() { RedirectUri = "http://www.example.com/specific_redirect_uri" }); + } + else if (handler != null) + { + await handler(context); + } + else + { + await next(); + } + }); + }) + .ConfigureServices(services => + { + services.AddAuthentication(); + services.Configure(authOptions => authOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); + }); + + return new TestServer(builder); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs new file mode 100644 index 0000000000..47605dccea --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -0,0 +1,230 @@ +// 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.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Text.Encodings.Web; +using System.Xml.Linq; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.TestHost; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +{ + /// + /// This helper class is used to check that query string parameters are as expected. + /// + internal class TestSettings + { + private readonly OpenIdConnectOptions _options; + + public TestSettings() : this(configure: null) + { + } + + public TestSettings(Action configure) + { + _options = TestDefaultValues.CreateOpenIdConnectOptions(configure); + } + + public TestSettings(OpenIdConnectOptions options) + { + _options = options; + } + + public OpenIdConnectOptions Options => _options; + + public UrlEncoder Encoder => UrlEncoder.Default; + + public string ExpectedState { get; set; } + + public TestServer CreateTestServer() => TestServerBuilder.CreateServer(Options); + + public IDictionary ValidateChallengeFormPost(string responseBody, params string[] parametersToValidate) + { + IDictionary formInputs = null; + var errors = new List(); + var xdoc = XDocument.Parse(responseBody.Replace("doctype", "DOCTYPE")); + var forms = xdoc.Descendants("form"); + if (forms.Count() != 1) + { + errors.Add("Only one form element is expected in response body."); + } + else + { + formInputs = forms.Single() + .Elements("input") + .ToDictionary(elem => elem.Attribute("name").Value, + elem => elem.Attribute("value").Value); + + ValidateParameters(formInputs, parametersToValidate, errors, htmlEncoded: false); + } + + if (errors.Any()) + { + var buf = new StringBuilder(); + buf.AppendLine($"The challenge form post is not valid."); + // buf.AppendLine(); + + foreach (var error in errors) + { + buf.AppendLine(error); + } + + Debug.WriteLine(buf.ToString()); + Assert.True(false, buf.ToString()); + } + + return formInputs; + } + + public IDictionary ValidateChallengeRedirect(Uri redirectUri, params string[] parametersToValidate) => + ValidateRedirectCore(redirectUri, OpenIdConnectRequestType.Authentication, parametersToValidate); + + public IDictionary ValidateSignoutRedirect(Uri redirectUri, params string[] parametersToValidate) => + ValidateRedirectCore(redirectUri, OpenIdConnectRequestType.Logout, parametersToValidate); + + private IDictionary ValidateRedirectCore(Uri redirectUri, OpenIdConnectRequestType requestType, string[] parametersToValidate) + { + var errors = new List(); + + // Validate the authority + ValidateExpectedAuthority(redirectUri.AbsoluteUri, errors, requestType); + + // Convert query to dictionary + var queryDict = string.IsNullOrEmpty(redirectUri.Query) ? + new Dictionary() : + redirectUri.Query.TrimStart('?').Split('&').Select(part => part.Split('=')).ToDictionary(parts => parts[0], parts => parts[1]); + + // Validate the query string parameters + ValidateParameters(queryDict, parametersToValidate, errors, htmlEncoded: true); + + if (errors.Any()) + { + var buf = new StringBuilder(); + buf.AppendLine($"The redirect uri is not valid."); + buf.AppendLine(redirectUri.AbsoluteUri); + + foreach (var error in errors) + { + buf.AppendLine(error); + } + + Debug.WriteLine(buf.ToString()); + Assert.True(false, buf.ToString()); + } + + return queryDict; + } + + private void ValidateParameters( + IDictionary actualValues, + IEnumerable parametersToValidate, + ICollection errors, + bool htmlEncoded) + { + foreach (var paramToValidate in parametersToValidate) + { + switch (paramToValidate) + { + case OpenIdConnectParameterNames.ClientId: + ValidateClientId(actualValues, errors, htmlEncoded); + break; + case OpenIdConnectParameterNames.ResponseType: + ValidateResponseType(actualValues, errors, htmlEncoded); + break; + case OpenIdConnectParameterNames.ResponseMode: + ValidateResponseMode(actualValues, errors, htmlEncoded); + break; + case OpenIdConnectParameterNames.Scope: + ValidateScope(actualValues, errors, htmlEncoded); + break; + case OpenIdConnectParameterNames.RedirectUri: + ValidateRedirectUri(actualValues, errors, htmlEncoded); + break; + case OpenIdConnectParameterNames.Resource: + ValidateResource(actualValues, errors, htmlEncoded); + break; + case OpenIdConnectParameterNames.State: + ValidateState(actualValues, errors, htmlEncoded); + break; + default: + throw new InvalidOperationException($"Unknown parameter \"{paramToValidate}\"."); + } + } + } + + private void ValidateExpectedAuthority(string absoluteUri, ICollection errors, OpenIdConnectRequestType requestType) + { + string expectedAuthority; + switch (requestType) + { + case OpenIdConnectRequestType.Token: + expectedAuthority = _options.Configuration?.TokenEndpoint ?? _options.Authority + @"/oauth2/token"; + break; + case OpenIdConnectRequestType.Logout: + expectedAuthority = _options.Configuration?.EndSessionEndpoint ?? _options.Authority + @"/oauth2/logout"; + break; + default: + expectedAuthority = _options.Configuration?.AuthorizationEndpoint ?? _options.Authority + @"/oauth2/authorize"; + break; + } + + if (!absoluteUri.StartsWith(expectedAuthority)) + { + errors.Add($"ExpectedAuthority: {expectedAuthority}"); + } + } + + private void ValidateClientId(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => + ValidateQueryParameter(OpenIdConnectParameterNames.ClientId, _options.ClientId, actualQuery, errors, htmlEncoded); + + private void ValidateResponseType(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => + ValidateQueryParameter(OpenIdConnectParameterNames.ResponseType, _options.ResponseType, actualQuery, errors, htmlEncoded); + + private void ValidateResponseMode(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => + ValidateQueryParameter(OpenIdConnectParameterNames.ResponseMode, _options.ResponseMode, actualQuery, errors, htmlEncoded); + + private void ValidateScope(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => + ValidateQueryParameter(OpenIdConnectParameterNames.Scope, string.Join(" ", _options.Scope), actualQuery, errors, htmlEncoded); + + private void ValidateRedirectUri(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => + ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, TestDefaultValues.TestHost + _options.CallbackPath, actualQuery, errors, htmlEncoded); + + private void ValidateResource(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => + ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, _options.Resource, actualQuery, errors, htmlEncoded); + + private void ValidateState(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => + ValidateQueryParameter(OpenIdConnectParameterNames.State, ExpectedState, actualQuery, errors, htmlEncoded); + + private void ValidateQueryParameter( + string parameterName, + string expectedValue, + IDictionary actualQuery, + ICollection errors, + bool htmlEncoded) + { + string actualValue; + if (actualQuery.TryGetValue(parameterName, out actualValue)) + { + if (htmlEncoded) + { + expectedValue = Encoder.Encode(expectedValue); + } + + if (actualValue != expectedValue) + { + errors.Add($"Query parameter {parameterName}'s expected value is {expectedValue} but its actual value is {actualValue}"); + } + } + else + { + errors.Add($"Query parameter {parameterName} is missing"); + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs new file mode 100644 index 0000000000..3bbd3152b3 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs @@ -0,0 +1,77 @@ +// 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.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using System.Xml.Linq; +using Microsoft.AspNetCore.TestHost; + +namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +{ + internal class TestTransaction + { + public static Task SendAsync(TestServer server, string url) + { + return SendAsync(server, url, cookieHeader: null); + } + + public static async Task SendAsync(TestServer server, string uri, string cookieHeader) + { + var request = new HttpRequestMessage(HttpMethod.Get, uri); + if (!string.IsNullOrEmpty(cookieHeader)) + { + request.Headers.Add("Cookie", cookieHeader); + } + + var transaction = new TestTransaction + { + Request = request, + Response = await server.CreateClient().SendAsync(request), + }; + + if (transaction.Response.Headers.Contains("Set-Cookie")) + { + transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").ToList(); + } + + transaction.ResponseText = await transaction.Response.Content.ReadAsStringAsync(); + if (transaction.Response.Content != null && + transaction.Response.Content.Headers.ContentType != null && + transaction.Response.Content.Headers.ContentType.MediaType == "text/xml") + { + transaction.ResponseElement = XElement.Parse(transaction.ResponseText); + } + + return transaction; + } + + public HttpRequestMessage Request { get; set; } + + public HttpResponseMessage Response { get; set; } + + public IList SetCookie { get; set; } + + public string ResponseText { get; set; } + + public XElement ResponseElement { get; set; } + + public string AuthenticationCookieValue + { + get + { + if (SetCookie != null && SetCookie.Count > 0) + { + var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNetCore.Cookie=")); + if (authCookie != null) + { + return authCookie.Substring(0, authCookie.IndexOf(';')); + } + } + + return null; + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestUtilities.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestUtilities.cs deleted file mode 100644 index 6247c85b43..0000000000 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestUtilities.cs +++ /dev/null @@ -1,37 +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.IdentityModel.Protocols; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; - -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect -{ - /// - /// These utilities are designed to test openidconnect related flows - /// - public class TestUtilities - { - public const string DefaultHost = @"http://localhost"; - - public static IConfigurationManager DefaultOpenIdConnectConfigurationManager - { - get - { - return new StaticConfigurationManager(DefaultOpenIdConnectConfiguration); - } - } - - public static OpenIdConnectConfiguration DefaultOpenIdConnectConfiguration - { - get - { - return new OpenIdConnectConfiguration() - { - AuthorizationEndpoint = @"https://login.microsoftonline.com/common/oauth2/authorize", - EndSessionEndpoint = @"https://login.microsoftonline.com/common/oauth2/endsessionendpoint", - TokenEndpoint = @"https://login.microsoftonline.com/common/oauth2/token", - }; - } - } - } -} From 562eb7054ac4d4b73a7d109484effff1ae6c4481 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 22 Aug 2016 22:12:11 -0700 Subject: [PATCH 613/900] Merge TestDefaultValues with TestServerBuilder --- .../OpenIdConnectChallengeTests.cs | 4 +- .../OpenIdConnectConfigurationTests.cs | 6 +-- .../OpenIdConnectMiddlewareTests.cs | 12 ++--- .../OpenIdConnect/TestDefaultValues.cs | 48 ------------------- .../OpenIdConnect/TestServerBuilder.cs | 37 +++++++++++++- .../OpenIdConnect/TestSettings.cs | 4 +- 6 files changed, 49 insertions(+), 62 deletions(-) delete mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestDefaultValues.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index b2e2514d61..bf0d9ff0e3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect properties.Items.Add(OpenIdConnectDefaults.UserstatePropertiesKey, userState); var server = TestServerBuilder.CreateServer(settings.Options, handler: null, properties: properties); - var transaction = await TestTransaction.SendAsync(server, TestDefaultValues.TestHost + TestServerBuilder.ChallengeWithProperties); + var transaction = await TestTransaction.SendAsync(server, TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); var res = transaction.Response; Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); @@ -317,6 +317,6 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect Assert.Contains("expires", secondCookie); } - private static string ChallengeEndpoint => TestDefaultValues.TestHost + TestServerBuilder.Challenge; + private static string ChallengeEndpoint => TestServerBuilder.TestHost + TestServerBuilder.Challenge; } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 3603c2bf40..0f5338c5c4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { var options = new OpenIdConnectOptions { - Authority = TestDefaultValues.DefaultAuthority, + Authority = TestServerBuilder.DefaultAuthority, ClientId = Guid.NewGuid().ToString(), SignInScheme = Guid.NewGuid().ToString() }; @@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect TestConfigurationException( new OpenIdConnectOptions { - Authority = TestDefaultValues.DefaultAuthority, + Authority = TestServerBuilder.DefaultAuthority, ClientId = Guid.NewGuid().ToString() }, ex => Assert.Equal("SignInScheme", ex.ParamName)); @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect new OpenIdConnectOptions { SignInScheme = "TestScheme", - Authority = TestDefaultValues.DefaultAuthority, + Authority = TestServerBuilder.DefaultAuthority, }, ex => Assert.Equal("ClientId", ex.ParamName)); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 4a750ea41d..f2ea922926 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -48,10 +48,10 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Fact] public async Task SignOutWithDefaultRedirectUri() { - var configuration = TestDefaultValues.CreateDefaultOpenIdConnectConfiguration(); + var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); var server = TestServerBuilder.CreateServer(new OpenIdConnectOptions { - Authority = TestDefaultValues.DefaultAuthority, + Authority = TestServerBuilder.DefaultAuthority, ClientId = "Test Id", Configuration = configuration }); @@ -64,10 +64,10 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Fact] public async Task SignOutWithCustomRedirectUri() { - var configuration = TestDefaultValues.CreateDefaultOpenIdConnectConfiguration(); + var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); var server = TestServerBuilder.CreateServer(new OpenIdConnectOptions { - Authority = TestDefaultValues.DefaultAuthority, + Authority = TestServerBuilder.DefaultAuthority, ClientId = "Test Id", Configuration = configuration, PostLogoutRedirectUri = "https://example.com/logout" @@ -81,10 +81,10 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Fact] public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properites() { - var configuration = TestDefaultValues.CreateDefaultOpenIdConnectConfiguration(); + var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); var server = TestServerBuilder.CreateServer(new OpenIdConnectOptions { - Authority = TestDefaultValues.DefaultAuthority, + Authority = TestServerBuilder.DefaultAuthority, ClientId = "Test Id", Configuration = configuration, PostLogoutRedirectUri = "https://example.com/logout" diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestDefaultValues.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestDefaultValues.cs deleted file mode 100644 index c3e92a9042..0000000000 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestDefaultValues.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Builder; -using Microsoft.IdentityModel.Protocols; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; - -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect -{ - internal class TestDefaultValues - { - public static readonly string DefaultAuthority = @"https://login.microsoftonline.com/common"; - - public static readonly string TestHost = @"https://example.com"; - - public static OpenIdConnectOptions CreateOpenIdConnectOptions() => - new OpenIdConnectOptions - { - Authority = TestDefaultValues.DefaultAuthority, - ClientId = Guid.NewGuid().ToString(), - Configuration = TestDefaultValues.CreateDefaultOpenIdConnectConfiguration() - }; - - public static OpenIdConnectOptions CreateOpenIdConnectOptions(Action update) - { - var options = CreateOpenIdConnectOptions(); - - if (update != null) - { - update(options); - } - - return options; - } - - public static OpenIdConnectConfiguration CreateDefaultOpenIdConnectConfiguration() => - new OpenIdConnectConfiguration() - { - AuthorizationEndpoint = DefaultAuthority + "/oauth2/authorize", - EndSessionEndpoint = DefaultAuthority + "/oauth2/endsessionendpoint", - TokenEndpoint = DefaultAuthority + "/oauth2/token" - }; - - public static IConfigurationManager CreateDefaultOpenIdConnectConfigurationManager() => - new StaticConfigurationManager(CreateDefaultOpenIdConnectConfiguration()); - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs index f8ab6fdb09..5a672093ea 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -12,17 +12,52 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { internal class TestServerBuilder { + public static readonly string DefaultAuthority = @"https://login.microsoftonline.com/common"; + public static readonly string TestHost = @"https://example.com"; public static readonly string Challenge = "/challenge"; public static readonly string ChallengeWithOutContext = "/challengeWithOutContext"; public static readonly string ChallengeWithProperties = "/challengeWithProperties"; public static readonly string Signin = "/signin"; public static readonly string Signout = "/signout"; + public static OpenIdConnectOptions CreateOpenIdConnectOptions() => + new OpenIdConnectOptions + { + Authority = DefaultAuthority, + ClientId = Guid.NewGuid().ToString(), + Configuration = CreateDefaultOpenIdConnectConfiguration() + }; + + public static OpenIdConnectOptions CreateOpenIdConnectOptions(Action update) + { + var options = CreateOpenIdConnectOptions(); + + if (update != null) + { + update(options); + } + + return options; + } + + public static OpenIdConnectConfiguration CreateDefaultOpenIdConnectConfiguration() => + new OpenIdConnectConfiguration() + { + AuthorizationEndpoint = DefaultAuthority + "/oauth2/authorize", + EndSessionEndpoint = DefaultAuthority + "/oauth2/endsessionendpoint", + TokenEndpoint = DefaultAuthority + "/oauth2/token" + }; + + public static IConfigurationManager CreateDefaultOpenIdConnectConfigurationManager() => + new StaticConfigurationManager(CreateDefaultOpenIdConnectConfiguration()); + public static TestServer CreateServer(OpenIdConnectOptions options) { return CreateServer(options, handler: null, properties: null); @@ -94,4 +129,4 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect return new TestServer(builder); } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 47605dccea..3e50a7abee 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public TestSettings(Action configure) { - _options = TestDefaultValues.CreateOpenIdConnectOptions(configure); + _options = TestServerBuilder.CreateOpenIdConnectOptions(configure); } public TestSettings(OpenIdConnectOptions options) @@ -193,7 +193,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect ValidateQueryParameter(OpenIdConnectParameterNames.Scope, string.Join(" ", _options.Scope), actualQuery, errors, htmlEncoded); private void ValidateRedirectUri(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, TestDefaultValues.TestHost + _options.CallbackPath, actualQuery, errors, htmlEncoded); + ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, TestServerBuilder.TestHost + _options.CallbackPath, actualQuery, errors, htmlEncoded); private void ValidateResource(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, _options.Resource, actualQuery, errors, htmlEncoded); From c5c11e81b35d99ecde3b528254215df804adc926 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 22 Aug 2016 22:18:52 -0700 Subject: [PATCH 614/900] Split TestTransaction, add extension to TestServer --- .../OpenIdConnectChallengeTests.cs | 20 ++++---- .../OpenIdConnectMiddlewareTests.cs | 8 +-- .../OpenIdConnect/TestServerExtensions.cs | 50 +++++++++++++++++++ .../OpenIdConnect/TestTransaction.cs | 37 -------------- 4 files changed, 64 insertions(+), 51 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index bf0d9ff0e3..78f84c04f5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect opt => opt.AuthenticationMethod = OpenIdConnectRedirectBehavior.RedirectGet); var server = settings.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); @@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect opt => opt.AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost); var server = settings.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; Assert.Equal(HttpStatusCode.OK, res.StatusCode); @@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect properties.Items.Add(OpenIdConnectDefaults.UserstatePropertiesKey, userState); var server = TestServerBuilder.CreateServer(settings.Options, handler: null, properties: properties); - var transaction = await TestTransaction.SendAsync(server, TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); var res = transaction.Response; Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); @@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect }); var server = settings.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); @@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect ); var server = settings.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + var transaction = await server.SendAsync(ChallengeEndpoint); Assert.True(eventIsHit); @@ -198,7 +198,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect ); var server = settings.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); @@ -239,7 +239,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect ); var server = settings.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); @@ -267,7 +267,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect ); var server = settings.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; Assert.Equal(HttpStatusCode.OK, res.StatusCode); @@ -294,7 +294,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect ); var server = settings.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; Assert.Equal(HttpStatusCode.OK, res.StatusCode); @@ -306,7 +306,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { var settings = new TestSettings(); var server = settings.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, ChallengeEndpoint); + var transaction = await server.SendAsync(ChallengeEndpoint); var firstCookie = transaction.SetCookie.First(); Assert.Contains(OpenIdConnectDefaults.CookieNoncePrefix, firstCookie); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index f2ea922926..959d64acea 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var server = setting.CreateTestServer(); - var transaction = await TestTransaction.SendAsync(server, DefaultHost + TestServerBuilder.Signout); + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); var res = transaction.Response; Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); @@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect Configuration = configuration }); - var transaction = await TestTransaction.SendAsync(server, DefaultHost + TestServerBuilder.Signout); + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal(configuration.EndSessionEndpoint, transaction.Response.Headers.Location.AbsoluteUri); } @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect PostLogoutRedirectUri = "https://example.com/logout" }); - var transaction = await TestTransaction.SendAsync(server, DefaultHost + TestServerBuilder.Signout); + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Contains(UrlEncoder.Default.Encode("https://example.com/logout"), transaction.Response.Headers.Location.AbsoluteUri); } @@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect PostLogoutRedirectUri = "https://example.com/logout" }); - var transaction = await TestTransaction.SendAsync(server, "https://example.com/signout_with_specific_redirect_uri"); + var transaction = await server.SendAsync("https://example.com/signout_with_specific_redirect_uri"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Contains(UrlEncoder.Default.Encode("http://www.example.com/specific_redirect_uri"), transaction.Response.Headers.Location.AbsoluteUri); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs new file mode 100644 index 0000000000..a7085966a4 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs @@ -0,0 +1,50 @@ +// 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.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using System.Xml.Linq; +using Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect; +using Microsoft.AspNetCore.TestHost; + +namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect +{ + internal static class TestServerExtensions + { + public static Task SendAsync(this TestServer server, string url) + { + return SendAsync(server, url, cookieHeader: null); + } + + public static async Task SendAsync(this TestServer server, string uri, string cookieHeader) + { + var request = new HttpRequestMessage(HttpMethod.Get, uri); + if (!string.IsNullOrEmpty(cookieHeader)) + { + request.Headers.Add("Cookie", cookieHeader); + } + + var transaction = new TestTransaction + { + Request = request, + Response = await server.CreateClient().SendAsync(request), + }; + + if (transaction.Response.Headers.Contains("Set-Cookie")) + { + transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").ToList(); + } + + transaction.ResponseText = await transaction.Response.Content.ReadAsStringAsync(); + if (transaction.Response.Content != null && + transaction.Response.Content.Headers.ContentType != null && + transaction.Response.Content.Headers.ContentType.MediaType == "text/xml") + { + transaction.ResponseElement = XElement.Parse(transaction.ResponseText); + } + + return transaction; + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs index 3bbd3152b3..745c41350a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs @@ -4,49 +4,12 @@ using System.Collections.Generic; using System.Linq; using System.Net.Http; -using System.Threading.Tasks; using System.Xml.Linq; -using Microsoft.AspNetCore.TestHost; namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { internal class TestTransaction { - public static Task SendAsync(TestServer server, string url) - { - return SendAsync(server, url, cookieHeader: null); - } - - public static async Task SendAsync(TestServer server, string uri, string cookieHeader) - { - var request = new HttpRequestMessage(HttpMethod.Get, uri); - if (!string.IsNullOrEmpty(cookieHeader)) - { - request.Headers.Add("Cookie", cookieHeader); - } - - var transaction = new TestTransaction - { - Request = request, - Response = await server.CreateClient().SendAsync(request), - }; - - if (transaction.Response.Headers.Contains("Set-Cookie")) - { - transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").ToList(); - } - - transaction.ResponseText = await transaction.Response.Content.ReadAsStringAsync(); - if (transaction.Response.Content != null && - transaction.Response.Content.Headers.ContentType != null && - transaction.Response.Content.Headers.ContentType.MediaType == "text/xml") - { - transaction.ResponseElement = XElement.Parse(transaction.ResponseText); - } - - return transaction; - } - public HttpRequestMessage Request { get; set; } public HttpResponseMessage Response { get; set; } From d887d74819a5406b8283e14437a08379f7698ab8 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 23 Aug 2016 21:27:00 -0700 Subject: [PATCH 615/900] Update OpenIdConnectChallengeTests 1. Set header and status code in OnRedirectToIdentityProviderEventHandlesResponse 2. Move field to the top --- .../OpenIdConnect/OpenIdConnectChallengeTests.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index 78f84c04f5..fc9338e2bf 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -14,6 +14,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { public class OpenIdConnectChallengeTests { + private static readonly string ChallengeEndpoint = TestServerBuilder.TestHost + TestServerBuilder.Challenge; + [Fact] public async Task ChallengeIsIssuedCorrectly() { @@ -259,7 +261,10 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { OnRedirectToIdentityProvider = context => { + context.Response.StatusCode = 410; + context.Response.Headers.Add("tea", "Oolong"); context.HandleResponse(); + return Task.FromResult(0); } }; @@ -270,7 +275,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; - Assert.Equal(HttpStatusCode.OK, res.StatusCode); + Assert.Equal(HttpStatusCode.Gone, res.StatusCode); + Assert.Equal("Oolong", res.Headers.GetValues("tea").Single()); Assert.Null(res.Headers.Location); } @@ -316,7 +322,5 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect Assert.StartsWith(".AspNetCore.Correlation.OpenIdConnect.", secondCookie); Assert.Contains("expires", secondCookie); } - - private static string ChallengeEndpoint => TestServerBuilder.TestHost + TestServerBuilder.Challenge; } } \ No newline at end of file From 59a86c17e2bfbad5ed2fe57f44a3054d17f07f89 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Wed, 24 Aug 2016 14:28:31 -0700 Subject: [PATCH 616/900] Update OpenIdConnectSample 1. Use bootstrap to enhance the view. 2. Html encoding 3. Improve readability --- samples/OpenIdConnectSample/Program.cs | 2 +- samples/OpenIdConnectSample/Startup.cs | 83 +++++++++++++++++++------- 2 files changed, 63 insertions(+), 22 deletions(-) diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs index b370c85a9e..49cbf139d6 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -13,7 +13,7 @@ namespace OpenIdConnectSample var host = new WebHostBuilder() .UseKestrel(options => { - //Configure SSL + // Configure SSL var serverCertificate = LoadCertificate(); options.UseHttps(serverCertificate); }) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 32d4739d19..37b753102b 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -1,5 +1,8 @@ using System; +using System.Collections.Generic; using System.Linq; +using System.Text.Encodings.Web; +using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Builder; @@ -80,20 +83,22 @@ namespace OpenIdConnectSample { if (context.Request.Path.Equals("/signedout")) { - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync($"You have been signed out.
{Environment.NewLine}"); - await context.Response.WriteAsync("Sign In"); - await context.Response.WriteAsync($""); + await WriteHtmlAsync(context.Response, async res => + { + await res.WriteAsync($"

You have been signed out.

"); + await res.WriteAsync("Sign In"); + }); return; } if (context.Request.Path.Equals("/signout")) { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync($"Signed out {context.User.Identity.Name}
{Environment.NewLine}"); - await context.Response.WriteAsync("Sign In"); - await context.Response.WriteAsync($""); + await WriteHtmlAsync(context.Response, async res => + { + await context.Response.WriteAsync($"

Signed out {HtmlEncode(context.User.Identity.Name)}

"); + await context.Response.WriteAsync("Sign In"); + }); return; } @@ -111,10 +116,11 @@ namespace OpenIdConnectSample if (context.Request.Path.Equals("/Account/AccessDenied")) { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync($"Access Denied for user {context.User.Identity.Name} to resource '{context.Request.Query["ReturnUrl"]}'
{Environment.NewLine}"); - await context.Response.WriteAsync("Sign Out"); - await context.Response.WriteAsync($""); + await WriteHtmlAsync(context.Response, async res => + { + await context.Response.WriteAsync($"

Access Denied for user {HtmlEncode(context.User.Identity.Name)} to resource '{HtmlEncode(context.Request.Query["ReturnUrl"])}'

"); + await context.Response.WriteAsync("Sign Out"); + }); return; } @@ -147,18 +153,53 @@ namespace OpenIdConnectSample return; } - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync($"Hello Authenticated User {user.Identity.Name}
{Environment.NewLine}"); - foreach (var claim in user.Claims) + + await WriteHtmlAsync(context.Response, async response => { - await context.Response.WriteAsync($"{claim.Type}: {claim.Value}
{Environment.NewLine}"); - } - await context.Response.WriteAsync("Restricted
"); - await context.Response.WriteAsync("Sign Out
"); - await context.Response.WriteAsync("Sign Out Remote
"); - await context.Response.WriteAsync($""); + await response.WriteAsync($"

Hello Authenticated User {HtmlEncode(user.Identity.Name)}

"); + await response.WriteAsync("Restricted"); + await response.WriteAsync("Sign Out"); + await response.WriteAsync("Sign Out Remote"); + + await response.WriteAsync("

Claims:

"); + await WriteTableHeader(response, new string[] { "Claim Type", "Value" }, context.User.Claims.Select(c => new string[] { c.Type, c.Value })); + }); }); } + + private static async Task WriteHtmlAsync(HttpResponse response, Func writeContent) + { + var bootstrap = ""; + + response.ContentType = "text/html"; + await response.WriteAsync($"{bootstrap}
"); + await writeContent(response); + await response.WriteAsync("
"); + } + + private static async Task WriteTableHeader(HttpResponse response, IEnumerable columns, IEnumerable> data) + { + await response.WriteAsync(""); + await response.WriteAsync(""); + foreach (var column in columns) + { + await response.WriteAsync($""); + } + await response.WriteAsync(""); + foreach (var row in data) + { + await response.WriteAsync(""); + foreach (var column in row) + { + await response.WriteAsync($""); + } + await response.WriteAsync(""); + } + await response.WriteAsync("
{HtmlEncode(column)}
{HtmlEncode(column)}
"); + } + + private static string HtmlEncode(string content) => + string.IsNullOrEmpty(content) ? string.Empty : HtmlEncoder.Default.Encode(content); } } From 0d5482685b5b7cc585294877689085592d0f79de Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 12 Jul 2016 14:27:12 -0700 Subject: [PATCH 617/900] Update OpenIdConnect.AzureAdSample --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index fcfc7b4df0..05c073b46a 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -20,8 +20,6 @@ namespace OpenIdConnect.AzureAdSample { public class Startup { - private const string GraphResourceID = "https://graph.windows.net"; - public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() @@ -103,7 +101,20 @@ namespace OpenIdConnect.AzureAdSample app.Run(async context => { - if (context.Request.Path.Equals("/signout")) + if (context.Request.Path.Equals("/signin")) + { + if (context.User.Identities.Any(identity => identity.IsAuthenticated)) + { + // User has already signed in + context.Response.Redirect("/"); + return; + } + + await context.Authentication.ChallengeAsync( + OpenIdConnectDefaults.AuthenticationScheme, + new AuthenticationProperties { RedirectUri = "/" }); + } + else if (context.Request.Path.Equals("/signout")) { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await WriteHtmlAsync(context.Response, From 26956c5ce1ddd7c2f1e7ffe044188514eb7a0617 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 28 Jul 2016 00:54:23 -0700 Subject: [PATCH 618/900] Update OIDC signout flow OIDC signout should return to CallbackPath then locally redirect to AuthProperties.RedirectUri --- .../OpenIdConnect.AzureAdSample/Startup.cs | 1 + .../LoggingExtensions.cs | 20 ++ .../OpenIdConnectHandler.cs | 250 +++++++++++------- .../OpenIdConnectOptions.cs | 12 +- .../RemoteAuthenticationHandler.cs | 1 + 5 files changed, 184 insertions(+), 100 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 05c073b46a..7e32ddf8d9 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -81,6 +81,7 @@ namespace OpenIdConnect.AzureAdSample ClientSecret = clientSecret, // for code flow Authority = authority, ResponseType = OpenIdConnectResponseType.CodeIdToken, + PostLogoutRedirectUri = "/usersignout", // GetClaimsFromUserInfoEndpoint = true, Events = new OpenIdConnectEvents() { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs index d0f3e12d90..7f2519f5fd 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -16,6 +16,7 @@ namespace Microsoft.Extensions.Logging private static Action _redeemingCodeForTokens; private static Action _enteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync; private static Action _enteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync; + private static Action _enteringOpenIdAuthenticationHandlerHandleSignOutAsync; private static Action _messageReceived; private static Action _messageReceivedContextHandledResponse; private static Action _messageReceivedContextSkipped; @@ -47,6 +48,7 @@ namespace Microsoft.Extensions.Logging private static Action _invalidSecurityTokenType; private static Action _unableToValidateIdToken; private static Action _postAuthenticationLocalRedirect; + private static Action _postSignOutRedirect; private static Action _remoteSignOutHandledResponse; private static Action _remoteSignOutSkipped; private static Action _remoteSignOut; @@ -72,6 +74,10 @@ namespace Microsoft.Extensions.Logging eventId: 4, logLevel: LogLevel.Trace, formatString: "Entering {OpenIdConnectHandlerType}'s HandleUnauthorizedAsync."); + _enteringOpenIdAuthenticationHandlerHandleSignOutAsync = LoggerMessage.Define( + eventId: 14, + logLevel: LogLevel.Trace, + formatString: "Entering {OpenIdConnectHandlerType}'s HandleSignOutAsync."); _postAuthenticationLocalRedirect = LoggerMessage.Define( eventId: 5, logLevel: LogLevel.Trace, @@ -180,6 +186,10 @@ namespace Microsoft.Extensions.Logging eventId: 32, logLevel: LogLevel.Debug, formatString: "TokenResponseReceived.Skipped"); + _postSignOutRedirect = LoggerMessage.Define( + eventId: 33, + logLevel: LogLevel.Trace, + formatString: "Using properties.RedirectUri for redirect post authentication: '{RedirectUri}'."); _userInformationReceived = LoggerMessage.Define( eventId: 35, logLevel: LogLevel.Trace, @@ -430,6 +440,11 @@ namespace Microsoft.Extensions.Logging _enteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync(logger, openIdConnectHandlerTypeName, null); } + public static void EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(this ILogger logger, string openIdConnectHandlerTypeName) + { + _enteringOpenIdAuthenticationHandlerHandleSignOutAsync(logger, openIdConnectHandlerTypeName, null); + } + public static void UserInformationReceived(this ILogger logger, string user) { _userInformationReceived(logger, user, null); @@ -440,6 +455,11 @@ namespace Microsoft.Extensions.Logging _postAuthenticationLocalRedirect(logger, redirectUri, null); } + public static void PostSignOutRedirect(this ILogger logger, string redirectUri) + { + _postSignOutRedirect(logger, redirectUri, null); + } + public static void RemoteSignOutHandledResponse(this ILogger logger) { _remoteSignOutHandledResponse(logger, null); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index df7caf3317..066803e99c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Primitives; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; @@ -68,7 +69,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { return await HandleRemoteSignOutAsync(); } - return await base.HandleRequestAsync(); + else if (Options.SignedOutCallbackPath.HasValue && Options.SignedOutCallbackPath == Request.Path) + { + return await HandleSignOutCallbackAsync(); + } + else + { + return await base.HandleRequestAsync(); + } } protected virtual async Task HandleRemoteSignOutAsync() @@ -79,12 +87,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { message = new OpenIdConnectMessage(Request.Query.Select(pair => new KeyValuePair(pair.Key, pair.Value))); } + // assumption: if the ContentType is "application/x-www-form-urlencoded" it should be safe to read as it is small. else if (string.Equals(Request.Method, "POST", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(Request.ContentType) // May have media/type; charset=utf-8, allow partial match. && Request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase) - && Request.Body.CanRead) { + && Request.Body.CanRead) + { var form = await Request.ReadFormAsync(); message = new OpenIdConnectMessage(form.Select(pair => new KeyValuePair(pair.Key, pair.Value))); } @@ -139,108 +149,134 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } /// - /// Handles Signout + /// Sign out the Relying Party from the OpenID provider /// - /// - protected override async Task HandleSignOutAsync(SignOutContext signout) + /// A task executing the sign out procedure + protected override async Task HandleSignOutAsync(SignOutContext context) { - if (signout != null) + if (context == null) { - if (_configuration == null && Options.ConfigurationManager != null) + return; + } + + Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); + + if (_configuration == null && Options.ConfigurationManager != null) + { + _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); + } + + var message = new OpenIdConnectMessage() + { + IssuerAddress = _configuration == null ? string.Empty : (_configuration.EndSessionEndpoint ?? string.Empty), + + // Redirect back of SigneOutCallbackPath first before user agent is redirected to actual post logout redirect uri + PostLogoutRedirectUri = BuildRedirectUriIfRelative(Options.SignedOutCallbackPath) + }; + + // Get the post redirect URI. + var properties = new AuthenticationProperties(context.Properties); + if (string.IsNullOrEmpty(properties.RedirectUri)) + { + properties.RedirectUri = BuildRedirectUriIfRelative(Options.PostLogoutRedirectUri); + if (string.IsNullOrWhiteSpace(properties.RedirectUri)) { - _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); - } - - var message = new OpenIdConnectMessage() - { - IssuerAddress = _configuration == null ? string.Empty : (_configuration.EndSessionEndpoint ?? string.Empty), - }; - - // Set End_Session_Endpoint in order: - // 1. properties.Redirect - // 2. Options.PostLogoutRedirectUri - var properties = new AuthenticationProperties(signout.Properties); - var logoutRedirectUri = properties.RedirectUri; - if (!string.IsNullOrEmpty(logoutRedirectUri)) - { - // Relative to PathBase - if (logoutRedirectUri.StartsWith("/", StringComparison.Ordinal)) - { - logoutRedirectUri = BuildRedirectUri(logoutRedirectUri); - } - message.PostLogoutRedirectUri = logoutRedirectUri; - } - else if (!string.IsNullOrEmpty(Options.PostLogoutRedirectUri)) - { - logoutRedirectUri = Options.PostLogoutRedirectUri; - // Relative to PathBase - if (logoutRedirectUri.StartsWith("/", StringComparison.Ordinal)) - { - logoutRedirectUri = BuildRedirectUri(logoutRedirectUri); - } - message.PostLogoutRedirectUri = logoutRedirectUri; - } - - // Attach the identity token to the logout request when possible. - message.IdTokenHint = await Context.Authentication.GetTokenAsync(Options.SignOutScheme, OpenIdConnectParameterNames.IdToken); - - var redirectContext = new RedirectContext(Context, Options, properties) - { - ProtocolMessage = message - }; - - await Options.Events.RedirectToIdentityProviderForSignOut(redirectContext); - if (redirectContext.HandledResponse) - { - Logger.RedirectToIdentityProviderForSignOutHandledResponse(); - return; - } - else if (redirectContext.Skipped) - { - Logger.RedirectToIdentityProviderForSignOutSkipped(); - return; - } - - message = redirectContext.ProtocolMessage; - - if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet) - { - var redirectUri = message.CreateLogoutRequestUrl(); - if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) - { - Logger.InvalidLogoutQueryStringRedirectUrl(redirectUri); - } - - Response.Redirect(redirectUri); - } - else if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.FormPost) - { - var inputs = new StringBuilder(); - foreach (var parameter in message.Parameters) - { - var name = HtmlEncoder.Encode(parameter.Key); - var value = HtmlEncoder.Encode(parameter.Value); - - var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value); - inputs.AppendLine(input); - } - - var issuer = HtmlEncoder.Encode(message.IssuerAddress); - - var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, issuer, inputs); - var buffer = Encoding.UTF8.GetBytes(content); - - Response.ContentLength = buffer.Length; - Response.ContentType = "text/html;charset=UTF-8"; - - // Emit Cache-Control=no-cache to prevent client caching. - Response.Headers[HeaderNames.CacheControl] = "no-cache"; - Response.Headers[HeaderNames.Pragma] = "no-cache"; - Response.Headers[HeaderNames.Expires] = "-1"; - - await Response.Body.WriteAsync(buffer, 0, buffer.Length); + properties.RedirectUri = CurrentUri; } } + Logger.PostSignOutRedirect(properties.RedirectUri); + + // Attach the identity token to the logout request when possible. + message.IdTokenHint = await Context.Authentication.GetTokenAsync(Options.SignOutScheme, OpenIdConnectParameterNames.IdToken); + + var redirectContext = new RedirectContext(Context, Options, properties) + { + ProtocolMessage = message + }; + + await Options.Events.RedirectToIdentityProviderForSignOut(redirectContext); + if (redirectContext.HandledResponse) + { + Logger.RedirectToIdentityProviderForSignOutHandledResponse(); + return; + } + else if (redirectContext.Skipped) + { + Logger.RedirectToIdentityProviderForSignOutSkipped(); + return; + } + + message = redirectContext.ProtocolMessage; + + if (!string.IsNullOrEmpty(message.State)) + { + properties.Items[OpenIdConnectDefaults.UserstatePropertiesKey] = message.State; + } + + message.State = Options.StateDataFormat.Protect(properties); + + if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet) + { + var redirectUri = message.CreateLogoutRequestUrl(); + if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) + { + Logger.InvalidLogoutQueryStringRedirectUrl(redirectUri); + } + + Response.Redirect(redirectUri); + } + else if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.FormPost) + { + var inputs = new StringBuilder(); + foreach (var parameter in message.Parameters) + { + var name = HtmlEncoder.Encode(parameter.Key); + var value = HtmlEncoder.Encode(parameter.Value); + + var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value); + inputs.AppendLine(input); + } + + var issuer = HtmlEncoder.Encode(message.IssuerAddress); + + var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, issuer, inputs); + var buffer = Encoding.UTF8.GetBytes(content); + + Response.ContentLength = buffer.Length; + Response.ContentType = "text/html;charset=UTF-8"; + + // Emit Cache-Control=no-cache to prevent client caching. + Response.Headers[HeaderNames.CacheControl] = "no-cache"; + Response.Headers[HeaderNames.Pragma] = "no-cache"; + Response.Headers[HeaderNames.Expires] = "-1"; + + await Response.Body.WriteAsync(buffer, 0, buffer.Length); + } + else + { + throw new NotImplementedException($"An unsupported authentication method has been configured: {Options.AuthenticationMethod}"); + } + } + + /// + /// Response to the callback from OpenId provider after session ended. + /// + /// A task executing the callback procedure + protected virtual Task HandleSignOutCallbackAsync() + { + StringValues protectedState; + if (Request.Query.TryGetValue("State", out protectedState)) + { + var properties = Options.StateDataFormat.Unprotect(protectedState); + if (!string.IsNullOrEmpty(properties.RedirectUri)) + { + Response.Redirect(properties.RedirectUri); + return Task.FromResult(true); + } + } + + Response.Redirect("/"); + return Task.FromResult(true); } /// @@ -1111,5 +1147,23 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return ticket; } + + /// + /// Build a redirect path if the given path is a relative path. + /// + private string BuildRedirectUriIfRelative(string uri) + { + if (string.IsNullOrEmpty(uri)) + { + return uri; + } + + if (!uri.StartsWith("/", StringComparison.Ordinal)) + { + return uri; + } + + return BuildRedirectUri(uri); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 181444b055..c3b18b2951 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -50,7 +50,9 @@ namespace Microsoft.AspNetCore.Builder AutomaticChallenge = true; DisplayName = OpenIdConnectDefaults.Caption; CallbackPath = new PathString("/signin-oidc"); + SignedOutCallbackPath = new PathString("/signout-callback-oidc"); RemoteSignOutPath = new PathString("/signout-oidc"); + Events = new OpenIdConnectEvents(); Scope.Add("openid"); Scope.Add("profile"); @@ -120,9 +122,15 @@ namespace Microsoft.AspNetCore.Builder }; /// - /// Gets or sets the 'post_logout_redirect_uri' + /// The request path within the application's base path where the user agent will be returned after sign out from the identity provider. /// - /// This is sent to the OP as the redirect for the user-agent. + public PathString SignedOutCallbackPath { get; set; } + + /// + /// The uri where the user agent will be returned to after application is signed out from the identity provider. + /// The redirect will happen after the is invoked. + /// + /// This URI is optional and it can be out of the application's domain. public string PostLogoutRedirectUri { get; set; } /// diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 4dfcc3662c..e34ee5fb55 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -26,6 +26,7 @@ namespace Microsoft.AspNetCore.Authentication { return await HandleRemoteCallbackAsync(); } + return false; } From 8f5c7aef57457d8b0792d8d5fccd35819d64d268 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 14 Jul 2016 15:20:06 -0700 Subject: [PATCH 619/900] Update tests --- .../OpenIdConnectOptions.cs | 2 +- .../OpenIdConnectMiddlewareTests.cs | 64 +++++++++++++++---- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index c3b18b2951..9bd5779239 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Builder /// /// The uri where the user agent will be returned to after application is signed out from the identity provider. - /// The redirect will happen after the is invoked. + /// The redirect will happen after the SignoutCallbackPath is invoked. /// /// This URI is optional and it can be out of the application's domain. public string PostLogoutRedirectUri { get; set; } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 959d64acea..2862e10537 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Linq; using System.Globalization; using System.Net; using System.Text.Encodings.Web; @@ -18,6 +19,9 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect static string nonceDelimiter = "."; const string DefaultHost = @"https://example.com"; const string Logout = "/logout"; + const string Signin = "/signin"; + const string Signout = "/signout"; + /// /// Tests RedirectForSignOutContext replaces the OpenIdConnectMesssage correctly. @@ -49,50 +53,86 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public async Task SignOutWithDefaultRedirectUri() { var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); - var server = TestServerBuilder.CreateServer(new OpenIdConnectOptions + var options = new OpenIdConnectOptions { Authority = TestServerBuilder.DefaultAuthority, ClientId = "Test Id", Configuration = configuration - }); + }; + var server = TestServerBuilder.CreateServer(options); var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal(configuration.EndSessionEndpoint, transaction.Response.Headers.Location.AbsoluteUri); + Assert.True(transaction.Response.Headers.Location.AbsoluteUri.StartsWith(configuration.EndSessionEndpoint)); + + var query = transaction.Response.Headers.Location.Query.Substring(1).Split('&') + .Select(each => each.Split('=')) + .ToDictionary(pair => pair[0], pair => pair[1]); + + string redirectUri; + Assert.True(query.TryGetValue("post_logout_redirect_uri", out redirectUri)); + Assert.Equal(UrlEncoder.Default.Encode("https://example.com" + options.SignedOutCallbackPath), redirectUri, true); } [Fact] public async Task SignOutWithCustomRedirectUri() { var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); - var server = TestServerBuilder.CreateServer(new OpenIdConnectOptions + var options = new OpenIdConnectOptions { Authority = TestServerBuilder.DefaultAuthority, ClientId = "Test Id", Configuration = configuration, - PostLogoutRedirectUri = "https://example.com/logout" - }); + SignedOutCallbackPath = "/thelogout", + PostLogoutRedirectUri = "https://example.com/postlogout" + }; + var server = TestServerBuilder.CreateServer(options); var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Contains(UrlEncoder.Default.Encode("https://example.com/logout"), transaction.Response.Headers.Location.AbsoluteUri); + + var query = transaction.Response.Headers.Location.Query.Substring(1).Split('&') + .Select(each => each.Split('=')) + .ToDictionary(pair => pair[0], pair => pair[1]); + + string redirectUri; + Assert.True(query.TryGetValue("post_logout_redirect_uri", out redirectUri)); + Assert.Equal(UrlEncoder.Default.Encode("https://example.com" + options.SignedOutCallbackPath), redirectUri, true); + + string state; + Assert.True(query.TryGetValue("state", out state)); + var properties = options.StateDataFormat.Unprotect(state); + Assert.Equal("https://example.com/postlogout", properties.RedirectUri, true); } [Fact] public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properites() { var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); - var server = TestServerBuilder.CreateServer(new OpenIdConnectOptions + var options = new OpenIdConnectOptions { Authority = TestServerBuilder.DefaultAuthority, ClientId = "Test Id", Configuration = configuration, - PostLogoutRedirectUri = "https://example.com/logout" - }); + PostLogoutRedirectUri = "https://example.com/postlogout" + }; + var server = TestServerBuilder.CreateServer(options); var transaction = await server.SendAsync("https://example.com/signout_with_specific_redirect_uri"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Contains(UrlEncoder.Default.Encode("http://www.example.com/specific_redirect_uri"), transaction.Response.Headers.Location.AbsoluteUri); + + var query = transaction.Response.Headers.Location.Query.Substring(1).Split('&') + .Select(each => each.Split('=')) + .ToDictionary(pair => pair[0], pair => pair[1]); + + string redirectUri; + Assert.True(query.TryGetValue("post_logout_redirect_uri", out redirectUri)); + Assert.Equal(UrlEncoder.Default.Encode("https://example.com" + options.SignedOutCallbackPath), redirectUri, true); + + string state; + Assert.True(query.TryGetValue("state", out state)); + var properties = options.StateDataFormat.Unprotect(state); + Assert.Equal("http://www.example.com/specific_redirect_uri", properties.RedirectUri, true); } // Test Cases for calculating the expiration time of cookie from cookie name @@ -149,4 +189,4 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect } } -} \ No newline at end of file +} From fa0a68a84718d16db4cf24214623da2f02ca398a Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 28 Jul 2016 01:14:36 -0700 Subject: [PATCH 620/900] Fix xml comments error --- .../OpenIdConnectOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 9bd5779239..5c8bf8c0a2 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Builder /// /// The uri where the user agent will be returned to after application is signed out from the identity provider. - /// The redirect will happen after the SignoutCallbackPath is invoked. + /// The redirect will happen after the SignedOutCallbackPath is invoked. /// /// This URI is optional and it can be out of the application's domain. public string PostLogoutRedirectUri { get; set; } From ed6984fab5a0bacdaea676276f078d7cdb0407ca Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 28 Jul 2016 10:05:50 -0700 Subject: [PATCH 621/900] Update signed out redirect url in sample --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 7e32ddf8d9..84558affb7 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -81,7 +81,7 @@ namespace OpenIdConnect.AzureAdSample ClientSecret = clientSecret, // for code flow Authority = authority, ResponseType = OpenIdConnectResponseType.CodeIdToken, - PostLogoutRedirectUri = "/usersignout", + PostLogoutRedirectUri = "/signed-out", // GetClaimsFromUserInfoEndpoint = true, Events = new OpenIdConnectEvents() { @@ -128,10 +128,16 @@ namespace OpenIdConnect.AzureAdSample else if (context.Request.Path.Equals("/signout-remote")) { await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties - { - RedirectUri = "/remote-signedout" - }); + await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); + } + else if (context.Request.Path.Equals("/signed-out")) + { + await WriteHtmlAsync(context.Response, + async response => + { + await response.WriteAsync($"

You have been signed out.

"); + await response.WriteAsync("Sign In"); + }); } else if (context.Request.Path.Equals("/remote-signedout")) { From c5509fb594aeeaa72a801c289f9979ad8276f1dd Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 28 Jul 2016 10:44:08 -0700 Subject: [PATCH 622/900] Minor update in OpenIdConnectHandler and Options 1. Default post sign out uri to the root of the applciation; 2. Throw ArgumentNullException for null context in HandleSignOutAsync; 3. Guard null from Unprotected; 4. Clean up code --- .../OpenIdConnectHandler.cs | 15 ++++++--------- .../OpenIdConnectOptions.cs | 5 ++--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 066803e99c..80e8c693be 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -73,10 +73,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { return await HandleSignOutCallbackAsync(); } - else - { - return await base.HandleRequestAsync(); - } + + return await base.HandleRequestAsync(); } protected virtual async Task HandleRemoteSignOutAsync() @@ -156,7 +154,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { if (context == null) { - return; + throw new ArgumentNullException(nameof(context)); } Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); @@ -168,9 +166,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var message = new OpenIdConnectMessage() { - IssuerAddress = _configuration == null ? string.Empty : (_configuration.EndSessionEndpoint ?? string.Empty), + IssuerAddress = _configuration?.EndSessionEndpoint ?? string.Empty, - // Redirect back of SigneOutCallbackPath first before user agent is redirected to actual post logout redirect uri + // Redirect back to SigneOutCallbackPath first before user agent is redirected to actual post logout redirect uri PostLogoutRedirectUri = BuildRedirectUriIfRelative(Options.SignedOutCallbackPath) }; @@ -268,14 +266,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (Request.Query.TryGetValue("State", out protectedState)) { var properties = Options.StateDataFormat.Unprotect(protectedState); - if (!string.IsNullOrEmpty(properties.RedirectUri)) + if (!string.IsNullOrEmpty(properties?.RedirectUri)) { Response.Redirect(properties.RedirectUri); return Task.FromResult(true); } } - Response.Redirect("/"); return Task.FromResult(true); } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 5c8bf8c0a2..12bc1c03d8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.IdentityModel.Tokens.Jwt; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OpenIdConnect; @@ -130,8 +129,8 @@ namespace Microsoft.AspNetCore.Builder /// The uri where the user agent will be returned to after application is signed out from the identity provider. /// The redirect will happen after the SignedOutCallbackPath is invoked. ///
- /// This URI is optional and it can be out of the application's domain. - public string PostLogoutRedirectUri { get; set; } + /// This URI can be out of the application's domain. By default it points to the root. + public string PostLogoutRedirectUri { get; set; } = "/"; /// /// Gets or sets if a metadata refresh should be attempted after a SecurityTokenSignatureKeyNotFoundException. This allows for automatic From a79a0360c18df26f34d96521ff72067f9f2666b7 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Fri, 29 Jul 2016 15:06:37 -0700 Subject: [PATCH 623/900] Update OpenIdConnectHandler --- .../OpenIdConnectHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 80e8c693be..7521ef39e8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -147,7 +147,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } /// - /// Sign out the Relying Party from the OpenID provider + /// Redirect user to the identity provider for sign out /// /// A task executing the sign out procedure protected override async Task HandleSignOutAsync(SignOutContext context) @@ -263,7 +263,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect protected virtual Task HandleSignOutCallbackAsync() { StringValues protectedState; - if (Request.Query.TryGetValue("State", out protectedState)) + if (Request.Query.TryGetValue(OpenIdConnectParameterNames.State, out protectedState)) { var properties = Options.StateDataFormat.Unprotect(protectedState); if (!string.IsNullOrEmpty(properties?.RedirectUri)) From 3a5df89f1c06868cc6dd67997ea492c227a977fc Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 8 Aug 2016 08:59:22 -0700 Subject: [PATCH 624/900] Move a nullref check to base class --- .../OpenIdConnectHandler.cs | 5 ----- .../AuthenticationHandler.cs | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 7521ef39e8..e5dcbbdeb7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -152,11 +152,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// A task executing the sign out procedure protected override async Task HandleSignOutAsync(SignOutContext context) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); if (_configuration == null && Options.ConfigurationManager != null) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 1e642d82dd..f992cde009 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -288,6 +288,11 @@ namespace Microsoft.AspNetCore.Authentication public async Task SignOutAsync(SignOutContext context) { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + if (ShouldHandleScheme(context.AuthenticationScheme, handleAutomatic: false)) { SignOutAccepted = true; From cbbec15d37f85187d6d32252ed84887dde5b2798 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Fri, 26 Aug 2016 11:46:29 -0700 Subject: [PATCH 625/900] Ignore null ExpiresUtc property in RequestRefresh Issue: https://github.com/aspnet/Security/issues/949 --- .../CookieAuthenticationHandler.cs | 16 ++++--- .../Cookies/CookieMiddlewareTests.cs | 45 +++++++++++++++++++ 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index f11f69e1c9..7c583ed7e1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -57,11 +57,17 @@ namespace Microsoft.AspNetCore.Authentication.Cookies private void RequestRefresh(AuthenticationTicket ticket) { - _shouldRefresh = true; - var currentUtc = Options.SystemClock.UtcNow; - _refreshIssuedUtc = currentUtc; - var timeSpan = ticket.Properties.ExpiresUtc.Value.Subtract(ticket.Properties.IssuedUtc.Value); - _refreshExpiresUtc = currentUtc.Add(timeSpan); + var issuedUtc = ticket.Properties.IssuedUtc; + var expiresUtc = ticket.Properties.ExpiresUtc; + + if (issuedUtc != null && expiresUtc != null) + { + _shouldRefresh = true; + var currentUtc = Options.SystemClock.UtcNow; + _refreshIssuedUtc = currentUtc; + var timeSpan = expiresUtc.Value.Subtract(issuedUtc.Value); + _refreshExpiresUtc = currentUtc.Add(timeSpan); + } } private async Task ReadCookieTicket() diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 942b1c4a5f..e6f881fefc 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -1214,6 +1214,51 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); } + // Issue: https://github.com/aspnet/Security/issues/949 + [Fact] + public async Task NullExpiresUtcPropertyIsGuarded() + { + var builder = new WebHostBuilder() + .ConfigureServices(services => services.AddAuthentication()) + .Configure(app => + { + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = context => + { + context.Properties.ExpiresUtc = null; + context.ShouldRenew = true; + return Task.FromResult(0); + } + } + }); + + app.Run(async context => + { + if (context.Request.Path == "/signin") + { + await context.Authentication.SignInAsync( + CookieAuthenticationDefaults.AuthenticationScheme, + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))); + } + else + { + await context.Response.WriteAsync("ha+1"); + } + }); + }); + + var server = new TestServer(builder); + + var cookie = (await server.SendAsync("http://www.example.com/signin")).SetCookie.FirstOrDefault(); + Assert.NotNull(cookie); + + var transaction = await server.SendAsync("http://www.example.com/", cookie); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + private class NoOpDataProtector : IDataProtector { public IDataProtector CreateProtector(string purpose) From 5b323e5ba190f29ae4e93469d146fa2de1f45874 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Sun, 4 Sep 2016 18:04:55 -0700 Subject: [PATCH 626/900] Increase .travis.yml consistency between repos - aspnet/Universe#349 - minimize `dotnet` setup time; no need for caching - build with `--quiet` --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index efc1a57214..d7636fa329 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ addons: - libssl-dev - libunwind8 - zlib1g +env: + global: + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 mono: - 4.0.5 os: @@ -25,4 +29,4 @@ branches: before_install: - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: - - ./build.sh verify + - ./build.sh --quiet verify From ce0ed3d237e04dc23fe9618c74b0b2139b2e73a0 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 8 Sep 2016 10:01:53 -0700 Subject: [PATCH 627/900] Use TaskCache class from Microsoft.Extensions.TaskCache.Sources (#968) Instead of Task.FromResult(0) --- .../Events/CookieAuthenticationEvents.cs | 17 +++++++++-------- .../project.json | 4 ++++ .../Events/JwtBearerEvents.cs | 9 +++++---- .../project.json | 4 ++++ .../Events/OAuthEvents.cs | 5 +++-- .../project.json | 4 ++++ .../Events/OpenIdConnectEvents.cs | 19 ++++++++++--------- .../project.json | 4 ++++ .../Events/TwitterEvents.cs | 5 +++-- .../project.json | 4 ++++ .../AuthenticationHandler.cs | 6 +++--- .../ClaimsTransformationHandler.cs | 7 ++++--- .../Events/RemoteAuthenticationEvents.cs | 5 +++-- .../project.json | 4 ++++ .../ClaimsAuthorizationRequirement.cs | 3 ++- .../DenyAnonymousAuthorizationRequirement.cs | 3 ++- .../NameAuthorizationRequirement.cs | 3 ++- .../RolesAuthorizationRequirement.cs | 3 ++- .../project.json | 6 +++++- 19 files changed, 77 insertions(+), 38 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs index ffe687e5f2..4364a2e546 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs @@ -4,6 +4,7 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -17,22 +18,22 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnValidatePrincipal { get; set; } = context => Task.FromResult(0); + public Func OnValidatePrincipal { get; set; } = context => TaskCache.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnSigningIn { get; set; } = context => Task.FromResult(0); + public Func OnSigningIn { get; set; } = context => TaskCache.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnSignedIn { get; set; } = context => Task.FromResult(0); + public Func OnSignedIn { get; set; } = context => TaskCache.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnSigningOut { get; set; } = context => Task.FromResult(0); + public Func OnSigningOut { get; set; } = context => TaskCache.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. @@ -48,7 +49,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { context.Response.Redirect(context.RedirectUri); } - return Task.FromResult(0); + return TaskCache.CompletedTask; }; /// @@ -65,7 +66,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { context.Response.Redirect(context.RedirectUri); } - return Task.FromResult(0); + return TaskCache.CompletedTask; }; /// @@ -81,7 +82,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { context.Response.Redirect(context.RedirectUri); } - return Task.FromResult(0); + return TaskCache.CompletedTask; }; /// @@ -97,7 +98,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { context.Response.Redirect(context.RedirectUri); } - return Task.FromResult(0); + return TaskCache.CompletedTask; }; private static bool IsAjaxRequest(HttpRequest request) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index 7ddff7ce8c..1317797b6a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -23,6 +23,10 @@ "dependencies": { "Microsoft.AspNetCore.Authentication": "1.1.0-*", "Microsoft.Extensions.Options": "1.1.0-*", + "Microsoft.Extensions.TaskCache.Sources": { + "version": "1.1.0-*", + "type": "build" + }, "Microsoft.Extensions.WebEncoders": "1.1.0-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs index 38a877f668..8ac1c3631e 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.JwtBearer { @@ -14,22 +15,22 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. /// - public Func OnAuthenticationFailed { get; set; } = context => Task.FromResult(0); + public Func OnAuthenticationFailed { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked when a protocol message is first received. /// - public Func OnMessageReceived { get; set; } = context => Task.FromResult(0); + public Func OnMessageReceived { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. /// - public Func OnTokenValidated { get; set; } = context => Task.FromResult(0); + public Func OnTokenValidated { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked before a challenge is sent back to the caller. /// - public Func OnChallenge { get; set; } = context => Task.FromResult(0); + public Func OnChallenge { get; set; } = context => TaskCache.CompletedTask; public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 2f8ea6072a..7697e9b691 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -22,6 +22,10 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.Extensions.TaskCache.Sources": { + "version": "1.1.0-*", + "type": "build" + }, "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs index 44c4260516..066b324b75 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.OAuth { @@ -14,7 +15,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// Gets or sets the function that is invoked when the CreatingTicket method is invoked. /// - public Func OnCreatingTicket { get; set; } = context => Task.FromResult(0); + public Func OnCreatingTicket { get; set; } = context => TaskCache.CompletedTask; /// /// Gets or sets the delegate that is invoked when the RedirectToAuthorizationEndpoint method is invoked. @@ -22,7 +23,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth public Func OnRedirectToAuthorizationEndpoint { get; set; } = context => { context.Response.Redirect(context.RedirectUri); - return Task.FromResult(0); + return TaskCache.CompletedTask; }; /// diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index 192801ced6..0365178576 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -22,6 +22,10 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.Extensions.TaskCache.Sources": { + "version": "1.1.0-*", + "type": "build" + }, "Newtonsoft.Json": "9.0.1" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index 42d35b7982..f39b554ece 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { @@ -14,47 +15,47 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. /// - public Func OnAuthenticationFailed { get; set; } = context => Task.FromResult(0); + public Func OnAuthenticationFailed { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked after security token validation if an authorization code is present in the protocol message. /// - public Func OnAuthorizationCodeReceived { get; set; } = context => Task.FromResult(0); + public Func OnAuthorizationCodeReceived { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked when a protocol message is first received. /// - public Func OnMessageReceived { get; set; } = context => Task.FromResult(0); + public Func OnMessageReceived { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked before redirecting to the identity provider to authenticate. /// - public Func OnRedirectToIdentityProvider { get; set; } = context => Task.FromResult(0); + public Func OnRedirectToIdentityProvider { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked before redirecting to the identity provider to sign out. /// - public Func OnRedirectToIdentityProviderForSignOut { get; set; } = context => Task.FromResult(0); + public Func OnRedirectToIdentityProviderForSignOut { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked when a request is received on the RemoteSignOutPath. /// - public Func OnRemoteSignOut { get; set; } = context => Task.FromResult(0); + public Func OnRemoteSignOut { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked after "authorization code" is redeemed for tokens at the token endpoint. /// - public Func OnTokenResponseReceived { get; set; } = context => Task.FromResult(0); + public Func OnTokenResponseReceived { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked when an IdToken has been validated and produced an AuthenticationTicket. /// - public Func OnTokenValidated { get; set; } = context => Task.FromResult(0); + public Func OnTokenValidated { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked when user information is retrieved from the UserInfoEndpoint. /// - public Func OnUserInformationReceived { get; set; } = context => Task.FromResult(0); + public Func OnUserInformationReceived { get; set; } = context => TaskCache.CompletedTask; public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 5243a96a73..53379f96d5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -22,6 +22,10 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.Extensions.TaskCache.Sources": { + "version": "1.1.0-*", + "type": "build" + }, "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs index 21c5b57a7f..033227542a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.Twitter { @@ -14,7 +15,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Gets or sets the function that is invoked when the Authenticated method is invoked. /// - public Func OnCreatingTicket { get; set; } = context => Task.FromResult(0); + public Func OnCreatingTicket { get; set; } = context => TaskCache.CompletedTask; /// /// Gets or sets the delegate that is invoked when the ApplyRedirect method is invoked. @@ -22,7 +23,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter public Func OnRedirectToAuthorizationEndpoint { get; set; } = context => { context.Response.Redirect(context.RedirectUri); - return Task.FromResult(0); + return TaskCache.CompletedTask; }; /// diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 8696821dd8..9d4aa7b4ed 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -22,6 +22,10 @@ }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.Extensions.TaskCache.Sources": { + "version": "1.1.0-*", + "type": "build" + }, "Newtonsoft.Json": "9.0.1" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index f992cde009..55cfa5b01c 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -142,7 +142,7 @@ namespace Microsoft.AspNetCore.Authentication /// protected virtual Task FinishResponseAsync() { - return Task.FromResult(0); + return TaskCache.CompletedTask; } private async Task HandleAutomaticChallengeIfNeeded() @@ -283,7 +283,7 @@ namespace Microsoft.AspNetCore.Authentication protected virtual Task HandleSignInAsync(SignInContext context) { - return Task.FromResult(0); + return TaskCache.CompletedTask; } public async Task SignOutAsync(SignOutContext context) @@ -308,7 +308,7 @@ namespace Microsoft.AspNetCore.Authentication protected virtual Task HandleSignOutAsync(SignOutContext context) { - return Task.FromResult(0); + return TaskCache.CompletedTask; } protected virtual Task HandleForbiddenAsync(ChallengeContext context) diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs index 7a2c47e401..27965dbf4e 100644 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication { @@ -48,7 +49,7 @@ namespace Microsoft.AspNetCore.Authentication { return PriorHandler.ChallengeAsync(context); } - return Task.FromResult(0); + return TaskCache.CompletedTask; } public void GetDescriptions(DescribeSchemesContext context) @@ -65,7 +66,7 @@ namespace Microsoft.AspNetCore.Authentication { return PriorHandler.SignInAsync(context); } - return Task.FromResult(0); + return TaskCache.CompletedTask; } public Task SignOutAsync(SignOutContext context) @@ -74,7 +75,7 @@ namespace Microsoft.AspNetCore.Authentication { return PriorHandler.SignOutAsync(context); } - return Task.FromResult(0); + return TaskCache.CompletedTask; } public void RegisterAuthenticationHandler(IHttpAuthenticationFeature auth) diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs index ee45b8afd9..6e7d6a35c6 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs @@ -3,14 +3,15 @@ using System; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication { public class RemoteAuthenticationEvents : IRemoteAuthenticationEvents { - public Func OnRemoteFailure { get; set; } = context => Task.FromResult(0); + public Func OnRemoteFailure { get; set; } = context => TaskCache.CompletedTask; - public Func OnTicketReceived { get; set; } = context => Task.FromResult(0); + public Func OnTicketReceived { get; set; } = context => TaskCache.CompletedTask; /// /// Invoked when there is a remote failure diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index 460549c7ba..958170ab7d 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -29,6 +29,10 @@ "type": "build", "version": "1.1.0-*" }, + "Microsoft.Extensions.TaskCache.Sources": { + "version": "1.1.0-*", + "type": "build" + }, "Microsoft.Extensions.Options": "1.1.0-*", "Microsoft.Extensions.WebEncoders": "1.1.0-*" }, diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs index 0e28ba0776..4248e4813d 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -67,7 +68,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure context.Succeed(requirement); } } - return Task.FromResult(0); + return TaskCache.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs index 7f2671775f..5bae319b3e 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -27,7 +28,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure { context.Succeed(requirement); } - return Task.FromResult(0); + return TaskCache.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs index aca1920d7d..9fb295082b 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs @@ -4,6 +4,7 @@ using System; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -46,7 +47,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure context.Succeed(requirement); } } - return Task.FromResult(0); + return TaskCache.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs index 6e5aa72247..44e2b9a220 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -61,7 +62,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure context.Succeed(requirement); } } - return Task.FromResult(0); + return TaskCache.CompletedTask; } } diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 8e72b62f82..303ba904a1 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -21,7 +21,11 @@ }, "dependencies": { "Microsoft.Extensions.Logging.Abstractions": "1.1.0-*", - "Microsoft.Extensions.Options": "1.1.0-*" + "Microsoft.Extensions.Options": "1.1.0-*", + "Microsoft.Extensions.TaskCache.Sources": { + "version": "1.1.0-*", + "type": "build" + } }, "frameworks": { "net451": { From e8f55bdb13a865210eb151f943b69a528fee6242 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 15 Sep 2016 16:12:54 -0700 Subject: [PATCH 628/900] Add Fail fast option for AuthZ --- .../AuthorizationOptions.cs | 6 ++ .../DefaultAuthorizationService.cs | 16 +++- .../DefaultAuthorizationServiceTests.cs | 75 +++++++++++++++++-- 3 files changed, 90 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs index fa9e9ef1ee..6899913afb 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -13,6 +13,12 @@ namespace Microsoft.AspNetCore.Authorization { private IDictionary PolicyMap { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); + /// + /// Determines whether authentication handlers should be invoked after a failure. + /// Defaults to true. + /// + public bool InvokeHandlersAfterFailure { get; set; } = true; + /// /// Gets or sets the default authorization policy. /// diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 89777eab01..8980d51ac6 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -8,6 +8,7 @@ using System.Security.Claims; using System.Security.Principal; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authorization { @@ -16,6 +17,7 @@ namespace Microsoft.AspNetCore.Authorization /// public class DefaultAuthorizationService : IAuthorizationService { + private readonly AuthorizationOptions _options; private readonly IAuthorizationHandlerContextFactory _contextFactory; private readonly IAuthorizationEvaluator _evaluator; private readonly IAuthorizationPolicyProvider _policyProvider; @@ -28,7 +30,7 @@ namespace Microsoft.AspNetCore.Authorization /// The used to provide policies. /// The handlers used to fulfill s. /// The logger used to log messages, warnings and errors. - public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) : this(policyProvider, handlers, logger, new DefaultAuthorizationHandlerContextFactory(), new DefaultAuthorizationEvaluator()) { } + public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) : this(policyProvider, handlers, logger, new DefaultAuthorizationHandlerContextFactory(), new DefaultAuthorizationEvaluator(), Options.Create(new AuthorizationOptions())) { } /// /// Creates a new instance of . @@ -38,8 +40,13 @@ namespace Microsoft.AspNetCore.Authorization /// The logger used to log messages, warnings and errors. /// The used to create the context to handle the authorization. /// The used to determine if authorzation was successful. - public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger, IAuthorizationHandlerContextFactory contextFactory, IAuthorizationEvaluator evaluator) + /// The used. + public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger, IAuthorizationHandlerContextFactory contextFactory, IAuthorizationEvaluator evaluator, IOptions options) { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } if (policyProvider == null) { throw new ArgumentNullException(nameof(policyProvider)); @@ -61,6 +68,7 @@ namespace Microsoft.AspNetCore.Authorization throw new ArgumentNullException(nameof(evaluator)); } + _options = options.Value; _handlers = handlers.ToArray(); _policyProvider = policyProvider; _logger = logger; @@ -89,6 +97,10 @@ namespace Microsoft.AspNetCore.Authorization foreach (var handler in _handlers) { await handler.HandleAsync(authContext); + if (!_options.InvokeHandlersAfterFailure && authContext.HasFailed) + { + break; + } } if (_evaluator.HasSucceeded(authContext)) diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 7f9e5642ae..039740ab2f 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -20,11 +20,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var services = new ServiceCollection(); services.AddAuthorization(); services.AddLogging(); - services.AddOptions(); - if (setupServices != null) - { - setupServices(services); - } + setupServices?.Invoke(services); return services.BuildServiceProvider().GetRequiredService(); } @@ -109,6 +105,72 @@ namespace Microsoft.AspNetCore.Authorization.Test Assert.True(allowed); } + public async Task Authorize_ShouldInvokeAllHandlersByDefault() + { + // Arrange + var handler1 = new FailHandler(); + var handler2 = new FailHandler(); + var authorizationService = BuildAuthorizationService(services => + { + services.AddSingleton(handler1); + services.AddSingleton(handler2); + services.AddAuthorization(options => + { + options.AddPolicy("Custom", policy => policy.Requirements.Add(new CustomRequirement())); + }); + }); + + // Act + var allowed = await authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "Custom"); + + // Assert + Assert.False(allowed); + Assert.True(handler1.Invoked); + Assert.True(handler2.Invoked); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task Authorize_ShouldInvokeAllHandlersDependingOnSetting(bool invokeAllHandlers) + { + // Arrange + var handler1 = new FailHandler(); + var handler2 = new FailHandler(); + var authorizationService = BuildAuthorizationService(services => + { + services.AddSingleton(handler1); + services.AddSingleton(handler2); + services.AddAuthorization(options => + { + options.InvokeHandlersAfterFailure = invokeAllHandlers; + options.AddPolicy("Custom", policy => policy.Requirements.Add(new CustomRequirement())); + }); + }); + + // Act + var allowed = await authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "Custom"); + + // Assert + Assert.False(allowed); + Assert.True(handler1.Invoked); + Assert.Equal(invokeAllHandlers, handler2.Invoked); + } + + private class FailHandler : IAuthorizationHandler + { + public bool Invoked { get; set; } + + public Task HandleAsync(AuthorizationHandlerContext context) + { + Invoked = true; + context.Fail(); + return Task.FromResult(0); + } + } + + + [Fact] public async Task Authorize_ShouldFailWhenAllRequirementsNotHandled() { @@ -584,8 +646,11 @@ namespace Microsoft.AspNetCore.Authorization.Test public class CustomRequirement : IAuthorizationRequirement { } public class CustomHandler : AuthorizationHandler { + public bool Invoked { get; set; } + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, CustomRequirement requirement) { + Invoked = true; context.Succeed(requirement); return Task.FromResult(0); } From 22d2fe99c6fd9806b36025399a217a3a8b4e50f4 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 15 Sep 2016 16:21:11 -0700 Subject: [PATCH 629/900] AddOptions in BuildAuthorizationService test helper --- .../DefaultAuthorizationServiceTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 039740ab2f..7b0fc8c8b9 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -20,6 +20,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var services = new ServiceCollection(); services.AddAuthorization(); services.AddLogging(); + services.AddOptions(); setupServices?.Invoke(services); return services.BuildServiceProvider().GetRequiredService(); } From e12838e38f5f8be8371c0a7b02d9ce47e0663ce0 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 21 Sep 2016 11:20:41 -0700 Subject: [PATCH 630/900] Auth: Always call prior handlers during Challenge --- .../AuthenticationHandler.cs | 14 ++++-- .../AuthenticationHandlerFacts.cs | 48 ++++++++++++++++++- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 55cfa5b01c..5e9a7c2381 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -311,6 +311,11 @@ namespace Microsoft.AspNetCore.Authentication return TaskCache.CompletedTask; } + /// + /// Override this method to deal with a challenge that is forbidden. + /// + /// + /// The returned boolean is ignored. protected virtual Task HandleForbiddenAsync(ChallengeContext context) { Response.StatusCode = 403; @@ -323,7 +328,7 @@ namespace Microsoft.AspNetCore.Authentication /// changing the 401 result to 302 of a login page or external sign-in location.) /// /// - /// True if no other handlers should be called + /// The returned boolean is no longer used. protected virtual Task HandleUnauthorizedAsync(ChallengeContext context) { Response.StatusCode = 401; @@ -333,7 +338,6 @@ namespace Microsoft.AspNetCore.Authentication public async Task ChallengeAsync(ChallengeContext context) { ChallengeCalled = true; - var handled = false; if (ShouldHandleScheme(context.AuthenticationScheme, Options.AutomaticChallenge)) { switch (context.Behavior) @@ -347,18 +351,18 @@ namespace Microsoft.AspNetCore.Authentication } goto case ChallengeBehavior.Unauthorized; case ChallengeBehavior.Unauthorized: - handled = await HandleUnauthorizedAsync(context); + await HandleUnauthorizedAsync(context); Logger.AuthenticationSchemeChallenged(Options.AuthenticationScheme); break; case ChallengeBehavior.Forbidden: - handled = await HandleForbiddenAsync(context); + await HandleForbiddenAsync(context); Logger.AuthenticationSchemeForbidden(Options.AuthenticationScheme); break; } context.Accept(); } - if (!handled && PriorHandler != null) + if (PriorHandler != null) { await PriorHandler.ChallengeAsync(context); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs index aa9aef07c2..2cf11669d3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs @@ -75,6 +75,49 @@ namespace Microsoft.AspNetCore.Authentication Assert.Equal(1, handler.AuthCount); } + // Prior to https://github.com/aspnet/Security/issues/930 we wouldn't call prior if handled + [Fact] + public async Task AuthHandlerChallengeAlwaysCallsPriorHandler() + { + var handler = await TestHandler.Create("Alpha"); + var previous = new PreviousHandler(); + + handler.PriorHandler = previous; + await handler.ChallengeAsync(new ChallengeContext("Alpha")); + Assert.True(previous.ChallengeCalled); + } + + private class PreviousHandler : IAuthenticationHandler + { + public bool ChallengeCalled = false; + + public Task AuthenticateAsync(AuthenticateContext context) + { + throw new NotImplementedException(); + } + + public Task ChallengeAsync(ChallengeContext context) + { + ChallengeCalled = true; + return Task.FromResult(0); + } + + public void GetDescriptions(DescribeSchemesContext context) + { + throw new NotImplementedException(); + } + + public Task SignInAsync(SignInContext context) + { + throw new NotImplementedException(); + } + + public Task SignOutAsync(SignOutContext context) + { + throw new NotImplementedException(); + } + } + private class CountOptions : AuthenticationOptions { } private class CountHandler : AuthenticationHandler @@ -109,6 +152,8 @@ namespace Microsoft.AspNetCore.Authentication { private TestHandler() { } + public AuthenticateResult Result = AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), new AuthenticationProperties(), "whatever")); + public static async Task Create(string scheme) { var handler = new TestHandler(); @@ -124,7 +169,7 @@ namespace Microsoft.AspNetCore.Authentication protected override Task HandleAuthenticateAsync() { - return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), new AuthenticationProperties(), "whatever"))); + return Task.FromResult(Result); } } @@ -220,7 +265,6 @@ namespace Microsoft.AspNetCore.Authentication set { - throw new NotImplementedException(); } } From aa1fd5d89a81aff26eb623976bf392ba469f4ff8 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 15 Sep 2016 15:11:47 -0700 Subject: [PATCH 631/900] Move ChunkingCookieManager to a separate Sources project --- Security.sln | 30 ++++- .../Resources.resx | 126 ------------------ .../project.json | 7 +- .../ChunkingCookieManager.cs | 26 +++- ...etCore.ChunkingCookieManager.Sources.xproj | 18 +++ .../project.json | 12 ++ .../CookieChunkingTests.cs | 2 +- ...e.ChunkingCookieManager.Sources.Test.xproj | 21 +++ .../project.json | 26 ++++ 9 files changed, 135 insertions(+), 133 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/Resources.resx rename src/{Microsoft.AspNetCore.Authentication.Cookies => Microsoft.AspNetCore.ChunkingCookieManager.Sources}/ChunkingCookieManager.cs (89%) create mode 100644 src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/Microsoft.AspNetCore.ChunkingCookieManager.Sources.xproj create mode 100644 src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json rename test/{Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure => Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test}/CookieChunkingTests.cs (98%) create mode 100644 test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.xproj create mode 100644 test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json diff --git a/Security.sln b/Security.sln index 2ed873270c..c84ec1bd96 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -57,6 +57,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Owin.Security.Int EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "OpenIdConnect.AzureAdSample", "samples\OpenIdConnect.AzureAdSample\OpenIdConnect.AzureAdSample.xproj", "{3A7AD414-EBDE-4F92-B307-4E8F19B6117E}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.ChunkingCookieManager.Sources", "src\Microsoft.AspNetCore.ChunkingCookieManager.Sources\Microsoft.AspNetCore.ChunkingCookieManager.Sources.xproj", "{2690FBE6-9D27-4C84-B82C-11188B0BCDA3}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test", "test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.xproj", "{51563775-C659-4907-9BAF-9995BAB87D01}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -325,6 +329,28 @@ Global {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|Mixed Platforms.Build.0 = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|x86.ActiveCfg = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|x86.Build.0 = Release|Any CPU + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Debug|x86.ActiveCfg = Debug|Any CPU + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Debug|x86.Build.0 = Debug|Any CPU + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Release|Any CPU.Build.0 = Release|Any CPU + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Release|x86.ActiveCfg = Release|Any CPU + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Release|x86.Build.0 = Release|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|x86.ActiveCfg = Debug|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|x86.Build.0 = Debug|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Release|Any CPU.ActiveCfg = Release|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Release|Any CPU.Build.0 = Release|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.ActiveCfg = Release|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -352,5 +378,7 @@ Global {A7922DD8-09F1-43E4-938B-CC523EA08898} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} + {2690FBE6-9D27-4C84-B82C-11188B0BCDA3} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Resources.resx b/src/Microsoft.AspNetCore.Authentication.Cookies/Resources.resx deleted file mode 100644 index 71debecfa3..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Resources.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - The cookie key and options are larger than ChunksSize, leaving no room for data. - - - The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded. - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index 1317797b6a..331de199ac 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -18,10 +18,15 @@ "nowarn": [ "CS1591" ], - "xmlDoc": true + "xmlDoc": true, + "define": [ "SECURITY" ] }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.AspNetCore.ChunkingCookieManager.Sources": { + "version": "1.1.0-*", + "type": "build" + }, "Microsoft.Extensions.Options": "1.1.0-*", "Microsoft.Extensions.TaskCache.Sources": { "version": "1.1.0-*", diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs similarity index 89% rename from src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs rename to src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs index c7bff38d1f..26fe0809c5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs +++ b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -9,6 +9,9 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; +// Keep the type public for Security repo as it would be a breaking change to change the accessor now. +// Make this type internal for other repos as it could be used by multiple projects and having it public causes type conflicts. +#if SECURITY namespace Microsoft.AspNetCore.Authentication.Cookies { /// @@ -17,6 +20,16 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// public class ChunkingCookieManager : ICookieManager { +#else +namespace Microsoft.AspNetCore.Internal +{ + /// + /// This handles cookies that are limited by per cookie length. It breaks down long cookies for responses, and reassembles them + /// from requests. + /// + internal class ChunkingCookieManager + { +#endif private const string ChunkKeySuffix = "C"; private const string ChunkCountPrefix = "chunks-"; @@ -96,7 +109,12 @@ namespace Microsoft.AspNetCore.Authentication.Cookies totalSize += chunks[i].Length; } throw new FormatException( - string.Format(CultureInfo.CurrentCulture, Resources.Exception_ImcompleteChunkedCookie, chunkId - 1, chunksCount, totalSize)); + string.Format( + CultureInfo.CurrentCulture, + "The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded.", + chunkId - 1, + chunksCount, + totalSize)); } // Missing chunk, abort by returning the original cookie value. It may have been a false positive? return value; @@ -162,7 +180,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { // 10 is the minimum data we want to put in an individual cookie, including the cookie chunk identifier "CXX". // No room for data, we can't chunk the options and name - throw new InvalidOperationException(Resources.Exception_CookieLimitTooSmall); + throw new InvalidOperationException("The cookie key and options are larger than ChunksSize, leaving no room for data."); } else { @@ -247,10 +265,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } var responseHeaders = context.Response.Headers; - var existingValues = responseHeaders[Constants.Headers.SetCookie]; + var existingValues = responseHeaders[HeaderNames.SetCookie]; if (!StringValues.IsNullOrEmpty(existingValues)) { - responseHeaders[Constants.Headers.SetCookie] = existingValues.Where(value => !rejectPredicate(value)).ToArray(); + responseHeaders[HeaderNames.SetCookie] = existingValues.Where(value => !rejectPredicate(value)).ToArray(); } AppendResponseCookie( diff --git a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/Microsoft.AspNetCore.ChunkingCookieManager.Sources.xproj b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/Microsoft.AspNetCore.ChunkingCookieManager.Sources.xproj new file mode 100644 index 0000000000..593e5d6816 --- /dev/null +++ b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/Microsoft.AspNetCore.ChunkingCookieManager.Sources.xproj @@ -0,0 +1,18 @@ + + + + 14.0.25420 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 2690fbe6-9d27-4c84-b82c-11188b0bcda3 + Microsoft.AspNetCore.ChunkingCookieManager.Sources + .\obj + .\bin\ + + + 2.0 + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json new file mode 100644 index 0000000000..a1a4f21841 --- /dev/null +++ b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json @@ -0,0 +1,12 @@ +{ + "version": "1.1.0-*", + "shared": "*.cs", + "dependencies": { + "Microsoft.AspNetCore.Http.Abstractions": "1.1.0-*", + "Microsoft.Net.Http.Headers": "1.1.0-*" + }, + "frameworks": { + "net451": {}, + "netstandard1.3": {} + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs similarity index 98% rename from test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs rename to test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs index 670baf5db4..c978d169e4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/Infrastructure/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs @@ -5,7 +5,7 @@ using System; using Microsoft.AspNetCore.Http; using Xunit; -namespace Microsoft.AspNetCore.Authentication.Cookies.Infrastructure +namespace Microsoft.AspNetCore.Internal { public class CookieChunkingTests { diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.xproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.xproj new file mode 100644 index 0000000000..d95a6c1287 --- /dev/null +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.xproj @@ -0,0 +1,21 @@ + + + + 14.0.25420 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 51563775-c659-4907-9baf-9995bab87d01 + Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test + .\obj + .\bin\ + + + 2.0 + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json new file mode 100644 index 0000000000..f5fab3f1e6 --- /dev/null +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json @@ -0,0 +1,26 @@ +{ + "buildOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "dotnet-test-xunit": "2.2.0-*", + "Microsoft.AspNetCore.ChunkingCookieManager.Sources": { + "version": "1.1.0-*", + "type": "build" + }, + "Microsoft.AspNetCore.Http": "1.1.0-*", + "xunit": "2.2.0-*" + }, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } + } + }, + "net451": {} + }, + "testRunner": "xunit" +} \ No newline at end of file From 25f39dd0f5f9a9199b720c2a53a2002cad26a8c4 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 20 Sep 2016 16:14:40 -0700 Subject: [PATCH 632/900] #859 Discriminate between providers when sharing an auth cookie --- .../RemoteAuthenticationHandler.cs | 12 +- .../Google/GoogleMiddlewareTests.cs | 263 +++++++++++++++++- 2 files changed, 272 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index e34ee5fb55..862193db15 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -17,6 +17,7 @@ namespace Microsoft.AspNetCore.Authentication private const string CorrelationPrefix = ".AspNetCore.Correlation."; private const string CorrelationProperty = ".xsrf"; private const string CorrelationMarker = "N"; + private const string AuthSchemeKey = ".AuthScheme"; private static readonly RandomNumberGenerator CryptoRandom = RandomNumberGenerator.Create(); @@ -86,6 +87,9 @@ namespace Microsoft.AspNetCore.Authentication // REVIEW: is this safe or good? ticket.Properties.RedirectUri = null; + // Mark which provider produced this identity so we can cross-check later in HandleAuthenticateAsync + context.Properties.Items[AuthSchemeKey] = Options.AuthenticationScheme; + await Options.Events.TicketReceived(context); if (context.HandledResponse) @@ -132,7 +136,11 @@ namespace Microsoft.AspNetCore.Authentication return AuthenticateResult.Fail(authenticateContext.Error); } - if (authenticateContext.Principal != null) + // The SignInScheme may be shared with multiple providers, make sure this middleware issued the identity. + string authenticatedScheme; + if (authenticateContext.Principal != null && authenticateContext.Properties != null + && authenticateContext.Properties.TryGetValue(AuthSchemeKey, out authenticatedScheme) + && string.Equals(Options.AuthenticationScheme, authenticatedScheme, StringComparison.Ordinal)) { return AuthenticateResult.Success(new AuthenticationTicket(authenticateContext.Principal, new AuthenticationProperties(authenticateContext.Properties), Options.AuthenticationScheme)); @@ -143,7 +151,7 @@ namespace Microsoft.AspNetCore.Authentication } - return AuthenticateResult.Fail("Remote authentication does not support authenticate"); + return AuthenticateResult.Fail("Remote authentication does not directly support authenticate"); } protected override Task HandleSignOutAsync(SignOutContext context) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 42cecf81bd..d0a2cfa195 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -215,7 +215,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } [Fact] - public async Task AuthenticateWillFail() + public async Task AuthenticateWithoutCookieWillFail() { var server = CreateServer(new GoogleOptions { @@ -755,6 +755,243 @@ namespace Microsoft.AspNetCore.Authentication.Google transaction.Response.Headers.GetValues("Location").First()); } + [Fact] + public async Task AuthenticateAutomaticWhenAlreadySignedInSucceeds() + { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var server = CreateServer(new GoogleOptions + { + ClientId = "Test Id", + ClientSecret = "Test Secret", + SaveTokens = true, + StateDataFormat = stateFormat, + BackchannelHttpHandler = CreateBackchannel() + }); + + // Skip the challenge step, go directly to the callback path + + var properties = new AuthenticationProperties(); + var correlationKey = ".xsrf"; + var correlationValue = "TestCorrelationId"; + properties.Items.Add(correlationKey, correlationValue); + properties.RedirectUri = "/me"; + var state = stateFormat.Protect(properties); + var transaction = await server.SendAsync( + "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), + $".AspNetCore.Correlation.Google.{correlationValue}=N"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); + Assert.Equal(2, transaction.SetCookie.Count); + Assert.Contains($".AspNetCore.Correlation.Google.{correlationValue}", transaction.SetCookie[0]); // Delete + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + + var authCookie = transaction.AuthenticationCookieValue; + transaction = await server.SendAsync("https://example.com/authenticate", authCookie); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + Assert.Equal("Test Name", transaction.FindClaimValue(ClaimTypes.Name)); + Assert.Equal("Test User ID", transaction.FindClaimValue(ClaimTypes.NameIdentifier)); + Assert.Equal("Test Given Name", transaction.FindClaimValue(ClaimTypes.GivenName)); + Assert.Equal("Test Family Name", transaction.FindClaimValue(ClaimTypes.Surname)); + Assert.Equal("Test email", transaction.FindClaimValue(ClaimTypes.Email)); + + // Ensure claims transformation + Assert.Equal("yup", transaction.FindClaimValue("xform")); + } + + [Fact] + public async Task AuthenticateGoogleWhenAlreadySignedInSucceeds() + { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var server = CreateServer(new GoogleOptions + { + ClientId = "Test Id", + ClientSecret = "Test Secret", + SaveTokens = true, + StateDataFormat = stateFormat, + BackchannelHttpHandler = CreateBackchannel() + }); + + // Skip the challenge step, go directly to the callback path + + var properties = new AuthenticationProperties(); + var correlationKey = ".xsrf"; + var correlationValue = "TestCorrelationId"; + properties.Items.Add(correlationKey, correlationValue); + properties.RedirectUri = "/me"; + var state = stateFormat.Protect(properties); + var transaction = await server.SendAsync( + "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), + $".AspNetCore.Correlation.Google.{correlationValue}=N"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); + Assert.Equal(2, transaction.SetCookie.Count); + Assert.Contains($".AspNetCore.Correlation.Google.{correlationValue}", transaction.SetCookie[0]); // Delete + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + + var authCookie = transaction.AuthenticationCookieValue; + transaction = await server.SendAsync("https://example.com/authenticateGoogle", authCookie); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + Assert.Equal("Test Name", transaction.FindClaimValue(ClaimTypes.Name)); + Assert.Equal("Test User ID", transaction.FindClaimValue(ClaimTypes.NameIdentifier)); + Assert.Equal("Test Given Name", transaction.FindClaimValue(ClaimTypes.GivenName)); + Assert.Equal("Test Family Name", transaction.FindClaimValue(ClaimTypes.Surname)); + Assert.Equal("Test email", transaction.FindClaimValue(ClaimTypes.Email)); + + // Ensure claims transformation + Assert.Equal("yup", transaction.FindClaimValue("xform")); + } + + [Fact] + public async Task ChallengeGoogleWhenAlreadySignedInReturnsForbidden() + { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var server = CreateServer(new GoogleOptions + { + ClientId = "Test Id", + ClientSecret = "Test Secret", + SaveTokens = true, + StateDataFormat = stateFormat, + BackchannelHttpHandler = CreateBackchannel() + }); + + // Skip the challenge step, go directly to the callback path + + var properties = new AuthenticationProperties(); + var correlationKey = ".xsrf"; + var correlationValue = "TestCorrelationId"; + properties.Items.Add(correlationKey, correlationValue); + properties.RedirectUri = "/me"; + var state = stateFormat.Protect(properties); + var transaction = await server.SendAsync( + "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), + $".AspNetCore.Correlation.Google.{correlationValue}=N"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); + Assert.Equal(2, transaction.SetCookie.Count); + Assert.Contains($".AspNetCore.Correlation.Google.{correlationValue}", transaction.SetCookie[0]); // Delete + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + + var authCookie = transaction.AuthenticationCookieValue; + transaction = await server.SendAsync("https://example.com/challenge", authCookie); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.StartsWith("https://example.com/Account/AccessDenied?", transaction.Response.Headers.Location.OriginalString); + } + + [Fact] + public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull() + { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var server = CreateServer(new GoogleOptions + { + ClientId = "Test Id", + ClientSecret = "Test Secret", + SaveTokens = true, + StateDataFormat = stateFormat, + BackchannelHttpHandler = CreateBackchannel() + }); + + // Skip the challenge step, go directly to the callback path + + var properties = new AuthenticationProperties(); + var correlationKey = ".xsrf"; + var correlationValue = "TestCorrelationId"; + properties.Items.Add(correlationKey, correlationValue); + properties.RedirectUri = "/me"; + var state = stateFormat.Protect(properties); + var transaction = await server.SendAsync( + "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), + $".AspNetCore.Correlation.Google.{correlationValue}=N"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); + Assert.Equal(2, transaction.SetCookie.Count); + Assert.Contains($".AspNetCore.Correlation.Google.{correlationValue}", transaction.SetCookie[0]); // Delete + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + + var authCookie = transaction.AuthenticationCookieValue; + transaction = await server.SendAsync("https://example.com/authenticateFacebook", authCookie); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + Assert.Equal(null, transaction.FindClaimValue(ClaimTypes.Name)); + } + + [Fact] + public async Task ChallengeFacebookWhenAlreadySignedWithGoogleSucceeds() + { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var server = CreateServer(new GoogleOptions + { + ClientId = "Test Id", + ClientSecret = "Test Secret", + SaveTokens = true, + StateDataFormat = stateFormat, + BackchannelHttpHandler = CreateBackchannel() + }); + + // Skip the challenge step, go directly to the callback path + + var properties = new AuthenticationProperties(); + var correlationKey = ".xsrf"; + var correlationValue = "TestCorrelationId"; + properties.Items.Add(correlationKey, correlationValue); + properties.RedirectUri = "/me"; + var state = stateFormat.Protect(properties); + var transaction = await server.SendAsync( + "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), + $".AspNetCore.Correlation.Google.{correlationValue}=N"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); + Assert.Equal(2, transaction.SetCookie.Count); + Assert.Contains($".AspNetCore.Correlation.Google.{correlationValue}", transaction.SetCookie[0]); // Delete + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + + var authCookie = transaction.AuthenticationCookieValue; + transaction = await server.SendAsync("https://example.com/challengeFacebook", authCookie); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.StartsWith("https://www.facebook.com/", transaction.Response.Headers.Location.OriginalString); + } + + private HttpMessageHandler CreateBackchannel() + { + return new TestHttpMessageHandler() + { + Sender = req => + { + if (req.RequestUri.AbsoluteUri == "https://www.googleapis.com/oauth2/v4/token") + { + return ReturnJsonResponse(new + { + access_token = "Test Access Token", + expires_in = 3600, + token_type = "Bearer" + }); + } + else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://www.googleapis.com/plus/v1/people/me") + { + return ReturnJsonResponse(new + { + id = "Test User ID", + displayName = "Test Name", + name = new + { + familyName = "Test Family Name", + givenName = "Test Given Name" + }, + url = "Profile link", + emails = new[] + { + new + { + value = "Test email", + type = "account" + } + } + }); + } + + throw new NotImplementedException(req.RequestUri.AbsoluteUri); + } + }; + } + private static HttpResponseMessage ReturnJsonResponse(object content, HttpStatusCode code = HttpStatusCode.OK) { var res = new HttpResponseMessage(code); @@ -774,6 +1011,11 @@ namespace Microsoft.AspNetCore.Authentication.Google AutomaticAuthenticate = true }); app.UseGoogleAuthentication(options); + app.UseFacebookAuthentication(new FacebookOptions() + { + AppId = "Test AppId", + AppSecret = "Test AppSecrent", + }); app.UseClaimsTransformation(context => { var id = new ClaimsIdentity("xform"); @@ -789,6 +1031,10 @@ namespace Microsoft.AspNetCore.Authentication.Google { await context.Authentication.ChallengeAsync("Google"); } + else if (req.Path == new PathString("/challengeFacebook")) + { + await context.Authentication.ChallengeAsync("Facebook"); + } else if (req.Path == new PathString("/tokens")) { var authContext = new AuthenticateContext(TestExtensions.CookieAuthenticationScheme); @@ -800,6 +1046,21 @@ namespace Microsoft.AspNetCore.Authentication.Google { res.Describe(context.User); } + else if (req.Path == new PathString("/authenticate")) + { + var user = await context.Authentication.AuthenticateAsync(Http.Authentication.AuthenticationManager.AutomaticScheme); + res.Describe(user); + } + else if (req.Path == new PathString("/authenticateGoogle")) + { + var user = await context.Authentication.AuthenticateAsync("Google"); + res.Describe(user); + } + else if (req.Path == new PathString("/authenticateFacebook")) + { + var user = await context.Authentication.AuthenticateAsync("Facebook"); + res.Describe(user); + } else if (req.Path == new PathString("/unauthorized")) { // Simulate Authorization failure From 5aae7ded010dd80dfb24ca17fc719ff4f4658cd6 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 22 Sep 2016 11:28:51 -0700 Subject: [PATCH 633/900] Update Twitter auth package description --- src/Microsoft.AspNetCore.Authentication.Twitter/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 9d4aa7b4ed..395f67b3fc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -1,6 +1,6 @@ { "version": "1.1.0-*", - "description": "ASP.NET Core middleware that enables an application to support Twitter's OAuth 2.0 authentication workflow.", + "description": "ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow.", "packOptions": { "repository": { "type": "git", From ddeef1f9ac09c34c2a2c28e35923ae7288b1049e Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Fri, 23 Sep 2016 10:23:50 -0700 Subject: [PATCH 634/900] Add prompt parameter to Google auth endpoint --- .../GoogleHandler.cs | 8 +++++--- .../Google/GoogleMiddlewareTests.cs | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 68cc6054f1..f28ab4d14a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -87,18 +87,20 @@ namespace Microsoft.AspNetCore.Authentication.Google // TODO: Abstract this properties override pattern into the base class? protected override string BuildChallengeUrl(AuthenticationProperties properties, string redirectUri) { - var scope = FormatScope(); + // Google Identity Platform Manual: + // https://developers.google.com/identity/protocols/OAuth2WebServer var queryStrings = new Dictionary(StringComparer.OrdinalIgnoreCase); queryStrings.Add("response_type", "code"); queryStrings.Add("client_id", Options.ClientId); queryStrings.Add("redirect_uri", redirectUri); - AddQueryString(queryStrings, properties, "scope", scope); - + AddQueryString(queryStrings, properties, "scope", FormatScope()); AddQueryString(queryStrings, properties, "access_type", Options.AccessType); AddQueryString(queryStrings, properties, "approval_prompt"); + AddQueryString(queryStrings, properties, "prompt"); AddQueryString(queryStrings, properties, "login_hint"); + AddQueryString(queryStrings, properties, "include_granted_scopes"); var state = Options.StateDataFormat.Protect(properties); queryStrings.Add("state", state); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index d0a2cfa195..944c322ad3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -43,8 +43,10 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Contains("&state=", location); Assert.DoesNotContain("access_type=", location); + Assert.DoesNotContain("prompt=", location); Assert.DoesNotContain("approval_prompt=", location); Assert.DoesNotContain("login_hint=", location); + Assert.DoesNotContain("include_granted_scopes=", location); } [Fact] @@ -177,7 +179,9 @@ namespace Microsoft.AspNetCore.Authentication.Google { "scope", "https://www.googleapis.com/auth/plus.login" }, { "access_type", "offline" }, { "approval_prompt", "force" }, - { "login_hint", "test@example.com" } + { "prompt", "consent" }, + { "login_hint", "test@example.com" }, + { "include_granted_scopes", "false" } })); } @@ -189,6 +193,8 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Contains("scope=" + UrlEncoder.Default.Encode("https://www.googleapis.com/auth/plus.login"), query); Assert.Contains("access_type=offline", query); Assert.Contains("approval_prompt=force", query); + Assert.Contains("prompt=consent", query); + Assert.Contains("include_granted_scopes=false", query); Assert.Contains("login_hint=" + UrlEncoder.Default.Encode("test@example.com"), query); } From 28932a779523dcfed5ee844bac1c85a7e9a00a6d Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Wed, 21 Sep 2016 16:18:59 -0700 Subject: [PATCH 635/900] Log the error inforamtion when redeem auth code --- .../LoggingExtensions.cs | 18 ++++- .../OpenIdConnectHandler.cs | 77 +++++++++++++++---- 2 files changed, 77 insertions(+), 18 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs index 7f2519f5fd..aa6d0cbaa7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -37,7 +37,8 @@ namespace Microsoft.Extensions.Logging private static Action _invalidLogoutQueryStringRedirectUrl; private static Action _nullOrEmptyAuthorizationResponseState; private static Action _unableToReadAuthorizationResponseState; - private static Action _authorizationResponseError; + private static Action _responseError; + private static Action _responseErrorWithStatusCode; private static Action _exceptionProcessingMessage; private static Action _accessTokenNotAvailable; private static Action _retrievingClaims; @@ -106,10 +107,14 @@ namespace Microsoft.Extensions.Logging eventId: 11, logLevel: LogLevel.Debug, formatString: "Unable to read the message.State."); - _authorizationResponseError = LoggerMessage.Define( + _responseError = LoggerMessage.Define( eventId: 12, logLevel: LogLevel.Error, formatString: "Message contains error: '{Error}', error_description: '{ErrorDescription}', error_uri: '{ErrorUri}'."); + _responseErrorWithStatusCode = LoggerMessage.Define( + eventId: 49, + logLevel: LogLevel.Error, + formatString: "Message contains error: '{Error}', error_description: '{ErrorDescription}', error_uri: '{ErrorUri}', status code '{StatusCode}'."); _updatingConfiguration = LoggerMessage.Define( eventId: 13, logLevel: LogLevel.Debug, @@ -380,9 +385,14 @@ namespace Microsoft.Extensions.Logging _unableToReadAuthorizationResponseState(logger, null); } - public static void AuthorizationResponseError(this ILogger logger, string error, string errorDescription, string errorUri) + public static void ResponseError(this ILogger logger, string error, string errorDescription, string errorUri) { - _authorizationResponseError(logger, error, errorDescription, errorUri, null); + _responseError(logger, error, errorDescription, errorUri, null); + } + + public static void ResponseErrorWithStatusCode(this ILogger logger, string error, string errorDescription, string errorUri, int statusCode) + { + _responseErrorWithStatusCode(logger, error, errorDescription, errorUri, statusCode, null); } public static void ExceptionProcessingMessage(this ILogger logger, Exception ex) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index e5dcbbdeb7..2039a76e90 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -507,14 +507,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // if any of the error fields are set, throw error null if (!string.IsNullOrEmpty(authorizationResponse.Error)) { - Logger.AuthorizationResponseError( - authorizationResponse.Error, - authorizationResponse.ErrorDescription ?? "ErrorDecription null", - authorizationResponse.ErrorUri ?? "ErrorUri null"); - - return AuthenticateResult.Fail(new OpenIdConnectProtocolException( - string.Format(CultureInfo.InvariantCulture, Resources.MessageContainsError, authorizationResponse.Error, - authorizationResponse.ErrorDescription ?? "ErrorDecription null", authorizationResponse.ErrorUri ?? "ErrorUri null"))); + return AuthenticateResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null)); } if (_configuration == null && Options.ConfigurationManager != null) @@ -590,6 +583,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { return result; } + authorizationResponse = tokenResponseReceivedContext.ProtocolMessage; tokenEndpointResponse = tokenResponseReceivedContext.TokenEndpointResponse; @@ -684,20 +678,50 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } /// - /// Redeems the authorization code for tokens at the token endpoint + /// Redeems the authorization code for tokens at the token endpoint. /// /// The request that will be sent to the token endpoint and is available for customization. /// OpenIdConnect message that has tokens inside it. protected virtual async Task RedeemAuthorizationCodeAsync(OpenIdConnectMessage tokenEndpointRequest) { Logger.RedeemingCodeForTokens(); + var requestMessage = new HttpRequestMessage(HttpMethod.Post, _configuration.TokenEndpoint); requestMessage.Content = new FormUrlEncodedContent(tokenEndpointRequest.Parameters); + var responseMessage = await Backchannel.SendAsync(requestMessage); - responseMessage.EnsureSuccessStatusCode(); - var tokenResonse = await responseMessage.Content.ReadAsStringAsync(); - var jsonTokenResponse = JObject.Parse(tokenResonse); - return new OpenIdConnectMessage(jsonTokenResponse); + + var contentMediaType = responseMessage.Content.Headers.ContentType?.MediaType; + if (string.IsNullOrEmpty(contentMediaType)) + { + Logger.LogDebug($"Unexpected token response format. Status Code: {(int)responseMessage.StatusCode}. Content-Type header is missing."); + } + else if (!string.Equals(contentMediaType, "application/json", StringComparison.OrdinalIgnoreCase)) + { + Logger.LogDebug($"Unexpected token response format. Status Code: {(int)responseMessage.StatusCode}. Content-Type {responseMessage.Content.Headers.ContentType}."); + } + + // Error handling: + // 1. If the response body can't be parsed as json, throws. + // 2. If the response's status code is not in 2XX range, throw OpenIdConnectProtocolException. If the body is correct parsed, + // pass the error information from body to the exception. + OpenIdConnectMessage message; + try + { + var responseContent = await responseMessage.Content.ReadAsStringAsync(); + message = new OpenIdConnectMessage(responseContent); + } + catch (Exception ex) + { + throw new OpenIdConnectProtocolException($"Failed to parse token response body as JSON. Status Code: {(int)responseMessage.StatusCode}. Content-Type: {responseMessage.Content.Headers.ContentType}", ex); + } + + if (!responseMessage.IsSuccessStatusCode) + { + throw CreateOpenIdConnectProtocolException(message, responseMessage); + } + + return message; } /// @@ -1016,7 +1040,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return authorizationCodeReceivedContext; } - private async Task RunTokenResponseReceivedEventAsync(OpenIdConnectMessage message, OpenIdConnectMessage tokenEndpointResponse, AuthenticationProperties properties) + private async Task RunTokenResponseReceivedEventAsync( + OpenIdConnectMessage message, + OpenIdConnectMessage tokenEndpointResponse, + AuthenticationProperties properties) { Logger.TokenResponseReceived(); var eventContext = new TokenResponseReceivedContext(Context, Options, properties) @@ -1157,5 +1184,27 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return BuildRedirectUri(uri); } + + private OpenIdConnectProtocolException CreateOpenIdConnectProtocolException(OpenIdConnectMessage message, HttpResponseMessage response) + { + var description = message.ErrorDescription ?? "error_description is null"; + var errorUri = message.ErrorUri ?? "error_uri is null"; + + if (response != null) + { + Logger.ResponseErrorWithStatusCode(message.Error, description, errorUri, (int)response.StatusCode); + } + else + { + Logger.ResponseError(message.Error, description, errorUri); + } + + return new OpenIdConnectProtocolException(string.Format( + CultureInfo.InvariantCulture, + Resources.MessageContainsError, + message.Error, + description, + errorUri)); + } } } From 918d6127457b88bbb45de5e7efd8ccf1e95d9d6a Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 26 Sep 2016 14:31:57 -0700 Subject: [PATCH 636/900] Add ChunkingCookieManager.Sources to NuGetPackageVerifier --- NuGetPackageVerifier.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index 9f3414fbc4..c522f4c1a8 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -18,6 +18,12 @@ "Microsoft.Owin.Security.Interop": { } } }, + "adx-nonshipping": { + "rules": [], + "packages": { + "Microsoft.AspNetCore.ChunkingCookieManager.Sources": { } + } + }, "Default": { // Rules to run for packages not listed in any other set. "rules": [ "DefaultCompositeRule" From 0152691108717bd74cc5f0406e7b745b31c8ca23 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Wed, 28 Sep 2016 14:25:02 -0700 Subject: [PATCH 637/900] Cookie Auto: set properties back to ticket when using SessionStore (#995) --- .../CookieAuthenticationHandler.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 7c583ed7e1..1f2b395b1d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -150,6 +150,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies HttpOnly = Options.CookieHttpOnly, Path = Options.CookiePath ?? (OriginalPathBase.HasValue ? OriginalPathBase.ToString() : "/"), }; + if (Options.CookieSecure == CookieSecurePolicy.SameAsRequest) { cookieOptions.Secure = Request.IsHttps; @@ -158,6 +159,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { cookieOptions.Secure = Options.CookieSecure == CookieSecurePolicy.Always; } + return cookieOptions; } @@ -172,13 +174,16 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var ticket = (await HandleAuthenticateOnceSafeAsync())?.Ticket; if (ticket != null) { + var properties = ticket.Properties; + if (_refreshIssuedUtc.HasValue) { - ticket.Properties.IssuedUtc = _refreshIssuedUtc; + properties.IssuedUtc = _refreshIssuedUtc; } + if (_refreshExpiresUtc.HasValue) { - ticket.Properties.ExpiresUtc = _refreshExpiresUtc; + properties.ExpiresUtc = _refreshExpiresUtc; } if (Options.SessionStore != null && _sessionKey != null) @@ -194,7 +199,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var cookieValue = Options.TicketDataFormat.Protect(ticket, GetTlsTokenBinding()); var cookieOptions = BuildCookieOptions(); - if (ticket.Properties.IsPersistent && _refreshExpiresUtc.HasValue) + if (properties.IsPersistent && _refreshExpiresUtc.HasValue) { cookieOptions.Expires = _refreshExpiresUtc.Value.ToUniversalTime(); } @@ -205,7 +210,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies cookieValue, cookieOptions); - await ApplyHeaders(shouldRedirectToReturnUrl: false, properties: ticket.Properties); + await ApplyHeaders(shouldRedirectToReturnUrl: false, properties: properties); } } @@ -261,6 +266,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Options.ClaimsIssuer)); ticket = new AuthenticationTicket(principal, null, Options.AuthenticationScheme); } + var cookieValue = Options.TicketDataFormat.Protect(ticket, GetTlsTokenBinding()); Options.CookieManager.AppendResponseCookie( From ac773beffcdd348599f4b8cb4cac76473bee0ecf Mon Sep 17 00:00:00 2001 From: Adem Caglin Date: Thu, 29 Sep 2016 23:24:24 +0300 Subject: [PATCH 638/900] Changed BuildChallengeUrl in order to accept AuthorizationEndpoint which contains query parameters (#992) --- .../OAuthHandler.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index dbfa1ef92b..1c5143842f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; +using Microsoft.AspNetCore.WebUtilities; namespace Microsoft.AspNetCore.Authentication.OAuth { @@ -206,8 +207,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth var scope = FormatScope(); var state = Options.StateDataFormat.Protect(properties); - - var queryBuilder = new QueryBuilder() + var parameters = new Dictionary { { "client_id", Options.ClientId }, { "scope", scope }, @@ -215,7 +215,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { "redirect_uri", redirectUri }, { "state", state }, }; - return Options.AuthorizationEndpoint + queryBuilder.ToString(); + return QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, parameters); } protected virtual string FormatScope() From e09dd6d0b8fad0a6d0f7c52931549006e794693e Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 29 Sep 2016 16:21:26 -0700 Subject: [PATCH 639/900] Fix #976: Break claims value in array into multiple claims (#996) * Break claims value in array into multiple claims * Review feedback 1 --- .../OpenIdConnectHandler.cs | 7 +--- .../Utility/ClaimsHelper.cs | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 2039a76e90..1e5eda4707 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -806,12 +806,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } // adding remaining unique claims from userinfo endpoint to the identity - foreach (var pair in user) - { - JToken value; - var claimValue = user.TryGetValue(pair.Key, out value) ? value.ToString() : null; - identity.AddClaim(new Claim(pair.Key, claimValue, ClaimValueTypes.String, jwt.Issuer)); - } + ClaimsHelper.AddClaimsToIdentity(user, identity, jwt.Issuer); return AuthenticateResult.Success(ticket); } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs new file mode 100644 index 0000000000..dab4d0fd9c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Security.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect +{ + internal static class ClaimsHelper + { + public static void AddClaimsToIdentity( + JObject userInformationPayload, + ClaimsIdentity identity, + string issuer) + { + foreach (var pair in userInformationPayload) + { + var array = pair.Value as JArray; + if (array != null) + { + foreach (var item in array) + { + AddClaimsToIdentity(item, identity, pair.Key, issuer); + } + } + else + { + AddClaimsToIdentity(pair.Value, identity, pair.Key, issuer); + } + } + } + + private static void AddClaimsToIdentity(JToken item, ClaimsIdentity identity, string key, string issuer) + => identity.AddClaim(new Claim(key, item?.ToString() ?? string.Empty, ClaimValueTypes.String, issuer)); + } +} From f64c864911a2ec84f895f012bd2560b14482eea2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 28 Sep 2016 11:52:20 -0700 Subject: [PATCH 640/900] Updating partner package versions --- samples/CookieSample/project.json | 2 +- samples/CookieSessionSample/project.json | 2 +- samples/JwtBearerSample/project.json | 6 +++--- samples/OpenIdConnect.AzureAdSample/project.json | 4 ++-- samples/OpenIdConnectSample/project.json | 8 ++++---- samples/SocialSample/project.json | 6 +++--- .../project.json | 7 +++++-- .../project.json | 3 ++- .../project.json | 3 ++- .../project.json | 3 ++- .../project.json | 3 ++- .../project.json | 3 ++- .../project.json | 3 ++- .../project.json | 1 + src/Microsoft.AspNetCore.Authentication/project.json | 11 ++++------- src/Microsoft.AspNetCore.Authorization/project.json | 5 +++-- .../project.json | 3 ++- src/Microsoft.AspNetCore.CookiePolicy/project.json | 3 ++- src/Microsoft.Owin.Security.Interop/project.json | 3 ++- .../project.json | 2 +- .../project.json | 2 +- .../project.json | 2 +- .../project.json | 2 +- .../Microsoft.Owin.Security.Interop.Test/project.json | 1 + 24 files changed, 50 insertions(+), 38 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 57ceb354aa..4cf29c1771 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -15,7 +15,7 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index 6530e1cf00..69c44692e6 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -16,7 +16,7 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 21d2365ece..e6658fa898 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -8,15 +8,15 @@ "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", "Microsoft.AspNetCore.StaticFiles": "1.1.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*" + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*" }, "frameworks": { "net451": {}, "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 6aee5073f2..4cbe064a34 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -14,7 +14,7 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } @@ -37,4 +37,4 @@ "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" } -} +} \ No newline at end of file diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index a6a16a29fc..2293569c31 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -5,18 +5,18 @@ "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", "Microsoft.Extensions.FileProviders.Embedded": "1.1.0-*", "Microsoft.Extensions.Logging.Console": "1.1.0-*", - "Microsoft.Extensions.Logging.Debug": "1.1.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*" + "Microsoft.Extensions.Logging.Debug": "1.1.0-*" }, "frameworks": { "net451": {}, "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } @@ -39,4 +39,4 @@ "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" } -} +} \ No newline at end of file diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 227354e518..791666abc1 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -9,10 +9,10 @@ "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", "Microsoft.Extensions.FileProviders.Embedded": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*" + "Microsoft.Extensions.Logging.Console": "1.1.0-*" }, "buildOptions": { "emitEntryPoint": true @@ -22,7 +22,7 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index 331de199ac..baa2b87c2d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -19,7 +19,9 @@ "CS1591" ], "xmlDoc": true, - "define": [ "SECURITY" ] + "define": [ + "SECURITY" + ] }, "dependencies": { "Microsoft.AspNetCore.Authentication": "1.1.0-*", @@ -32,7 +34,8 @@ "version": "1.1.0-*", "type": "build" }, - "Microsoft.Extensions.WebEncoders": "1.1.0-*" + "Microsoft.Extensions.WebEncoders": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 796b3bf7c5..436b41be5f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -21,7 +21,8 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*" + "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index dde8c3a544..b4e4a8a461 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -21,7 +21,8 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*" + "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 7697e9b691..53c72471e1 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -26,7 +26,8 @@ "version": "1.1.0-*", "type": "build" }, - "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" + "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index 3169adf72d..be590b3ec9 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -21,7 +21,8 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*" + "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index 0365178576..c1d6ac0799 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -26,13 +26,14 @@ "version": "1.1.0-*", "type": "build" }, + "NETStandard.Library": "1.6.1-*", "Newtonsoft.Json": "9.0.1" }, "frameworks": { "net451": {}, "netstandard1.3": { "dependencies": { - "System.Runtime.Serialization.Primitives": "4.1.1-*" + "System.Runtime.Serialization.Primitives": "4.3.0-*" } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 53379f96d5..3c7054a772 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -26,7 +26,8 @@ "version": "1.1.0-*", "type": "build" }, - "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-*" + "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 395f67b3fc..28239ec93a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -26,6 +26,7 @@ "version": "1.1.0-*", "type": "build" }, + "NETStandard.Library": "1.6.1-*", "Newtonsoft.Json": "9.0.1" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index 958170ab7d..4f0bc2bc99 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -25,6 +25,7 @@ "Microsoft.AspNetCore.Http": "1.1.0-*", "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", "Microsoft.Extensions.Logging.Abstractions": "1.1.0-*", + "Microsoft.Extensions.Options": "1.1.0-*", "Microsoft.Extensions.SecurityHelper.Sources": { "type": "build", "version": "1.1.0-*" @@ -33,8 +34,8 @@ "version": "1.1.0-*", "type": "build" }, - "Microsoft.Extensions.Options": "1.1.0-*", - "Microsoft.Extensions.WebEncoders": "1.1.0-*" + "Microsoft.Extensions.WebEncoders": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": { @@ -42,10 +43,6 @@ "System.Net.Http": "" } }, - "netstandard1.3": { - "dependencies": { - "System.Net.Http": "4.1.0-*" - } - } + "netstandard1.3": {} } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 303ba904a1..fc455c84dd 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -25,7 +25,8 @@ "Microsoft.Extensions.TaskCache.Sources": { "version": "1.1.0-*", "type": "build" - } + }, + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": { @@ -37,7 +38,7 @@ }, "netstandard1.3": { "dependencies": { - "System.Security.Claims": "4.0.1-*" + "System.Security.Claims": "4.3.0-*" } } } diff --git a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json index a1a4f21841..96571bb786 100644 --- a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json +++ b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json @@ -3,7 +3,8 @@ "shared": "*.cs", "dependencies": { "Microsoft.AspNetCore.Http.Abstractions": "1.1.0-*", - "Microsoft.Net.Http.Headers": "1.1.0-*" + "Microsoft.Net.Http.Headers": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json index 4cf5f4881c..471dfc8a8e 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/project.json @@ -20,7 +20,8 @@ }, "dependencies": { "Microsoft.AspNetCore.Http": "1.1.0-*", - "Microsoft.Extensions.Options": "1.1.0-*" + "Microsoft.Extensions.Options": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.Owin.Security.Interop/project.json b/src/Microsoft.Owin.Security.Interop/project.json index c7b3326a01..be6e48490b 100644 --- a/src/Microsoft.Owin.Security.Interop/project.json +++ b/src/Microsoft.Owin.Security.Interop/project.json @@ -19,7 +19,8 @@ }, "dependencies": { "Microsoft.AspNetCore.DataProtection.Extensions": "1.1.0-*", - "Microsoft.Owin.Security": "3.0.1" + "Microsoft.Owin.Security": "3.0.1", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 0feac5dd91..1fd82c9f5a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -19,7 +19,7 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index f8fda41e34..6d723ec6b2 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -14,7 +14,7 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json index f5fab3f1e6..c060c077f5 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json @@ -15,7 +15,7 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 89673d8488..9398f1df85 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -14,7 +14,7 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index e622bd746f..89709865e0 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -9,6 +9,7 @@ "Microsoft.Owin.Security.Cookies": "3.0.1", "Microsoft.Owin.Security.Interop": "1.1.0-*", "Microsoft.Owin.Testing": "3.0.1", + "NETStandard.Library": "1.6.1-*", "xunit": "2.2.0-*" }, "frameworks": { From 55134b31fe430fb40a5f4cec93b28f24289124f9 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 12 Oct 2016 13:46:35 -0700 Subject: [PATCH 641/900] Updating to netcoreapp1.1 --- samples/CookieSample/project.json | 2 +- samples/CookieSessionSample/project.json | 2 +- samples/JwtBearerSample/project.json | 2 +- samples/OpenIdConnect.AzureAdSample/project.json | 2 +- samples/OpenIdConnectSample/project.json | 2 +- samples/SocialSample/project.json | 2 +- test/Microsoft.AspNetCore.Authentication.Test/project.json | 2 +- test/Microsoft.AspNetCore.Authorization.Test/project.json | 2 +- .../project.json | 2 +- test/Microsoft.AspNetCore.CookiePolicy.Test/project.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 4cf29c1771..2529f14027 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -12,7 +12,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index 69c44692e6..8987d1b6ad 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -13,7 +13,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index e6658fa898..3a61c23ee4 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -13,7 +13,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 4cbe064a34..958f48d162 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -11,7 +11,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 2293569c31..631e339afb 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -13,7 +13,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 791666abc1..e2419deeb3 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -19,7 +19,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 1fd82c9f5a..8bbb453200 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -16,7 +16,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 6d723ec6b2..c483cee312 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -11,7 +11,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json index c060c077f5..0597e0fab8 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json @@ -12,7 +12,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 9398f1df85..df7e38f4ab 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -11,7 +11,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", From 1268d245b892912a9f2704395d30f2f8537db7be Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 12 Oct 2016 16:09:40 -0700 Subject: [PATCH 642/900] Revert "Updating to netcoreapp1.1" This reverts commit 55134b31fe430fb40a5f4cec93b28f24289124f9. --- samples/CookieSample/project.json | 2 +- samples/CookieSessionSample/project.json | 2 +- samples/JwtBearerSample/project.json | 2 +- samples/OpenIdConnect.AzureAdSample/project.json | 2 +- samples/OpenIdConnectSample/project.json | 2 +- samples/SocialSample/project.json | 2 +- test/Microsoft.AspNetCore.Authentication.Test/project.json | 2 +- test/Microsoft.AspNetCore.Authorization.Test/project.json | 2 +- .../project.json | 2 +- test/Microsoft.AspNetCore.CookiePolicy.Test/project.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 2529f14027..4cf29c1771 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -12,7 +12,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index 8987d1b6ad..69c44692e6 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -13,7 +13,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 3a61c23ee4..e6658fa898 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -13,7 +13,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 958f48d162..4cbe064a34 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -11,7 +11,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 631e339afb..2293569c31 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -13,7 +13,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index e2419deeb3..791666abc1 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -19,7 +19,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 8bbb453200..1fd82c9f5a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -16,7 +16,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index c483cee312..6d723ec6b2 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -11,7 +11,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json index 0597e0fab8..c060c077f5 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json @@ -12,7 +12,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index df7e38f4ab..9398f1df85 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -11,7 +11,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", From 7e577832ff682d5ccd2ba6d68c11ba4d713c8b3d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 13 Oct 2016 11:24:28 -0700 Subject: [PATCH 643/900] Updating to netcoreapp1.1 --- samples/CookieSample/project.json | 2 +- samples/CookieSessionSample/project.json | 2 +- samples/JwtBearerSample/project.json | 2 +- samples/OpenIdConnect.AzureAdSample/project.json | 2 +- samples/OpenIdConnectSample/project.json | 2 +- samples/SocialSample/project.json | 2 +- test/Microsoft.AspNetCore.Authentication.Test/project.json | 2 +- test/Microsoft.AspNetCore.Authorization.Test/project.json | 2 +- .../project.json | 2 +- test/Microsoft.AspNetCore.CookiePolicy.Test/project.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 4cf29c1771..2529f14027 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -12,7 +12,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index 69c44692e6..8987d1b6ad 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -13,7 +13,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index e6658fa898..3a61c23ee4 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -13,7 +13,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 4cbe064a34..958f48d162 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -11,7 +11,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 2293569c31..631e339afb 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -13,7 +13,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index 791666abc1..e2419deeb3 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -19,7 +19,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 1fd82c9f5a..8bbb453200 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -16,7 +16,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 6d723ec6b2..c483cee312 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -11,7 +11,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json index c060c077f5..0597e0fab8 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json @@ -12,7 +12,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index 9398f1df85..df7e38f4ab 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -11,7 +11,7 @@ "xunit": "2.2.0-*" }, "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", From 734d36b2d171d054c93b5b0b2486e736adc67caf Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 13 Oct 2016 13:59:39 -0700 Subject: [PATCH 644/900] Update to latest CoreFx package --- .../project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 3c7054a772..234b9fd376 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -26,7 +26,7 @@ "version": "1.1.0-*", "type": "build" }, - "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0", + "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.1-*", "NETStandard.Library": "1.6.1-*" }, "frameworks": { From 3eab3ef013c725e0e9ee34f35af7b7f75d73e616 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 13 Oct 2016 14:00:21 -0700 Subject: [PATCH 645/900] Updating package that was missed --- src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 53c72471e1..7103ca2542 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -26,7 +26,7 @@ "version": "1.1.0-*", "type": "build" }, - "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0", + "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.1-*", "NETStandard.Library": "1.6.1-*" }, "frameworks": { From b1b5a40ebfdae2841cad3ccfea5d7e1db089d9c0 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 13 Oct 2016 20:14:15 -0700 Subject: [PATCH 646/900] #1004 clean up social sample code --- samples/SocialSample/Startup.cs | 35 +++++++++++++++++---------- samples/SocialSample/appsettings.json | 12 --------- samples/SocialSample/project.json | 1 - 3 files changed, 22 insertions(+), 26 deletions(-) delete mode 100644 samples/SocialSample/appsettings.json diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 4f3a03d50d..5bd848067e 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -29,7 +29,7 @@ namespace SocialSample { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json"); + .AddJsonFile("appsettings.json", optional: true); if (env.IsDevelopment()) { @@ -77,7 +77,14 @@ namespace SocialSample LoginPath = new PathString("/login") }); - // You must first create an app with facebook and add it's ID and Secret to your config.json or user-secrets. + if (string.IsNullOrEmpty(Configuration["facebook:appid"])) + { + // User-Secrets: https://docs.asp.net/en/latest/security/app-secrets.html + // See below for registration instructions for each provider. + throw new InvalidOperationException("User secrets must be configured for each authentication provider."); + } + + // You must first create an app with Facebook and add its ID and Secret to your user-secrets. // https://developers.facebook.com/apps/ app.UseFacebookAuthentication(new FacebookOptions { @@ -88,7 +95,8 @@ namespace SocialSample SaveTokens = true, }); - // See config.json + // You must first create an app with Google and add its ID and Secret to your user-secrets. + // https://console.developers.google.com/project app.UseOAuthAuthentication(new OAuthOptions { AuthenticationScheme = "Google-AccessToken", @@ -102,7 +110,7 @@ namespace SocialSample SaveTokens = true }); - // See config.json + // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project app.UseGoogleAuthentication(new GoogleOptions { @@ -120,7 +128,7 @@ namespace SocialSample } }); - // See config.json + // You must first create an app with Twitter and add its key and Secret to your user-secrets. // https://apps.twitter.com/ app.UseTwitterAuthentication(new TwitterOptions { @@ -151,14 +159,14 @@ namespace SocialSample Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL: https://localhost:44318/ */ - // See config.json + // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. // https://apps.dev.microsoft.com/ app.UseOAuthAuthentication(new OAuthOptions { AuthenticationScheme = "Microsoft-AccessToken", DisplayName = "MicrosoftAccount-AccessToken", - ClientId = Configuration["msa:clientid"], - ClientSecret = Configuration["msa:clientsecret"], + ClientId = Configuration["microsoftaccount:clientid"], + ClientSecret = Configuration["microsoftaccount:clientsecret"], CallbackPath = new PathString("/signin-microsoft-token"), AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint, TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint, @@ -166,17 +174,17 @@ namespace SocialSample SaveTokens = true }); - // See config.json + // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. // https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/ app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions { DisplayName = "MicrosoftAccount", - ClientId = Configuration["msa:clientid"], - ClientSecret = Configuration["msa:clientsecret"], + ClientId = Configuration["microsoftaccount:clientid"], + ClientSecret = Configuration["microsoftaccount:clientsecret"], SaveTokens = true }); - // See config.json + // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ app.UseOAuthAuthentication(new OAuthOptions { @@ -190,7 +198,8 @@ namespace SocialSample SaveTokens = true }); - // See config.json + // You must first create an app with GitHub and add its ID and Secret to your user-secrets. + // https://github.com/settings/applications/ app.UseOAuthAuthentication(new OAuthOptions { AuthenticationScheme = "GitHub", diff --git a/samples/SocialSample/appsettings.json b/samples/SocialSample/appsettings.json deleted file mode 100644 index 11477998c0..0000000000 --- a/samples/SocialSample/appsettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "google:clientid": "560027070069-37ldt4kfuohhu3m495hk2j4pjp92d382.apps.googleusercontent.com", - "google:clientsecret": "n2Q-GEw9RQjzcRbU3qhfTj8f", - "twitter:consumerkey": "VvNJRyGeqYBByN694UHudI2cv", - "twitter:consumersecret": "V2xEqWgmphPdlUXX4ARWsozl9lfbvr5wbAYw2LN8m6kZV7pt20", - "github:clientid": "49e302895d8b09ea5656", - "github:clientsecret": "98f1bf028608901e9df91d64ee61536fe562064b", - "github-token:clientid": "8c0c5a572abe8fe89588", - "github-token:clientsecret": "e1d95eaf03461d27acd6f49d4fc7bf19d6ac8cda", - "msa:clientid": "e2105565-1f56-434a-ae61-9849ebaf606c", - "msa:clientsecret": "pjqtt3RXrFwcfSJyQ0BeUez" -} diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index e2419deeb3..e041bf26ca 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -31,7 +31,6 @@ "userSecretsId": "aspnet5-SocialSample-20151210111056", "publishOptions": { "include": [ - "appsettings.json", "project.json", "web.config" ] From fa348ca680c94261c39e0d1a3e4db828e1592a72 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 14 Oct 2016 10:11:48 -0700 Subject: [PATCH 647/900] Update to RTM build of ActiveDirectory package --- samples/OpenIdConnect.AzureAdSample/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 958f48d162..2cfabe8dff 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -7,7 +7,7 @@ "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", "Microsoft.Extensions.Logging.Console": "1.1.0-*", - "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.11.305310302-alpha" + "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.13.4" }, "frameworks": { "net451": {}, From fd56f5ac2ae5f6585e5b123eae2050f2a794ad1f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 17 Oct 2016 09:49:45 -0700 Subject: [PATCH 648/900] Branching for 1.1.0-preview1 --- NuGet.config | 4 ++-- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 0fd623ffdd..ad973186eb 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..787f63ac02 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0-preview1.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..355c682856 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0-preview1.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 8fcbddc23be1caff41f59f17b90624171fa8e43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Mon, 24 Oct 2016 18:28:25 +0200 Subject: [PATCH 649/900] Update ClaimsHelper.AddClaimsToIdentity to infer the claim value type from the JSON token type (#1002) --- .../Utility/ClaimsHelper.cs | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs index dab4d0fd9c..78eea68bfb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.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.IdentityModel.Tokens.Jwt; using System.Security.Claims; using Newtonsoft.Json.Linq; @@ -31,6 +32,50 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } private static void AddClaimsToIdentity(JToken item, ClaimsIdentity identity, string key, string issuer) - => identity.AddClaim(new Claim(key, item?.ToString() ?? string.Empty, ClaimValueTypes.String, issuer)); + => identity.AddClaim(new Claim(key, item?.ToString() ?? string.Empty, GetClaimValueType(item), issuer)); + + private static string GetClaimValueType(JToken token) + { + if (token == null) + { + return JsonClaimValueTypes.JsonNull; + } + + switch (token.Type) + { + case JTokenType.Array: + return JsonClaimValueTypes.JsonArray; + + case JTokenType.Boolean: + return ClaimValueTypes.Boolean; + + case JTokenType.Date: + return ClaimValueTypes.DateTime; + + case JTokenType.Float: + return ClaimValueTypes.Double; + + case JTokenType.Integer: + { + var value = (long) token; + if (value >= int.MinValue && value <= int.MaxValue) + { + return ClaimValueTypes.Integer; + } + + return ClaimValueTypes.Integer64; + } + + case JTokenType.Object: + return JsonClaimValueTypes.Json; + + case JTokenType.String: + return ClaimValueTypes.String; + } + + // Fall back to ClaimValueTypes.String when no appropriate + // claim value type can be inferred from the claim value. + return ClaimValueTypes.String; + } } } From 2d1c56ce5ccfc15c78dd49cee772f6be473f3ee2 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 17 Oct 2016 14:58:08 -0700 Subject: [PATCH 650/900] #884 Honor OIDC's and Jwt's OnAuthenticationFailed HandleResponse() --- samples/JwtBearerSample/Startup.cs | 23 +- samples/OpenIdConnectSample/Startup.cs | 24 +- .../OpenIdConnectHandler.cs | 8 +- .../OpenIdConnectOptions.cs | 1 + .../AuthenticateResult.cs | 11 + .../AuthenticationHandler.cs | 22 +- .../Events/BaseControlContext.cs | 9 +- .../RemoteAuthenticationHandler.cs | 4 + .../JwtBearer/JwtBearerMiddlewareTests.cs | 119 ++ .../OpenIdConnect/OpenIdConnectEventTests.cs | 1534 +++++++++++++++++ 10 files changed, 1743 insertions(+), 12 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 02611de8c4..ac599bc57f 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -15,6 +16,8 @@ namespace JwtBearerSample { public Startup(IHostingEnvironment env) { + Environment = env; + var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath); @@ -30,6 +33,8 @@ namespace JwtBearerSample public IConfiguration Configuration { get; set; } + public IHostingEnvironment Environment { get; set; } + // Shared between users in memory public IList Todos { get; } = new List(); @@ -68,7 +73,23 @@ namespace JwtBearerSample { // You also need to update /wwwroot/app/scripts/app.js Authority = Configuration["jwt:authority"], - Audience = Configuration["jwt:audience"] + Audience = Configuration["jwt:audience"], + Events = new JwtBearerEvents() + { + OnAuthenticationFailed = c => + { + c.HandleResponse(); + + c.Response.StatusCode = 500; + c.Response.ContentType = "text/plain"; + if (Environment.IsDevelopment()) + { + // Debug only, in production do not share exceptions with the remote host. + return c.Response.WriteAsync(c.Exception.ToString()); + } + return c.Response.WriteAsync("An error occurred processing your authentication."); + } + } }); // [Authorize] would usually handle this diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 37b753102b..90ed3db25d 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -20,6 +20,8 @@ namespace OpenIdConnectSample { public Startup(IHostingEnvironment env) { + Environment = env; + var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath); @@ -35,6 +37,8 @@ namespace OpenIdConnectSample public IConfiguration Configuration { get; set; } + public IHostingEnvironment Environment { get; set; } + public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(sharedOptions => @@ -75,8 +79,24 @@ namespace OpenIdConnectSample ClientId = Configuration["oidc:clientid"], ClientSecret = Configuration["oidc:clientsecret"], // for code flow Authority = Configuration["oidc:authority"], - ResponseType = OpenIdConnectResponseType.Code, - GetClaimsFromUserInfoEndpoint = true + ResponseType = OpenIdConnectResponseType.CodeIdToken, + GetClaimsFromUserInfoEndpoint = true, + Events = new OpenIdConnectEvents() + { + OnAuthenticationFailed = c => + { + c.HandleResponse(); + + c.Response.StatusCode = 500; + c.Response.ContentType = "text/plain"; + if (Environment.IsDevelopment()) + { + // Debug only, in production do not share exceptions with the remote host. + return c.Response.WriteAsync(c.Exception.ToString()); + } + return c.Response.WriteAsync("An error occurred processing your authentication."); + } + } }); app.Run(async context => diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 1e5eda4707..9cc4fc2cd4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -578,7 +578,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect tokenEndpointResponse = await RedeemAuthorizationCodeAsync(tokenEndpointRequest); } - var tokenResponseReceivedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties); + var tokenResponseReceivedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties, ticket); if (tokenResponseReceivedContext.CheckEventResult(out result)) { return result; @@ -1038,13 +1038,15 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private async Task RunTokenResponseReceivedEventAsync( OpenIdConnectMessage message, OpenIdConnectMessage tokenEndpointResponse, - AuthenticationProperties properties) + AuthenticationProperties properties, + AuthenticationTicket ticket) { Logger.TokenResponseReceived(); var eventContext = new TokenResponseReceivedContext(Context, Options, properties) { ProtocolMessage = message, - TokenEndpointResponse = tokenEndpointResponse + TokenEndpointResponse = tokenEndpointResponse, + Ticket = ticket }; await Options.Events.TokenResponseReceived(eventContext); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 12bc1c03d8..f0b26f75b2 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -86,6 +86,7 @@ namespace Microsoft.AspNetCore.Builder /// /// Boolean to set whether the middleware should go to user info endpoint to retrieve additional claims or not after creating an identity from id_token received from token endpoint. + /// The default is 'false'. /// public bool GetClaimsFromUserInfoEndpoint { get; set; } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs index fb97931cbb..28f116d3d8 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs @@ -33,6 +33,12 @@ namespace Microsoft.AspNetCore.Authentication /// public Exception Failure { get; private set; } + /// + /// Indicates that stage of authentication was directly handled by user intervention and no + /// further processing should be attempted. + /// + public bool Handled { get; private set; } + /// /// Indicates that this stage of authentication was skipped by user intervention. /// @@ -47,6 +53,11 @@ namespace Microsoft.AspNetCore.Authentication return new AuthenticateResult() { Ticket = ticket }; } + public static AuthenticateResult Handle() + { + return new AuthenticateResult() { Handled = true }; + } + public static AuthenticateResult Skip() { return new AuthenticateResult() { Skipped = true }; diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 5e9a7c2381..ae32424ebd 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -58,6 +58,8 @@ namespace Microsoft.AspNetCore.Authentication protected TOptions Options { get; private set; } + protected AuthenticateResult InitializeResult { get; private set; } + /// /// Initialize is called once per request to contextualize this instance with appropriate state. /// @@ -101,12 +103,18 @@ namespace Microsoft.AspNetCore.Authentication if (ShouldHandleScheme(AuthenticationManager.AutomaticScheme, Options.AutomaticAuthenticate)) { - var result = await HandleAuthenticateOnceAsync(); - if (result?.Failure != null) + InitializeResult = await HandleAuthenticateOnceAsync(); + if (InitializeResult?.Skipped == true || InitializeResult?.Handled == true) { - Logger.AuthenticationSchemeNotAuthenticatedWithFailure(Options.AuthenticationScheme, result.Failure.Message); + return; } - var ticket = result?.Ticket; + + if (InitializeResult?.Failure != null) + { + Logger.AuthenticationSchemeNotAuthenticatedWithFailure(Options.AuthenticationScheme, InitializeResult.Failure.Message); + } + + var ticket = InitializeResult?.Ticket; if (ticket?.Principal != null) { Context.User = SecurityHelper.MergeUserPrincipal(Context.User, ticket.Principal); @@ -179,6 +187,10 @@ namespace Microsoft.AspNetCore.Authentication /// pipeline. public virtual Task HandleRequestAsync() { + if (InitializeResult?.Handled == true) + { + return Task.FromResult(true); + } return Task.FromResult(false); } @@ -250,7 +262,7 @@ namespace Microsoft.AspNetCore.Authentication /// /// Used to ensure HandleAuthenticateAsync is only invoked once safely. The subsequent /// calls will return the same authentication result. Any exceptions will be converted - /// into a failed authenticatoin result containing the exception. + /// into a failed authentication result containing the exception. /// protected async Task HandleAuthenticateOnceSafeAsync() { diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs index 24f3ba8e53..4039a05609 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs @@ -51,7 +51,14 @@ namespace Microsoft.AspNetCore.Authentication { if (HandledResponse) { - result = AuthenticateResult.Success(Ticket); + if (Ticket == null) + { + result = AuthenticateResult.Handle(); + } + else + { + result = AuthenticateResult.Success(Ticket); + } return true; } else if (Skipped) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 862193db15..1e41fb0b50 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -43,6 +43,10 @@ namespace Microsoft.AspNetCore.Authentication { exception = new InvalidOperationException("Invalid return state, unable to redirect."); } + else if (authResult.Handled) + { + return true; + } else if (authResult.Skipped) { return false; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs index fea01b36fe..c0d2ddba5b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs @@ -429,6 +429,39 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal(string.Empty, response.ResponseText); } + [Fact] + public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() + { + var server = CreateServer(new JwtBearerOptions + { + Events = new JwtBearerEvents() + { + OnMessageReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + throw new NotImplementedException(); + }, + OnAuthenticationFailed = context => + { + throw new NotImplementedException(context.Exception.ToString()); + }, + OnChallenge = context => + { + throw new NotImplementedException(); + }, + } + }); + + var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); + Assert.Equal(string.Empty, response.ResponseText); + } + [Fact] public async Task EventOnTokenValidatedSkipped_NoMoreEventsExecuted() { @@ -460,6 +493,38 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal(string.Empty, response.ResponseText); } + [Fact] + public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() + { + var options = new JwtBearerOptions + { + Events = new JwtBearerEvents() + { + OnTokenValidated = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnAuthenticationFailed = context => + { + throw new NotImplementedException(context.Exception.ToString()); + }, + OnChallenge = context => + { + throw new NotImplementedException(); + }, + } + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + var server = CreateServer(options); + + var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); + Assert.Equal(string.Empty, response.ResponseText); + } + [Fact] public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() { @@ -491,6 +556,38 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal(string.Empty, response.ResponseText); } + [Fact] + public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() + { + var options = new JwtBearerOptions + { + Events = new JwtBearerEvents() + { + OnTokenValidated = context => + { + throw new Exception("Test Exception"); + }, + OnAuthenticationFailed = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnChallenge = context => + { + throw new NotImplementedException(); + }, + } + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + var server = CreateServer(options); + + var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); + Assert.Equal(string.Empty, response.ResponseText); + } + [Fact] public async Task EventOnChallengeSkipped_ResponseNotModified() { @@ -512,6 +609,28 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal(string.Empty, response.ResponseText); } + [Fact] + public async Task EventOnChallengeHandled_ResponseNotModified() + { + var server = CreateServer(new JwtBearerOptions + { + Events = new JwtBearerEvents() + { + OnChallenge = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + } + }); + + var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); + Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); + Assert.Empty(response.Response.Headers.WwwAuthenticate); + Assert.Equal(string.Empty, response.ResponseText); + } + class InvalidTokenValidator : ISecurityTokenValidator { public InvalidTokenValidator() diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs new file mode 100644 index 0000000000..a212af649d --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -0,0 +1,1534 @@ +// 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.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Claims; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Microsoft.IdentityModel.Tokens; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect +{ + public class OpenIdConnectEventTests + { + private readonly Func MessageNotImpl = context => { throw new NotImplementedException("Message"); }; + private readonly Func TokenNotImpl = context => { throw new NotImplementedException("Token"); }; + private readonly Func CodeNotImpl = context => { throw new NotImplementedException("Code"); }; + private readonly Func TokenResponseNotImpl = context => { throw new NotImplementedException("TokenResponse"); }; + private readonly Func UserNotImpl = context => { throw new NotImplementedException("User"); }; + private readonly Func FailedNotImpl = context => { throw new NotImplementedException("Failed", context.Exception); }; + private readonly Func TicketNotImpl = context => { throw new NotImplementedException("Ticket"); }; + private readonly Func FailureNotImpl = context => { throw new NotImplementedException("Failure", context.Failure); }; + private readonly Func RedirectNotImpl = context => { throw new NotImplementedException("Redirect"); }; + private readonly Func RemoteSignOutNotImpl = context => { throw new NotImplementedException("Remote"); }; + private readonly RequestDelegate AppNotImpl = context => { throw new NotImplementedException("App"); }; + + [Fact] + public async Task OnMessageReceived_Skipped_NoMoreEventsRun() + { + var messageReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnTokenValidated = TokenNotImpl, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + OnRemoteFailure = FailureNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var response = await PostAsync(server, "signin-oidc", ""); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + } + + [Fact] + public async Task OnMessageReceived_Handled_NoMoreEventsRun() + { + var messageReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnTokenValidated = TokenNotImpl, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", ""); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + } + + [Fact] + public async Task OnTokenValidated_Skipped_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + } + + [Fact] + public async Task OnTokenValidated_HandledWithoutTicket_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + context.HandleResponse(); + context.Ticket = null; + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + } + + // TODO: Do any other events depend on the presence of the ticket? It's strange we have to double handle this event. + [Fact] + public async Task OnTokenValidated_HandledWithTicket_SkipToTicketReceived() + { + var messageReceived = false; + var tokenValidated = false; + var ticketReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + context.HandleResponse(); + // context.Ticket = null; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = context => + { + ticketReceived = true; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(ticketReceived); + } + + [Fact] + public async Task OnAuthorizationCodeReceived_Skipped_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + } + + [Fact] + public async Task OnAuthorizationCodeReceived_HandledWithoutTicket_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + context.HandleResponse(); + context.Ticket = null; + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + } + + [Fact] + public async Task OnAuthorizationCodeReceived_HandledWithTicket_SkipToTicketReceived() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var ticketReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + context.HandleResponse(); + // context.Ticket = null; + return Task.FromResult(0); + }, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = context => + { + ticketReceived = true; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(ticketReceived); + } + + [Fact] + public async Task OnTokenResponseReceived_Skipped_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + } + + [Fact] + public async Task OnTokenResponseReceived_HandledWithoutTicket_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + context.Ticket = null; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + } + + [Fact] + public async Task OnTokenResponseReceived_HandledWithTicket_SkipToTicketReceived() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var ticketReceived = false; + var tokenResponseReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + // context.Ticket = null; + context.HandleResponse(); + return Task.FromResult(0); + }, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = context => + { + ticketReceived = true; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(ticketReceived); + } + + [Fact] + public async Task OnTokenValidatedBackchannel_Skipped_NoMoreEventsRun() + { + var messageReceived = false; + var codeReceived = false; + var tokenResponseReceived = false; + var tokenValidated = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(tokenValidated); + } + + [Fact] + public async Task OnTokenValidatedBackchannel_HandledWithoutTicket_NoMoreEventsRun() + { + var messageReceived = false; + var codeReceived = false; + var tokenResponseReceived = false; + var tokenValidated = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + context.Ticket = null; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(tokenValidated); + } + + [Fact] + public async Task OnTokenValidatedBackchannel_HandledWithTicket_SkipToTicketReceived() + { + var messageReceived = false; + var codeReceived = false; + var ticketReceived = false; + var tokenResponseReceived = false; + var tokenValidated = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + // context.Ticket = null; + context.HandleResponse(); + return Task.FromResult(0); + }, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = context => + { + ticketReceived = true; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(tokenValidated); + Assert.True(ticketReceived); + } + + [Fact] + public async Task OnUserInformationReceived_Skipped_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + } + + [Fact] + public async Task OnUserInformationReceived_HandledWithoutTicket_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + context.Ticket = null; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + } + + [Fact] + public async Task OnUserInformationReceived_HandledWithTicket_SkipToTicketReceived() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var ticketReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + // context.Ticket = null; + context.HandleResponse(); + return Task.FromResult(0); + }, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = context => + { + ticketReceived = true; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(ticketReceived); + } + + [Fact] + public async Task OnAuthenticationFailed_Skipped_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var authFailed = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + throw new NotImplementedException("TestException"); + }, + OnAuthenticationFailed = context => + { + authFailed = true; + Assert.Equal("TestException", context.Exception.Message); + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(authFailed); + } + + [Fact] + public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var authFailed = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + throw new NotImplementedException("TestException"); + }, + OnAuthenticationFailed = context => + { + authFailed = true; + Assert.Equal("TestException", context.Exception.Message); + Assert.Null(context.Ticket); + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(authFailed); + } + + [Fact] + public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var ticketReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var authFailed = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + throw new NotImplementedException("TestException"); + }, + OnAuthenticationFailed = context => + { + authFailed = true; + Assert.Equal("TestException", context.Exception.Message); + Assert.Null(context.Ticket); + + var claims = new[] + { + new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), + new Claim(ClaimTypes.Email, "bob@contoso.com"), + new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") + }; + + context.Ticket = new AuthenticationTicket( + new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), + new AuthenticationProperties(), context.Options.AuthenticationScheme); + + context.HandleResponse(); + return Task.FromResult(0); + }, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = context => + { + ticketReceived = true; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(authFailed); + Assert.True(ticketReceived); + } + + [Fact] + public async Task OnRemoteFailure_Skipped_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var authFailed = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + throw new NotImplementedException("TestException"); + }, + OnAuthenticationFailed = context => + { + authFailed = true; + Assert.Equal("TestException", context.Exception.Message); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + Assert.Equal("TestException", context.Failure.Message); + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(authFailed); + Assert.True(remoteFailure); + } + + [Fact] + public async Task OnRemoteFailure_Handled_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var authFailed = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + throw new NotImplementedException("TestException"); + }, + OnAuthenticationFailed = context => + { + authFailed = true; + Assert.Equal("TestException", context.Exception.Message); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + Assert.Equal("TestException", context.Failure.Message); + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(authFailed); + Assert.True(remoteFailure); + } + + [Fact] + public async Task OnTicketReceived_Skipped_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var ticektReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + return Task.FromResult(0); + }, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = context => + { + ticektReceived = true; + context.SkipToNextMiddleware(); + return Task.FromResult(0); + }, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(ticektReceived); + } + + [Fact] + public async Task OnTicketReceived_Handled_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var ticektReceived = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + return Task.FromResult(0); + }, + OnAuthenticationFailed = FailedNotImpl, + OnRemoteFailure = FailureNotImpl, + OnTicketReceived = context => + { + ticektReceived = true; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(ticektReceived); + } + + private TestServer CreateServer(OpenIdConnectEvents events, RequestDelegate appCode) + { + var builder = new WebHostBuilder() + .ConfigureServices(services => + { + services.AddAuthentication(); + }) + .Configure(app => + { + app.UseCookieAuthentication(); + app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions() + { + Events = events, + SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme, + ClientId = "ClientId", + GetClaimsFromUserInfoEndpoint = true, + Configuration = new OpenIdConnectConfiguration() + { + TokenEndpoint = "http://testhost/tokens", + UserInfoEndpoint = "http://testhost/user", + }, + StateDataFormat = new TestStateDataFormat(), + SecurityTokenValidator = new TestTokenValidator(), + ProtocolValidator = new TestProtocolValidator(), + BackchannelHttpHandler = new TestBackchannel(), + }); + app.Run(appCode); + }); + + return new TestServer(builder); + } + + private Task PostAsync(TestServer server, string path, string form) + { + var client = server.CreateClient(); + var cookie = ".AspNetCore.Correlation." + OpenIdConnectDefaults.AuthenticationScheme + ".corrilationId=N"; + client.DefaultRequestHeaders.Add("Cookie", cookie); + return client.PostAsync("signin-oidc", + new StringContent(form, Encoding.ASCII, "application/x-www-form-urlencoded")); + } + + private class TestStateDataFormat : ISecureDataFormat + { + private AuthenticationProperties Data { get; set; } + + public string Protect(AuthenticationProperties data) + { + throw new NotImplementedException(); + } + + public string Protect(AuthenticationProperties data, string purpose) + { + throw new NotImplementedException(); + } + + public AuthenticationProperties Unprotect(string protectedText) + { + Assert.Equal("protected_state", protectedText); + return new AuthenticationProperties(new Dictionary() + { + { ".xsrf", "corrilationId" }, + { OpenIdConnectDefaults.RedirectUriForCodePropertiesKey, "redirect_uri" } + }); + } + + public AuthenticationProperties Unprotect(string protectedText, string purpose) + { + throw new NotImplementedException(); + } + } + + private class TestTokenValidator : ISecurityTokenValidator + { + public bool CanValidateToken => true; + + public int MaximumTokenSizeInBytes + { + get { return 1024; } + set { throw new NotImplementedException(); } + } + + public bool CanReadToken(string securityToken) + { + Assert.Equal("my_id_token", securityToken); + return true; + } + + public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParameters validationParameters, out SecurityToken validatedToken) + { + Assert.Equal("my_id_token", securityToken); + validatedToken = new JwtSecurityToken(); + return new ClaimsPrincipal(new ClaimsIdentity("customAuthType")); + } + } + + private class TestProtocolValidator : OpenIdConnectProtocolValidator + { + public override void ValidateAuthenticationResponse(OpenIdConnectProtocolValidationContext validationContext) + { + } + + public override void ValidateTokenResponse(OpenIdConnectProtocolValidationContext validationContext) + { + } + + public override void ValidateUserInfoResponse(OpenIdConnectProtocolValidationContext validationContext) + { + } + } + + private class TestBackchannel : HttpMessageHandler + { + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + if (string.Equals("/tokens", request.RequestUri.AbsolutePath, StringComparison.Ordinal)) + { + return Task.FromResult(new HttpResponseMessage() { Content = + new StringContent("{ \"id_token\": \"my_id_token\", \"access_token\": \"my_access_token\" }", Encoding.ASCII, "application/json") }); + } + if (string.Equals("/user", request.RequestUri.AbsolutePath, StringComparison.Ordinal)) + { + return Task.FromResult(new HttpResponseMessage() { Content = new StringContent("{ }", Encoding.ASCII, "application/json") }); + } + + throw new NotImplementedException(request.RequestUri.ToString()); + } + } + } +} From 500201bdf769e9cba67c5b0801801f6ec4678da5 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Mon, 31 Oct 2016 10:46:18 -0700 Subject: [PATCH 651/900] Made ChunkingCookieManager's default chunk size public --- .../ChunkingCookieManager.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs index 26fe0809c5..16426507ce 100644 --- a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs +++ b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -30,6 +30,11 @@ namespace Microsoft.AspNetCore.Internal internal class ChunkingCookieManager { #endif + /// + /// The default maximum size of characters in a cookie to send back to the client. + /// + public const int DefaultChunkSize = 4070; + private const string ChunkKeySuffix = "C"; private const string ChunkCountPrefix = "chunks-"; @@ -38,7 +43,7 @@ namespace Microsoft.AspNetCore.Internal // Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case. // See http://browsercookielimits.x64.me/. // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. - ChunkSize = 4070; + ChunkSize = DefaultChunkSize; ThrowForPartialCookies = true; } From e55e3b6f5a9f14e2971769d3a619eaec878c2e89 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Tue, 1 Nov 2016 12:22:42 -0700 Subject: [PATCH 652/900] Updated Authentication's Base64UrlTextEncoder to use WebUtilities's Base64UrlTextEncoder logic --- .../DataHandler/TextEncoder.cs | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs b/src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs index c07a314b05..c0663295cf 100644 --- a/src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs +++ b/src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs @@ -1,31 +1,30 @@ // 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.AspNetCore.Authentication { public static class Base64UrlTextEncoder { + /// + /// Encodes supplied data into Base64 and replaces any URL encodable characters into non-URL encodable + /// characters. + /// + /// Data to be encoded. + /// Base64 encoded string modified with non-URL encodable characters public static string Encode(byte[] data) { - return Convert.ToBase64String(data).TrimEnd('=').Replace('+', '-').Replace('/', '_'); + return WebUtilities.Base64UrlTextEncoder.Encode(data); } + /// + /// Decodes supplied string by replacing the non-URL encodable characters with URL encodable characters and + /// then decodes the Base64 string. + /// + /// The string to be decoded. + /// The decoded data. public static byte[] Decode(string text) { - return Convert.FromBase64String(Pad(text.Replace('-', '+').Replace('_', '/'))); + return WebUtilities.Base64UrlTextEncoder.Decode(text); } - - private static string Pad(string text) - { - var padding = 3 - ((text.Length + 3) % 4); - if (padding == 0) - { - return text; - } - return text + new string('=', padding); - } - } } From 834718d1f90c1f8fd4ffabc779269149ce285888 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 2 Nov 2016 14:43:57 -0700 Subject: [PATCH 653/900] Updating to RTM builds of IdentityModel packages --- src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json | 2 +- .../project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 7103ca2542..f2e9b5dd26 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -26,7 +26,7 @@ "version": "1.1.0-*", "type": "build" }, - "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.1-*", + "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.1.0", "NETStandard.Library": "1.6.1-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 234b9fd376..33f13c66cf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -26,7 +26,7 @@ "version": "1.1.0-*", "type": "build" }, - "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.1-*", + "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.1.0", "NETStandard.Library": "1.6.1-*" }, "frameworks": { From 0c815da523fcf8435bb46105c43e21ab1123bfef Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 4 Nov 2016 10:50:40 -0700 Subject: [PATCH 654/900] #903 Ensure redirect uris can be generated --- .../OpenIdConnectHandler.cs | 12 ++++++++++++ .../OpenIdConnect/OpenIdConnectChallengeTests.cs | 12 ++++++++++++ .../OpenIdConnect/OpenIdConnectMiddlewareTests.cs | 11 +++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 9cc4fc2cd4..6c3c2e9387 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -208,6 +208,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect message.State = Options.StateDataFormat.Protect(properties); + if (string.IsNullOrEmpty(message.IssuerAddress)) + { + throw new InvalidOperationException( + "Cannot redirect to the end session endpoint, the configuration may be missing or invalid."); + } + if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet) { var redirectUri = message.CreateLogoutRequestUrl(); @@ -356,6 +362,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect message.State = Options.StateDataFormat.Protect(properties); + if (string.IsNullOrEmpty(message.IssuerAddress)) + { + throw new InvalidOperationException( + "Cannot redirect to the authorization endpoint, the configuration may be missing or invalid."); + } + if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet) { var redirectUri = message.CreateAuthenticationRequestUrl(); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index fc9338e2bf..b9c0179aff 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -222,6 +222,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { var newMessage = new MockOpenIdConnectMessage { + IssuerAddress = "http://example.com/", TestAuthorizeEndpoint = $"http://example.com/{Guid.NewGuid()}/oauth2/signin" }; @@ -322,5 +323,16 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect Assert.StartsWith(".AspNetCore.Correlation.OpenIdConnect.", secondCookie); Assert.Contains("expires", secondCookie); } + + [Fact] + public async Task Challenge_WithEmptyConfig_Fails() + { + var settings = new TestSettings( + opt => opt.Configuration = new OpenIdConnectConfiguration()); + + var server = settings.CreateTestServer(); + var exception = await Assert.ThrowsAsync(() => server.SendAsync(ChallengeEndpoint)); + Assert.Equal("Cannot redirect to the authorization endpoint, the configuration may be missing or invalid.", exception.Message); + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 2862e10537..6c427c600e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -135,6 +135,17 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect Assert.Equal("http://www.example.com/specific_redirect_uri", properties.RedirectUri, true); } + [Fact] + public async Task SignOut_WithMissingConfig_Throws() + { + var setting = new TestSettings(opt => opt.Configuration = new OpenIdConnectConfiguration()); + + var server = setting.CreateTestServer(); + + var exception = await Assert.ThrowsAsync(() => server.SendAsync(DefaultHost + TestServerBuilder.Signout)); + Assert.Equal("Cannot redirect to the end session endpoint, the configuration may be missing or invalid.", exception.Message); + } + // Test Cases for calculating the expiration time of cookie from cookie name [Fact] public void NonceCookieExpirationTime() From 415055ebabcee656475e1f22e65045851641701c Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 7 Nov 2016 12:33:49 -0800 Subject: [PATCH 655/900] #1007 Additional id_token validation --- .../OpenIdConnectHandler.cs | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 6c3c2e9387..6691c4ed69 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -541,7 +541,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Logger.ReceivedIdToken(); ticket = ValidateToken(authorizationResponse.IdToken, properties, validationParameters, out jwt); - nonce = jwt?.Payload.Nonce; + nonce = jwt.Payload.Nonce; if (!string.IsNullOrEmpty(nonce)) { nonce = ReadNonceCookie(nonce); @@ -599,22 +599,25 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect authorizationResponse = tokenResponseReceivedContext.ProtocolMessage; tokenEndpointResponse = tokenResponseReceivedContext.TokenEndpointResponse; - // We only have to process the IdToken if we didn't already get one in the AuthorizationResponse + // no need to validate signature when token is received using "code flow" as per spec + // [http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation]. + validationParameters.RequireSignedTokens = false; + + // At least a cursory validation is required on the new IdToken, even if we've already validated the one from the authorization response. + // And we'll want to validate the new JWT in ValidateTokenResponse. + JwtSecurityToken tokenEndpointJwt; + var tokenEndpointTicket = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out tokenEndpointJwt); + + // Avoid reading & deleting the nonce cookie, running the event, etc, if it was already done as part of the authorization response validation. if (ticket == null) { - // no need to validate signature when token is received using "code flow" as per spec - // [http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation]. - validationParameters.RequireSignedTokens = false; - - ticket = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out jwt); - - nonce = jwt?.Payload.Nonce; + nonce = tokenEndpointJwt.Payload.Nonce; if (!string.IsNullOrEmpty(nonce)) { nonce = ReadNonceCookie(nonce); } - var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, tokenEndpointResponse, properties, ticket, jwt, nonce); + var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, tokenEndpointResponse, properties, tokenEndpointTicket, tokenEndpointJwt, nonce); if (tokenValidatedContext.CheckEventResult(out result)) { return result; @@ -626,6 +629,15 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect jwt = tokenValidatedContext.SecurityToken; nonce = tokenValidatedContext.Nonce; } + else + { + if (!string.Equals(jwt.Subject, tokenEndpointJwt.Subject, StringComparison.Ordinal)) + { + throw new SecurityTokenException("The sub claim does not match in the id_token's from the authorization and token endpoints."); + } + + jwt = tokenEndpointJwt; + } // Validate the token response if it wasn't provided manually if (!authorizationCodeReceivedContext.HandledCodeRedemption) From 96c27fa39389190298bf9b65362d2c090b47731c Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Tue, 8 Nov 2016 10:32:46 -0800 Subject: [PATCH 656/900] Revert breaking parameter rename --- .../OpenIdConnectHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 6691c4ed69..c9c513ea72 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -150,7 +150,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Redirect user to the identity provider for sign out /// /// A task executing the sign out procedure - protected override async Task HandleSignOutAsync(SignOutContext context) + protected override async Task HandleSignOutAsync(SignOutContext signout) { Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); @@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect }; // Get the post redirect URI. - var properties = new AuthenticationProperties(context.Properties); + var properties = new AuthenticationProperties(signout.Properties); if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = BuildRedirectUriIfRelative(Options.PostLogoutRedirectUri); From 82c231efca8a4afdc471929020a42038b90ba78e Mon Sep 17 00:00:00 2001 From: jacalvar Date: Mon, 7 Nov 2016 21:27:52 -0800 Subject: [PATCH 657/900] Created public API baselines --- .../baseline.net45.json | 1661 ++++++++++ .../baseline.netcore.json | 1661 ++++++++++ .../baseline.net45.json | 453 +++ .../baseline.netcore.json | 453 +++ .../baseline.net45.json | 291 ++ .../baseline.netcore.json | 291 ++ .../baseline.net45.json | 976 ++++++ .../baseline.netcore.json | 976 ++++++ .../baseline.net45.json | 256 ++ .../baseline.netcore.json | 256 ++ .../baseline.net45.json | 955 ++++++ .../baseline.netcore.json | 955 ++++++ .../baseline.net45.json | 2005 ++++++++++++ .../baseline.netcore.json | 2005 ++++++++++++ .../baseline.net45.json | 848 +++++ .../baseline.netcore.json | 848 +++++ .../baseline.net45.json | 2897 +++++++++++++++++ .../baseline.netcore.json | 2897 +++++++++++++++++ .../baseline.net45.json | 1593 +++++++++ .../baseline.netcore.json | 1593 +++++++++ .../baseline.net45.json | 392 +++ .../baseline.netcore.json | 392 +++ .../baseline.net45.json | 373 +++ 23 files changed, 25027 insertions(+) create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Authentication/baseline.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authorization/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Authorization/baseline.netcore.json create mode 100644 src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json create mode 100644 src/Microsoft.Owin.Security.Interop/baseline.net45.json diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json new file mode 100644 index 0000000000..56e48d3fed --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json @@ -0,0 +1,1661 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseCookieAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseCookieAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_CookieName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieDomain", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieDomain", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookiePath", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookiePath", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieHttpOnly", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieHttpOnly", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieSecure", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieSecure", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DataProtectionProvider", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DataProtectionProvider", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ExpireTimeSpan", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ExpireTimeSpan", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SlidingExpiration", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SlidingExpiration", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_LoginPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_LoginPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_LogoutPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_LogoutPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessDeniedPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AccessDeniedPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ReturnUrlParameter", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ReturnUrlParameter", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TicketDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TicketDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SystemClock", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SystemClock", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieManager", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieManager", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SessionStore", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SessionStore", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_ChunkSize", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ChunkSize", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ThrowForPartialCookies", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ThrowForPartialCookies", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetRequestCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AppendResponseCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "CookiePrefix", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "LoginPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "LogoutPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessDeniedPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "ReturnUrlParameter", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Cookies\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "urlEncoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetRequestCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AppendResponseCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "StoreAsync", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RenewAsync", + "Parameters": [ + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RetrieveAsync", + "Parameters": [ + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoveAsync", + "Parameters": [ + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnValidatePrincipal", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnValidatePrincipal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSigningIn", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSigningIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSignedIn", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSignedIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSigningOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSigningOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToLogin", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToLogin", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToAccessDenied", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToAccessDenied", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToLogout", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToLogout", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToReturnUrl", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToReturnUrl", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidatePrincipal", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SigningIn", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignedIn", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SigningOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToLogout", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToLogin", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToReturnUrl", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAccessDenied", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RedirectUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RedirectUri", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + }, + { + "Name": "redirectUri", + "Type": "System.String" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Principal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieOptions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieOptions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "cookieOptions", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_CookieOptions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieOptions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "cookieOptions", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ShouldRenew", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ShouldRenew", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReplacePrincipal", + "Parameters": [ + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RejectPrincipal", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "ValidatePrincipal", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SigningIn", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignedIn", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToLogout", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToLogin", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToReturnUrl", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAccessDenied", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SigningOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json new file mode 100644 index 0000000000..56e48d3fed --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json @@ -0,0 +1,1661 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseCookieAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseCookieAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_CookieName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieDomain", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieDomain", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookiePath", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookiePath", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieHttpOnly", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieHttpOnly", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieSecure", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieSecure", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DataProtectionProvider", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DataProtectionProvider", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ExpireTimeSpan", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ExpireTimeSpan", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SlidingExpiration", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SlidingExpiration", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_LoginPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_LoginPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_LogoutPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_LogoutPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessDeniedPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AccessDeniedPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ReturnUrlParameter", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ReturnUrlParameter", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TicketDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TicketDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SystemClock", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SystemClock", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieManager", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieManager", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SessionStore", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SessionStore", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_ChunkSize", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ChunkSize", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ThrowForPartialCookies", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ThrowForPartialCookies", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetRequestCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AppendResponseCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "CookiePrefix", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "LoginPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "LogoutPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessDeniedPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "ReturnUrlParameter", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Cookies\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "urlEncoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetRequestCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AppendResponseCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "StoreAsync", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RenewAsync", + "Parameters": [ + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RetrieveAsync", + "Parameters": [ + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoveAsync", + "Parameters": [ + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnValidatePrincipal", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnValidatePrincipal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSigningIn", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSigningIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSignedIn", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSignedIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSigningOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSigningOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToLogin", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToLogin", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToAccessDenied", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToAccessDenied", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToLogout", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToLogout", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToReturnUrl", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToReturnUrl", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidatePrincipal", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SigningIn", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignedIn", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SigningOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToLogout", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToLogin", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToReturnUrl", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAccessDenied", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RedirectUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RedirectUri", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + }, + { + "Name": "redirectUri", + "Type": "System.String" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Principal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieOptions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieOptions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "cookieOptions", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_CookieOptions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieOptions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "cookieOptions", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ShouldRenew", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ShouldRenew", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReplacePrincipal", + "Parameters": [ + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RejectPrincipal", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "ValidatePrincipal", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SigningIn", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignedIn", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToLogout", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToLogin", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToReturnUrl", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAccessDenied", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SigningOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json new file mode 100644 index 0000000000..1e070fc7ff --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json @@ -0,0 +1,453 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Facebook\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookHelper", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetId", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetAgeRangeMin", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetAgeRangeMax", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetBirthday", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetEmail", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetFirstName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetGender", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetLastName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetLink", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetLocation", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetLocale", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetMiddleName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetTimeZone", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseFacebookAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseFacebookAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.FacebookOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.FacebookOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AppId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AppId", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AppSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AppSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SendAppSecretProof", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SendAppSecretProof", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Fields", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json new file mode 100644 index 0000000000..1e070fc7ff --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json @@ -0,0 +1,453 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Facebook\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookHelper", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetId", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetAgeRangeMin", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetAgeRangeMax", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetBirthday", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetEmail", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetFirstName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetGender", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetLastName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetLink", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetLocation", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetLocale", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetMiddleName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetTimeZone", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseFacebookAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseFacebookAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.FacebookOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.FacebookOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AppId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AppId", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AppSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AppSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SendAppSecretProof", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SendAppSecretProof", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Fields", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json new file mode 100644 index 0000000000..647633afa8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json @@ -0,0 +1,291 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Google\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetId", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetGivenName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetFamilyName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetProfile", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetEmail", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.GoogleAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseGoogleAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseGoogleAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.GoogleOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.GoogleOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AccessType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AccessType", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json new file mode 100644 index 0000000000..647633afa8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json @@ -0,0 +1,291 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Google\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetId", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetGivenName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetFamilyName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetProfile", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetEmail", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.GoogleAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseGoogleAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseGoogleAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.GoogleOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.GoogleOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AccessType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AccessType", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json new file mode 100644 index 0000000000..37e18e53ed --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json @@ -0,0 +1,976 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Bearer\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Exception", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Exception", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.JwtBearerOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AuthenticationFailed", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Challenge", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthenticateFailure", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthenticateFailure", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Error", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Error", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ErrorDescription", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ErrorDescription", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ErrorUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ErrorUri", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnAuthenticationFailed", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnAuthenticationFailed", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnMessageReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnMessageReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnTokenValidated", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTokenValidated", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnChallenge", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnChallenge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthenticationFailed", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Challenge", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Token", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Token", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_SecurityToken", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.SecurityToken", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SecurityToken", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.SecurityToken" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseJwtBearerAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseJwtBearerAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.JwtBearerOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RequireHttpsMetadata", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RequireHttpsMetadata", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_MetadataAddress", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MetadataAddress", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Authority", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Authority", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Audience", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Audience", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Challenge", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Challenge", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_BackchannelHttpHandler", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpMessageHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_BackchannelHttpHandler", + "Parameters": [ + { + "Name": "value", + "Type": "System.Net.Http.HttpMessageHandler" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_BackchannelTimeout", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_BackchannelTimeout", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ConfigurationManager", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.IConfigurationManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConfigurationManager", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.IConfigurationManager" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshOnIssuerKeyNotFound", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RefreshOnIssuerKeyNotFound", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SystemClock", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SystemClock", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SecurityTokenValidators", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenValidationParameters", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.TokenValidationParameters", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenValidationParameters", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.TokenValidationParameters" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SaveToken", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SaveToken", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IncludeErrorDetails", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IncludeErrorDetails", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json new file mode 100644 index 0000000000..37e18e53ed --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json @@ -0,0 +1,976 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Bearer\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Exception", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Exception", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.JwtBearerOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AuthenticationFailed", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Challenge", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthenticateFailure", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthenticateFailure", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Error", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Error", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ErrorDescription", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ErrorDescription", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ErrorUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ErrorUri", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnAuthenticationFailed", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnAuthenticationFailed", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnMessageReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnMessageReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnTokenValidated", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTokenValidated", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnChallenge", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnChallenge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthenticationFailed", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Challenge", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Token", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Token", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_SecurityToken", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.SecurityToken", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SecurityToken", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.SecurityToken" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseJwtBearerAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseJwtBearerAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.JwtBearerOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RequireHttpsMetadata", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RequireHttpsMetadata", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_MetadataAddress", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MetadataAddress", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Authority", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Authority", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Audience", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Audience", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Challenge", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Challenge", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_BackchannelHttpHandler", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpMessageHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_BackchannelHttpHandler", + "Parameters": [ + { + "Name": "value", + "Type": "System.Net.Http.HttpMessageHandler" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_BackchannelTimeout", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_BackchannelTimeout", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ConfigurationManager", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.IConfigurationManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConfigurationManager", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.IConfigurationManager" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshOnIssuerKeyNotFound", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RefreshOnIssuerKeyNotFound", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SystemClock", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SystemClock", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SecurityTokenValidators", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenValidationParameters", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.TokenValidationParameters", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenValidationParameters", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.TokenValidationParameters" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SaveToken", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SaveToken", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IncludeErrorDetails", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IncludeErrorDetails", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json new file mode 100644 index 0000000000..06b3cd0d53 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json @@ -0,0 +1,256 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Microsoft\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetId", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetDisplayName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetGivenName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetSurname", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetEmail", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.MicrosoftAccountAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseMicrosoftAccountAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseMicrosoftAccountAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json new file mode 100644 index 0000000000..06b3cd0d53 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json @@ -0,0 +1,256 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Microsoft\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetId", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetDisplayName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetGivenName", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetSurname", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetEmail", + "Parameters": [ + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.MicrosoftAccountAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseMicrosoftAccountAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseMicrosoftAccountAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json new file mode 100644 index 0000000000..d485aedb17 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json @@ -0,0 +1,955 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExchangeCodeAsync", + "Parameters": [ + { + "Name": "code", + "Type": "System.String" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleUnauthorizedAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "BuildChallengeUrl", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Builder.OAuthOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Builder.OAuthOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Success", + "Parameters": [ + { + "Name": "response", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Failed", + "Parameters": [ + { + "Name": "error", + "Type": "System.Exception" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Response", + "Parameters": [], + "ReturnType": "Newtonsoft.Json.Linq.JObject", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Response", + "Parameters": [ + { + "Name": "value", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AccessToken", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenType", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RefreshToken", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ExpiresIn", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ExpiresIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Error", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Error", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "CreatingTicket", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_User", + "Parameters": [], + "ReturnType": "Newtonsoft.Json.Linq.JObject", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenResponse", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ExpiresIn", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Ticket", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Ticket", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Identity", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + }, + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + }, + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + }, + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnCreatingTicket", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnCreatingTicket", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToAuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreatingTicket", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RedirectUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseOAuthAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseOAuthAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.OAuthOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ClientId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClientId", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClientSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClientSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthorizationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UserInformationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UserInformationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Scope", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StateDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SystemClock", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SystemClock", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json new file mode 100644 index 0000000000..d485aedb17 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json @@ -0,0 +1,955 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExchangeCodeAsync", + "Parameters": [ + { + "Name": "code", + "Type": "System.String" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleUnauthorizedAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "BuildChallengeUrl", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Builder.OAuthOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Builder.OAuthOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Success", + "Parameters": [ + { + "Name": "response", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Failed", + "Parameters": [ + { + "Name": "error", + "Type": "System.Exception" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Response", + "Parameters": [], + "ReturnType": "Newtonsoft.Json.Linq.JObject", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Response", + "Parameters": [ + { + "Name": "value", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AccessToken", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenType", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RefreshToken", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ExpiresIn", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ExpiresIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Error", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Error", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "CreatingTicket", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_User", + "Parameters": [], + "ReturnType": "Newtonsoft.Json.Linq.JObject", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenResponse", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ExpiresIn", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Ticket", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Ticket", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Identity", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + }, + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + }, + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + }, + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnCreatingTicket", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnCreatingTicket", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToAuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreatingTicket", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RedirectUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseOAuthAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseOAuthAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.OAuthOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ClientId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClientId", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClientSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClientSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthorizationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UserInformationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UserInformationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Scope", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StateDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SystemClock", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SystemClock", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json new file mode 100644 index 0000000000..64cb79487d --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json @@ -0,0 +1,2005 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthenticationPropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Caption", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "CookieNoncePrefix", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "RedirectUriForCodePropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "UserstatePropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"OpenIdConnect\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HtmlEncoder", + "Parameters": [], + "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteSignOutAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "signout", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleUnauthorizedAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedeemAuthorizationCodeAsync", + "Parameters": [ + { + "Name": "tokenEndpointRequest", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetUserInformationAsync", + "Parameters": [ + { + "Name": "message", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + }, + { + "Name": "jwt", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + }, + { + "Name": "htmlEncoder", + "Type": "System.Text.Encodings.Web.HtmlEncoder" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HtmlEncoder", + "Parameters": [], + "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "services", + "Type": "System.IServiceProvider" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "htmlEncoder", + "Type": "System.Text.Encodings.Web.HtmlEncoder" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "RedirectGet", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "FormPost", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Exception", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Exception", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_JwtSecurityToken", + "Parameters": [], + "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_JwtSecurityToken", + "Parameters": [ + { + "Name": "value", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpointRequest", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpointRequest", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpointResponse", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpointResponse", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HandledCodeRedemption", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleCodeRedemption", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleCodeRedemption", + "Parameters": [ + { + "Name": "accessToken", + "Type": "System.String" + }, + { + "Name": "idToken", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleCodeRedemption", + "Parameters": [ + { + "Name": "tokenEndpointResponse", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "AuthenticationFailed", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizationCodeReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToIdentityProvider", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToIdentityProviderForSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoteSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenResponseReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UserInformationReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Token", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Token", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnAuthenticationFailed", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnAuthenticationFailed", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnAuthorizationCodeReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnAuthorizationCodeReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnMessageReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnMessageReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToIdentityProvider", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToIdentityProvider", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToIdentityProviderForSignOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToIdentityProviderForSignOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRemoteSignOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRemoteSignOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnTokenResponseReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTokenResponseReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnTokenValidated", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTokenValidated", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnUserInformationReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnUserInformationReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthenticationFailed", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizationCodeReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToIdentityProvider", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToIdentityProviderForSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoteSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenResponseReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UserInformationReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + }, + { + "Name": "message", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpointResponse", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpointResponse", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SecurityToken", + "Parameters": [], + "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SecurityToken", + "Parameters": [ + { + "Name": "value", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpointResponse", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpointResponse", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Nonce", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Nonce", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_User", + "Parameters": [], + "ReturnType": "Newtonsoft.Json.Linq.JObject", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_User", + "Parameters": [ + { + "Name": "value", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseOpenIdConnectAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseOpenIdConnectAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Authority", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Authority", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClientId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClientId", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClientSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClientSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ConfigurationManager", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.IConfigurationManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConfigurationManager", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.IConfigurationManager" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_GetClaimsFromUserInfoEndpoint", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_GetClaimsFromUserInfoEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RequireHttpsMetadata", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RequireHttpsMetadata", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_MetadataAddress", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MetadataAddress", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProtocolValidator", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolValidator", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolValidator", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolValidator" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PostLogoutRedirectUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PostLogoutRedirectUri", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshOnIssuerKeyNotFound", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RefreshOnIssuerKeyNotFound", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthenticationMethod", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthenticationMethod", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Resource", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Resource", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ResponseMode", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ResponseMode", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ResponseType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ResponseType", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Scope", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RemoteSignOutPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RemoteSignOutPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignOutScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignOutScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StateDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StringDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StringDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SecurityTokenValidator", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.ISecurityTokenValidator", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SecurityTokenValidator", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.ISecurityTokenValidator" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenValidationParameters", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.TokenValidationParameters", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenValidationParameters", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.TokenValidationParameters" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UseTokenLifetime", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UseTokenLifetime", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SkipUnrecognizedRequests", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SkipUnrecognizedRequests", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SystemClock", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SystemClock", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "authenticationScheme", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json new file mode 100644 index 0000000000..64cb79487d --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json @@ -0,0 +1,2005 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthenticationPropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Caption", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "CookieNoncePrefix", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "RedirectUriForCodePropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "UserstatePropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"OpenIdConnect\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HtmlEncoder", + "Parameters": [], + "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteSignOutAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "signout", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleUnauthorizedAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedeemAuthorizationCodeAsync", + "Parameters": [ + { + "Name": "tokenEndpointRequest", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetUserInformationAsync", + "Parameters": [ + { + "Name": "message", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + }, + { + "Name": "jwt", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + }, + { + "Name": "htmlEncoder", + "Type": "System.Text.Encodings.Web.HtmlEncoder" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HtmlEncoder", + "Parameters": [], + "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "services", + "Type": "System.IServiceProvider" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "htmlEncoder", + "Type": "System.Text.Encodings.Web.HtmlEncoder" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "RedirectGet", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "FormPost", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Exception", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Exception", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_JwtSecurityToken", + "Parameters": [], + "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_JwtSecurityToken", + "Parameters": [ + { + "Name": "value", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpointRequest", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpointRequest", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpointResponse", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpointResponse", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HandledCodeRedemption", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleCodeRedemption", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleCodeRedemption", + "Parameters": [ + { + "Name": "accessToken", + "Type": "System.String" + }, + { + "Name": "idToken", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleCodeRedemption", + "Parameters": [ + { + "Name": "tokenEndpointResponse", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "AuthenticationFailed", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizationCodeReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToIdentityProvider", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToIdentityProviderForSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoteSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenResponseReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UserInformationReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Token", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Token", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnAuthenticationFailed", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnAuthenticationFailed", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnAuthorizationCodeReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnAuthorizationCodeReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnMessageReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnMessageReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToIdentityProvider", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToIdentityProvider", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToIdentityProviderForSignOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToIdentityProviderForSignOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRemoteSignOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRemoteSignOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnTokenResponseReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTokenResponseReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnTokenValidated", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTokenValidated", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnUserInformationReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnUserInformationReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthenticationFailed", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizationCodeReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToIdentityProvider", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToIdentityProviderForSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoteSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenResponseReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UserInformationReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + }, + { + "Name": "message", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpointResponse", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpointResponse", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SecurityToken", + "Parameters": [], + "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SecurityToken", + "Parameters": [ + { + "Name": "value", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpointResponse", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpointResponse", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Nonce", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Nonce", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_User", + "Parameters": [], + "ReturnType": "Newtonsoft.Json.Linq.JObject", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_User", + "Parameters": [ + { + "Name": "value", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseOpenIdConnectAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseOpenIdConnectAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Authority", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Authority", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClientId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClientId", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClientSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClientSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ConfigurationManager", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.IConfigurationManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConfigurationManager", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.IConfigurationManager" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_GetClaimsFromUserInfoEndpoint", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_GetClaimsFromUserInfoEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RequireHttpsMetadata", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RequireHttpsMetadata", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_MetadataAddress", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MetadataAddress", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ProtocolValidator", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolValidator", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolValidator", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolValidator" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PostLogoutRedirectUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PostLogoutRedirectUri", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshOnIssuerKeyNotFound", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RefreshOnIssuerKeyNotFound", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthenticationMethod", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthenticationMethod", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Resource", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Resource", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ResponseMode", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ResponseMode", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ResponseType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ResponseType", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Scope", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RemoteSignOutPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RemoteSignOutPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignOutScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignOutScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StateDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StringDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StringDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SecurityTokenValidator", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.ISecurityTokenValidator", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SecurityTokenValidator", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.ISecurityTokenValidator" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenValidationParameters", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.TokenValidationParameters", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenValidationParameters", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.TokenValidationParameters" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UseTokenLifetime", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UseTokenLifetime", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SkipUnrecognizedRequests", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SkipUnrecognizedRequests", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SystemClock", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SystemClock", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "authenticationScheme", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json new file mode 100644 index 0000000000..c35232a310 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json @@ -0,0 +1,848 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Twitter\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.TwitterOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "CreatingTicket", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UserId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ScreenName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessTokenSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_User", + "Parameters": [], + "ReturnType": "Newtonsoft.Json.Linq.JObject", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Principal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + }, + { + "Name": "userId", + "Type": "System.String" + }, + { + "Name": "screenName", + "Type": "System.String" + }, + { + "Name": "accessToken", + "Type": "System.String" + }, + { + "Name": "accessTokenSecret", + "Type": "System.String" + }, + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnCreatingTicket", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnCreatingTicket", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToAuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreatingTicket", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RedirectUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.AccessToken", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UserId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UserId", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ScreenName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ScreenName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Token", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Token", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CallbackConfirmed", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CallbackConfirmed", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.RequestTokenSerializer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IDataSerializer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "model", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Write", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "token", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseTwitterAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseTwitterAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.TwitterOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ConsumerKey", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConsumerKey", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ConsumerSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConsumerSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RetrieveUserDetails", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RetrieveUserDetails", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StateDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SystemClock", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SystemClock", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json new file mode 100644 index 0000000000..c35232a310 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json @@ -0,0 +1,848 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Twitter\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterMiddleware", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "dataProtectionProvider", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "sharedOptions", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.TwitterOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "CreatingTicket", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UserId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ScreenName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessTokenSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_User", + "Parameters": [], + "ReturnType": "Newtonsoft.Json.Linq.JObject", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Principal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + }, + { + "Name": "userId", + "Type": "System.String" + }, + { + "Name": "screenName", + "Type": "System.String" + }, + { + "Name": "accessToken", + "Type": "System.String" + }, + { + "Name": "accessTokenSecret", + "Type": "System.String" + }, + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnCreatingTicket", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnCreatingTicket", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToAuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreatingTicket", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RedirectUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.AccessToken", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UserId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UserId", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ScreenName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ScreenName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Token", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Token", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CallbackConfirmed", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CallbackConfirmed", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.RequestTokenSerializer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IDataSerializer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "model", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Write", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "token", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseTwitterAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseTwitterAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.TwitterOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ConsumerKey", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConsumerKey", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ConsumerSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConsumerSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RetrieveUserDetails", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RetrieveUserDetails", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StateDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SystemClock", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SystemClock", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication/baseline.net45.json new file mode 100644 index 0000000000..1f69da5a8f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/baseline.net45.json @@ -0,0 +1,2897 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthenticationScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AutomaticAuthenticate", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AutomaticAuthenticate", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AutomaticChallenge", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AutomaticChallenge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClaimsIssuer", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClaimsIssuer", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Description", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Description", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseClaimsTransformation", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseClaimsTransformation", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "transform", + "Type": "System.Func>" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseClaimsTransformation", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Transformer", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Transformer", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_BackchannelTimeout", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_BackchannelTimeout", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_BackchannelHttpHandler", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpMessageHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_BackchannelHttpHandler", + "Parameters": [ + { + "Name": "value", + "Type": "System.Net.Http.HttpMessageHandler" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CallbackPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CallbackPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignInScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignInScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DisplayName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RemoteAuthenticationTimeout", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RemoteAuthenticationTimeout", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SaveTokens", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SaveTokens", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Succeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Ticket", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Failure", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Skipped", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Success", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Skip", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failure", + "Type": "System.Exception" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_SignInAccepted", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignInAccepted", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignOutAccepted", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignOutAccepted", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ChallengeCalled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ChallengeCalled", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Context", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Request", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Response", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OriginalPathBase", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OriginalPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Logger", + "Parameters": [], + "ReturnType": "Microsoft.Extensions.Logging.ILogger", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UrlEncoder", + "Parameters": [], + "ReturnType": "System.Text.Encodings.Web.UrlEncoder", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PriorHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PriorHandler", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CurrentUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "T0", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "InitializeAsync", + "Parameters": [ + { + "Name": "options", + "Type": "T0" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILogger" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "BuildRedirectUri", + "Parameters": [ + { + "Name": "targetPath", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FinishResponseAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetDescriptions", + "Parameters": [ + { + "Name": "describeContext", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ShouldHandleScheme", + "Parameters": [ + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "handleAutomatic", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthenticateAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateOnceAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignInAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignInAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignOutAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleForbiddenAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleUnauthorizedAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ChallengeAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Builder.AuthenticationOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthenticationScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "T0", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Options", + "Parameters": [ + { + "Name": "value", + "Type": "T0" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Logger", + "Parameters": [], + "ReturnType": "Microsoft.Extensions.Logging.ILogger", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Logger", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Extensions.Logging.ILogger" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UrlEncoder", + "Parameters": [], + "ReturnType": "System.Text.Encodings.Web.UrlEncoder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UrlEncoder", + "Parameters": [ + { + "Name": "value", + "Type": "System.Text.Encodings.Web.UrlEncoder" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Invoke", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + } + ], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Builder.AuthenticationOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationToken", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Name", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Name", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Value", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Value", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Context", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Principal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_PriorHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PriorHandler", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthenticateAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ChallengeAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetDescriptions", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignInAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignOutAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RegisterAuthenticationHandler", + "Parameters": [ + { + "Name": "auth", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UnregisterAuthenticationHandler", + "Parameters": [ + { + "Name": "auth", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "transform", + "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" + }, + { + "Name": "httpContext", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Options", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Invoke", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IClaimsTransformer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnTransform", + "Parameters": [], + "ReturnType": "System.Func>", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTransform", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func>" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TransformAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "TransformAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteCallbackAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignInAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleForbiddenAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateCorrelationId", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateCorrelationId", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_SignInScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignInScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SystemClock", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.ISystemClock" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "StoreTokens", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetTokenValue", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "tokenName", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetTokens", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetTokenAsync", + "Parameters": [ + { + "Name": "manager", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" + }, + { + "Name": "tokenName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetTokenAsync", + "Parameters": [ + { + "Name": "manager", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" + }, + { + "Name": "signInScheme", + "Type": "System.String" + }, + { + "Name": "tokenName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "model", + "Type": "T0" + } + ], + "ReturnType": "System.Byte[]", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "T0", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TModel", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + } + ], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + }, + { + "Name": "purpose", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" + }, + { + "Name": "purpose", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TData", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PropertiesDataFormat", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IDataSerializer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Default", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "model", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Write", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SecureDataFormat", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + } + ], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + }, + { + "Name": "purpose", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" + }, + { + "Name": "purpose", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "serializer", + "Type": "Microsoft.AspNetCore.Authentication.IDataSerializer" + }, + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TData", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Encode", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Decode", + "Parameters": [ + { + "Name": "text", + "Type": "System.String" + } + ], + "ReturnType": "System.Byte[]", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.TicketDataFormat", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.TicketSerializer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IDataSerializer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Default", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.TicketSerializer", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Write", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteIdentity", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteClaim", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "claim", + "Type": "System.Security.Claims.Claim" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReadIdentity", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReadClaim", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + } + ], + "ReturnType": "System.Security.Claims.Claim", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.BaseContext", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_HttpContext", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Request", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Response", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_State", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.EventResultState", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_State", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.EventResultState" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HandledResponse", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Skipped", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipToNextMiddleware", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Ticket", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Ticket", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CheckEventResult", + "Parameters": [ + { + "Name": "result", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Direction": "Out" + } + ], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.EventResultState", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Continue", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "Skipped", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + }, + { + "Kind": "Field", + "Name": "HandledResponse", + "Parameters": [], + "GenericParameter": [], + "Literal": "2" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.FailureContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Failure", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Failure", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "failure", + "Type": "System.Exception" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "RemoteFailure", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.FailureContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TicketReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnRemoteFailure", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRemoteFailure", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnTicketReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTicketReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoteFailure", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.FailureContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TicketReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.TicketReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Principal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Options", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ReturnUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ReturnUri", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddAuthentication", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddAuthentication", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json new file mode 100644 index 0000000000..1f69da5a8f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json @@ -0,0 +1,2897 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthenticationScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AutomaticAuthenticate", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AutomaticAuthenticate", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AutomaticChallenge", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AutomaticChallenge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClaimsIssuer", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClaimsIssuer", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Description", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Description", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseClaimsTransformation", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseClaimsTransformation", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "transform", + "Type": "System.Func>" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseClaimsTransformation", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Transformer", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Transformer", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_BackchannelTimeout", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_BackchannelTimeout", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_BackchannelHttpHandler", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpMessageHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_BackchannelHttpHandler", + "Parameters": [ + { + "Name": "value", + "Type": "System.Net.Http.HttpMessageHandler" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CallbackPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CallbackPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignInScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignInScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DisplayName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RemoteAuthenticationTimeout", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RemoteAuthenticationTimeout", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SaveTokens", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SaveTokens", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Succeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Ticket", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Failure", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Skipped", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Success", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Skip", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failure", + "Type": "System.Exception" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_SignInAccepted", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignInAccepted", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignOutAccepted", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignOutAccepted", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ChallengeCalled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ChallengeCalled", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Context", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Request", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Response", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OriginalPathBase", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OriginalPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Logger", + "Parameters": [], + "ReturnType": "Microsoft.Extensions.Logging.ILogger", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UrlEncoder", + "Parameters": [], + "ReturnType": "System.Text.Encodings.Web.UrlEncoder", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PriorHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PriorHandler", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CurrentUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "T0", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "InitializeAsync", + "Parameters": [ + { + "Name": "options", + "Type": "T0" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILogger" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "BuildRedirectUri", + "Parameters": [ + { + "Name": "targetPath", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FinishResponseAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetDescriptions", + "Parameters": [ + { + "Name": "describeContext", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ShouldHandleScheme", + "Parameters": [ + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "handleAutomatic", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthenticateAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateOnceAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignInAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignInAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignOutAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleForbiddenAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleUnauthorizedAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ChallengeAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Builder.AuthenticationOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthenticationScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "T0", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Options", + "Parameters": [ + { + "Name": "value", + "Type": "T0" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Logger", + "Parameters": [], + "ReturnType": "Microsoft.Extensions.Logging.ILogger", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Logger", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.Extensions.Logging.ILogger" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UrlEncoder", + "Parameters": [], + "ReturnType": "System.Text.Encodings.Web.UrlEncoder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UrlEncoder", + "Parameters": [ + { + "Name": "value", + "Type": "System.Text.Encodings.Web.UrlEncoder" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Invoke", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + } + ], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Builder.AuthenticationOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationToken", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Name", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Name", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Value", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Value", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Context", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Principal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_PriorHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PriorHandler", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthenticateAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ChallengeAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetDescriptions", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignInAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignOutAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RegisterAuthenticationHandler", + "Parameters": [ + { + "Name": "auth", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UnregisterAuthenticationHandler", + "Parameters": [ + { + "Name": "auth", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "transform", + "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" + }, + { + "Name": "httpContext", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Options", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Invoke", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IClaimsTransformer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnTransform", + "Parameters": [], + "ReturnType": "System.Func>", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTransform", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func>" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TransformAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "TransformAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteCallbackAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignInAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleForbiddenAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateCorrelationId", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateCorrelationId", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_SignInScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignInScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SystemClock", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.ISystemClock" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "StoreTokens", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetTokenValue", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + }, + { + "Name": "tokenName", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetTokens", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetTokenAsync", + "Parameters": [ + { + "Name": "manager", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" + }, + { + "Name": "tokenName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetTokenAsync", + "Parameters": [ + { + "Name": "manager", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" + }, + { + "Name": "signInScheme", + "Type": "System.String" + }, + { + "Name": "tokenName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "model", + "Type": "T0" + } + ], + "ReturnType": "System.Byte[]", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "T0", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TModel", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + } + ], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + }, + { + "Name": "purpose", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" + }, + { + "Name": "purpose", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TData", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PropertiesDataFormat", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IDataSerializer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Default", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "model", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Write", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SecureDataFormat", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + } + ], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + }, + { + "Name": "purpose", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" + }, + { + "Name": "purpose", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "serializer", + "Type": "Microsoft.AspNetCore.Authentication.IDataSerializer" + }, + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TData", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Encode", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Decode", + "Parameters": [ + { + "Name": "text", + "Type": "System.String" + } + ], + "ReturnType": "System.Byte[]", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.TicketDataFormat", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.TicketSerializer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IDataSerializer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Default", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.TicketSerializer", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Write", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteIdentity", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteClaim", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "claim", + "Type": "System.Security.Claims.Claim" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReadIdentity", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReadClaim", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + } + ], + "ReturnType": "System.Security.Claims.Claim", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.BaseContext", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_HttpContext", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Request", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Response", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_State", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.EventResultState", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_State", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.EventResultState" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HandledResponse", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Skipped", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipToNextMiddleware", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Ticket", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Ticket", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CheckEventResult", + "Parameters": [ + { + "Name": "result", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Direction": "Out" + } + ], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.EventResultState", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "Continue", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "Skipped", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + }, + { + "Kind": "Field", + "Name": "HandledResponse", + "Parameters": [], + "GenericParameter": [], + "Literal": "2" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.FailureContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Failure", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Failure", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "failure", + "Type": "System.Exception" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "RemoteFailure", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.FailureContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TicketReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnRemoteFailure", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRemoteFailure", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnTicketReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTicketReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoteFailure", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.FailureContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "TicketReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.TicketReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Principal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Options", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ReturnUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ReturnUri", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddAuthentication", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddAuthentication", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/baseline.net45.json b/src/Microsoft.AspNetCore.Authorization/baseline.net45.json new file mode 100644 index 0000000000..8ae585270c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/baseline.net45.json @@ -0,0 +1,1593 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.Extensions.DependencyInjection.AuthorizationServiceCollectionExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddAuthorization", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddAuthorization", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "configure", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "System.Attribute", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAllowAnonymous" + ], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "HandleAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "T0" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TRequirement", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "HandleAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "T0" + }, + { + "Name": "resource", + "Type": "T1" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TRequirement", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ] + }, + { + "ParameterName": "TResource", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Requirements", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_User", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Resource", + "Parameters": [], + "ReturnType": "System.Object", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PendingRequirements", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HasFailed", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HasSucceeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Succeed", + "Parameters": [ + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DefaultPolicy", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DefaultPolicy", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "configurePolicy", + "Type": "System.Action" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Requirements", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IReadOnlyList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IReadOnlyList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Combine", + "Parameters": [ + { + "Name": "policies", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Combine", + "Parameters": [ + { + "Name": "policies", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CombineAsync", + "Parameters": [ + { + "Name": "policyProvider", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" + }, + { + "Name": "authorizeData", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + }, + { + "Name": "authenticationSchemes", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Requirements", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Requirements", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.IList" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthenticationSchemes", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.IList" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddAuthenticationSchemes", + "Parameters": [ + { + "Name": "schemes", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddRequirements", + "Parameters": [ + { + "Name": "requirements", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Combine", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireClaim", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "requiredValues", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireClaim", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "requiredValues", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireClaim", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireRole", + "Parameters": [ + { + "Name": "roles", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireRole", + "Parameters": [ + { + "Name": "roles", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireUserName", + "Parameters": [ + { + "Name": "userName", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireAuthenticatedUser", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireAssertion", + "Parameters": [ + { + "Name": "handler", + "Type": "System.Func" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireAssertion", + "Parameters": [ + { + "Name": "handler", + "Type": "System.Func>" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Build", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "authenticationSchemes", + "Type": "System.String[]", + "IsParams": true + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationServiceExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "service", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "service", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "service", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "service", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizeAttribute", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "System.Attribute", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizeData" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Policy", + "Parameters": [], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Policy", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Roles", + "Parameters": [], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Roles", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ActiveAuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ActiveAuthenticationSchemes", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "policy", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationPolicyProvider", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "GetDefaultPolicyAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetPolicyAsync", + "Parameters": [ + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationService", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationService" + ], + "Members": [ + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "policyProvider", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" + }, + { + "Name": "handlers", + "Type": "System.Collections.Generic.IEnumerable" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILogger" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAllowAnonymous", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "HandleAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetPolicyAsync", + "Parameters": [ + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetDefaultPolicyAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationService", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Policy", + "Parameters": [], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Policy", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Roles", + "Parameters": [], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Roles", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ActiveAuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ActiveAuthenticationSchemes", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.AssertionRequirement", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Handler", + "Parameters": [], + "ReturnType": "System.Func>", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "handler", + "Type": "System.Func" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "handler", + "Type": "System.Func>" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.ClaimsAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_ClaimType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowedValues", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.ClaimsAuthorizationRequirement" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "allowedValues", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.DenyAnonymousAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.DenyAnonymousAuthorizationRequirement" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.NameAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_RequiredName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.NameAuthorizationRequirement" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "requiredName", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.OperationAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Name", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Name", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.PassThroughAuthorizationHandler", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "HandleAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.RolesAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_AllowedRoles", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.RolesAuthorizationRequirement" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "allowedRoles", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json new file mode 100644 index 0000000000..8ae585270c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json @@ -0,0 +1,1593 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.Extensions.DependencyInjection.AuthorizationServiceCollectionExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddAuthorization", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddAuthorization", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "configure", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "System.Attribute", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAllowAnonymous" + ], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "HandleAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "T0" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TRequirement", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "HandleAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "T0" + }, + { + "Name": "resource", + "Type": "T1" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TRequirement", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ] + }, + { + "ParameterName": "TResource", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Requirements", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_User", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Resource", + "Parameters": [], + "ReturnType": "System.Object", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PendingRequirements", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HasFailed", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HasSucceeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Succeed", + "Parameters": [ + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DefaultPolicy", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DefaultPolicy", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "configurePolicy", + "Type": "System.Action" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Requirements", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IReadOnlyList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IReadOnlyList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Combine", + "Parameters": [ + { + "Name": "policies", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Combine", + "Parameters": [ + { + "Name": "policies", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CombineAsync", + "Parameters": [ + { + "Name": "policyProvider", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" + }, + { + "Name": "authorizeData", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + }, + { + "Name": "authenticationSchemes", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Requirements", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Requirements", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.IList" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthenticationSchemes", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.IList" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddAuthenticationSchemes", + "Parameters": [ + { + "Name": "schemes", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddRequirements", + "Parameters": [ + { + "Name": "requirements", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Combine", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireClaim", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "requiredValues", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireClaim", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "requiredValues", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireClaim", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireRole", + "Parameters": [ + { + "Name": "roles", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireRole", + "Parameters": [ + { + "Name": "roles", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireUserName", + "Parameters": [ + { + "Name": "userName", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireAuthenticatedUser", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireAssertion", + "Parameters": [ + { + "Name": "handler", + "Type": "System.Func" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RequireAssertion", + "Parameters": [ + { + "Name": "handler", + "Type": "System.Func>" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Build", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "authenticationSchemes", + "Type": "System.String[]", + "IsParams": true + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationServiceExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "service", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "service", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "service", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "service", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizeAttribute", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "System.Attribute", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizeData" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Policy", + "Parameters": [], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Policy", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Roles", + "Parameters": [], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Roles", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ActiveAuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ActiveAuthenticationSchemes", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "policy", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationPolicyProvider", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "GetDefaultPolicyAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetPolicyAsync", + "Parameters": [ + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationService", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationService" + ], + "Members": [ + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "policyProvider", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" + }, + { + "Name": "handlers", + "Type": "System.Collections.Generic.IEnumerable" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILogger" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAllowAnonymous", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "HandleAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetPolicyAsync", + "Parameters": [ + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetDefaultPolicyAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationService", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Policy", + "Parameters": [], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Policy", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Roles", + "Parameters": [], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Roles", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ActiveAuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ActiveAuthenticationSchemes", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.AssertionRequirement", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Handler", + "Parameters": [], + "ReturnType": "System.Func>", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "handler", + "Type": "System.Func" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "handler", + "Type": "System.Func>" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.ClaimsAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_ClaimType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowedValues", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.ClaimsAuthorizationRequirement" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "allowedValues", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.DenyAnonymousAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.DenyAnonymousAuthorizationRequirement" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.NameAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_RequiredName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.NameAuthorizationRequirement" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "requiredName", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.OperationAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Name", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Name", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.PassThroughAuthorizationHandler", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "HandleAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.RolesAuthorizationRequirement", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_AllowedRoles", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequirementAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + }, + { + "Name": "requirement", + "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.RolesAuthorizationRequirement" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "allowedRoles", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json new file mode 100644 index 0000000000..8eef347eb6 --- /dev/null +++ b/src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json @@ -0,0 +1,392 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseCookiePolicy", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseCookiePolicy", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookiePolicyOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.CookiePolicyOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_HttpOnly", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_HttpOnly", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Secure", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Secure", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnAppendCookie", + "Parameters": [], + "ReturnType": "System.Action", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnAppendCookie", + "Parameters": [ + { + "Name": "value", + "Type": "System.Action" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnDeleteCookie", + "Parameters": [], + "ReturnType": "System.Action", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnDeleteCookie", + "Parameters": [ + { + "Name": "value", + "Type": "System.Action" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.CookiePolicy.AppendCookieContext", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Context", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieOptions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieValue", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieValue", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + }, + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.CookiePolicy.CookiePolicyMiddleware", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.CookiePolicyOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Options", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Builder.CookiePolicyOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Invoke", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.CookiePolicy.DeleteCookieContext", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Context", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieOptions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + }, + { + "Name": "name", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "None", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "Always", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json new file mode 100644 index 0000000000..8eef347eb6 --- /dev/null +++ b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json @@ -0,0 +1,392 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseCookiePolicy", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseCookiePolicy", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Builder.CookiePolicyOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.CookiePolicyOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_HttpOnly", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_HttpOnly", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Secure", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Secure", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnAppendCookie", + "Parameters": [], + "ReturnType": "System.Action", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnAppendCookie", + "Parameters": [ + { + "Name": "value", + "Type": "System.Action" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnDeleteCookie", + "Parameters": [], + "ReturnType": "System.Action", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnDeleteCookie", + "Parameters": [ + { + "Name": "value", + "Type": "System.Action" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.CookiePolicy.AppendCookieContext", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Context", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieOptions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieValue", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieValue", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + }, + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.CookiePolicy.CookiePolicyMiddleware", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Builder.CookiePolicyOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Options", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Builder.CookiePolicyOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Invoke", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.CookiePolicy.DeleteCookieContext", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Context", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieOptions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + }, + { + "Name": "name", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "None", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "Always", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/baseline.net45.json b/src/Microsoft.Owin.Security.Interop/baseline.net45.json new file mode 100644 index 0000000000..1fc242ec55 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/baseline.net45.json @@ -0,0 +1,373 @@ +{ + "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.Owin.Security.DataHandler.SecureDataFormat", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.Owin.Security.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Owin.Security.Interop.AspNetTicketSerializer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Default", + "Parameters": [], + "ReturnType": "Microsoft.Owin.Security.Interop.AspNetTicketSerializer", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.Owin.Security.AuthenticationTicket" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.Owin.Security.AuthenticationTicket", + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Write", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "ticket", + "Type": "Microsoft.Owin.Security.AuthenticationTicket" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteIdentity", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteClaim", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "claim", + "Type": "System.Security.Claims.Claim" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "Microsoft.Owin.Security.AuthenticationTicket", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReadIdentity", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReadClaim", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + } + ], + "ReturnType": "System.Security.Claims.Claim", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Owin.Security.Interop.ChunkingCookieManager", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Owin.Infrastructure.ICookieManager" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_ChunkSize", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ChunkSize", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ThrowForPartialCookies", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ThrowForPartialCookies", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetRequestCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.Owin.IOwinContext" + }, + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AppendResponseCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.Owin.IOwinContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.Owin.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.Owin.IOwinContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.Owin.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Owin.Security.Interop.DataProtectorShim", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "ImplementedInterfaces": [ + "Microsoft.Owin.Security.DataProtection.IDataProtector" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "userData", + "Type": "System.Byte[]" + } + ], + "ReturnType": "System.Byte[]", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataProtection.IDataProtector", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedData", + "Type": "System.Byte[]" + } + ], + "ReturnType": "System.Byte[]", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataProtection.IDataProtector", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file From f69bd9956bc163b6841bec8f36084e5106c29d88 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 Nov 2016 11:33:20 -0800 Subject: [PATCH 658/900] Branching for 1.1.0 --- NuGet.config | 4 ++-- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 0fd623ffdd..ad973186eb 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..24ca167cf6 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..fea9ac64ad 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 46df38de68b164c2c987bd4bda5594288fec7ccb Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 Nov 2016 14:19:34 -0800 Subject: [PATCH 659/900] Updating versions to 1.2.0-* --- samples/CookieSample/project.json | 12 ++++----- samples/CookieSessionSample/project.json | 14 +++++----- samples/JwtBearerSample/project.json | 12 ++++----- .../OpenIdConnect.AzureAdSample/project.json | 14 +++++----- samples/OpenIdConnectSample/project.json | 20 +++++++------- samples/SocialSample/project.json | 26 +++++++++---------- .../project.json | 16 +++++++----- .../project.json | 6 +++-- .../project.json | 6 +++-- .../project.json | 8 +++--- .../project.json | 6 +++-- .../project.json | 8 +++--- .../project.json | 8 +++--- .../project.json | 8 +++--- .../project.json | 18 ++++++------- .../project.json | 8 +++--- .../project.json | 6 ++--- .../project.json | 6 ++--- .../project.json | 4 +-- .../project.json | 18 ++++++------- .../project.json | 8 +++--- .../project.json | 4 +-- .../project.json | 8 +++--- .../project.json | 6 ++--- 24 files changed, 133 insertions(+), 117 deletions(-) diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index 2529f14027..ae4abcc286 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -1,11 +1,11 @@ { "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", - "Microsoft.AspNetCore.DataProtection": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*" + "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", + "Microsoft.AspNetCore.DataProtection": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*" }, "buildOptions": { "emitEntryPoint": true diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index 8987d1b6ad..0892ae8fb9 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -1,12 +1,12 @@ { "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", - "Microsoft.AspNetCore.DataProtection": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.Extensions.Caching.Memory": "1.1.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*" + "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", + "Microsoft.AspNetCore.DataProtection": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.Extensions.Caching.Memory": "1.2.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*" }, "buildOptions": { "emitEntryPoint": true diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index 3a61c23ee4..a70a9bea97 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -4,12 +4,12 @@ "emitEntryPoint": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.AspNetCore.StaticFiles": "1.1.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*" + "Microsoft.AspNetCore.Authentication.JwtBearer": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.AspNetCore.StaticFiles": "1.2.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.2.0-*" }, "frameworks": { "net451": {}, diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 2cfabe8dff..26da355f36 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -1,12 +1,12 @@ { "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*", "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.13.4" }, "frameworks": { diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index 631e339afb..c429cfd2bd 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -1,15 +1,15 @@ { "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", - "Microsoft.Extensions.FileProviders.Embedded": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*", - "Microsoft.Extensions.Logging.Debug": "1.1.0-*" + "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel.Https": "1.2.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.2.0-*", + "Microsoft.Extensions.FileProviders.Embedded": "1.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*", + "Microsoft.Extensions.Logging.Debug": "1.2.0-*" }, "frameworks": { "net451": {}, diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index e041bf26ca..c46f461b78 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -1,18 +1,18 @@ { "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.Google": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0-*", - "Microsoft.AspNetCore.DataProtection": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", - "Microsoft.Extensions.FileProviders.Embedded": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*" + "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.Facebook": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.Google": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.Twitter": "1.2.0-*", + "Microsoft.AspNetCore.DataProtection": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel.Https": "1.2.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.2.0-*", + "Microsoft.Extensions.FileProviders.Embedded": "1.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*" }, "buildOptions": { "emitEntryPoint": true diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index baa2b87c2d..8cdb4bf1ef 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core middleware that enables an application to use cookie based authentication.", "packOptions": { "repository": { @@ -24,17 +24,19 @@ ] }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.AspNetCore.Authentication": { + "target": "project" + }, "Microsoft.AspNetCore.ChunkingCookieManager.Sources": { - "version": "1.1.0-*", - "type": "build" + "type": "build", + "target": "project" }, - "Microsoft.Extensions.Options": "1.1.0-*", + "Microsoft.Extensions.Options": "1.2.0-*", "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "build" }, - "Microsoft.Extensions.WebEncoders": "1.1.0-*", + "Microsoft.Extensions.WebEncoders": "1.2.0-*", "NETStandard.Library": "1.6.1-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 436b41be5f..5f60a7f810 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow.", "packOptions": { "repository": { @@ -21,7 +21,9 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.OAuth": { + "target": "project" + }, "NETStandard.Library": "1.6.1-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index b4e4a8a461..1b24f2c996 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows.", "packOptions": { "repository": { @@ -21,7 +21,9 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.OAuth": { + "target": "project" + }, "NETStandard.Library": "1.6.1-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index f2e9b5dd26..65a3888243 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token.", "packOptions": { "repository": { @@ -21,9 +21,11 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.AspNetCore.Authentication": { + "target": "project" + }, "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "build" }, "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.1.0", diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index be590b3ec9..7a2a8436ba 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow.", "packOptions": { "repository": { @@ -21,7 +21,9 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.OAuth": { + "target": "project" + }, "NETStandard.Library": "1.6.1-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index c1d6ac0799..565b72537b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow.", "packOptions": { "repository": { @@ -21,9 +21,11 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.AspNetCore.Authentication": { + "target": "project" + }, "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "build" }, "NETStandard.Library": "1.6.1-*", diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index 33f13c66cf..dc137510a4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow.", "packOptions": { "repository": { @@ -21,9 +21,11 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.AspNetCore.Authentication": { + "target": "project" + }, "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "build" }, "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.1.0", diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index 28239ec93a..c4fa7ea462 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow.", "packOptions": { "repository": { @@ -21,9 +21,11 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Authentication": "1.1.0-*", + "Microsoft.AspNetCore.Authentication": { + "target": "project" + }, "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "build" }, "NETStandard.Library": "1.6.1-*", diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index 4f0bc2bc99..2006c8497a 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core common types used by the various authentication middleware components.", "packOptions": { "repository": { @@ -21,20 +21,20 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.DataProtection": "1.1.0-*", - "Microsoft.AspNetCore.Http": "1.1.0-*", - "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", - "Microsoft.Extensions.Logging.Abstractions": "1.1.0-*", - "Microsoft.Extensions.Options": "1.1.0-*", + "Microsoft.AspNetCore.DataProtection": "1.2.0-*", + "Microsoft.AspNetCore.Http": "1.2.0-*", + "Microsoft.AspNetCore.Http.Extensions": "1.2.0-*", + "Microsoft.Extensions.Logging.Abstractions": "1.2.0-*", + "Microsoft.Extensions.Options": "1.2.0-*", "Microsoft.Extensions.SecurityHelper.Sources": { "type": "build", - "version": "1.1.0-*" + "version": "1.2.0-*" }, "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "build" }, - "Microsoft.Extensions.WebEncoders": "1.1.0-*", + "Microsoft.Extensions.WebEncoders": "1.2.0-*", "NETStandard.Library": "1.6.1-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index fc455c84dd..3875aae17e 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core authorization classes.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Authorization.AllowAnonymousAttribute\r\nMicrosoft.AspNetCore.Authorization.AuthorizeAttribute", "packOptions": { "repository": { @@ -20,10 +20,10 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "1.1.0-*", - "Microsoft.Extensions.Options": "1.1.0-*", + "Microsoft.Extensions.Logging.Abstractions": "1.2.0-*", + "Microsoft.Extensions.Options": "1.2.0-*", "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "build" }, "NETStandard.Library": "1.6.1-*" diff --git a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json index 96571bb786..693fba630a 100644 --- a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json +++ b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json @@ -1,9 +1,9 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "shared": "*.cs", "dependencies": { - "Microsoft.AspNetCore.Http.Abstractions": "1.1.0-*", - "Microsoft.Net.Http.Headers": "1.1.0-*", + "Microsoft.AspNetCore.Http.Abstractions": "1.2.0-*", + "Microsoft.Net.Http.Headers": "1.2.0-*", "NETStandard.Library": "1.6.1-*" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json index 471dfc8a8e..5a0eca5f43 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "ASP.NET Core cookie policy classes to control the behavior of cookies.", "packOptions": { "repository": { @@ -19,8 +19,8 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Http": "1.1.0-*", - "Microsoft.Extensions.Options": "1.1.0-*", + "Microsoft.AspNetCore.Http": "1.2.0-*", + "Microsoft.Extensions.Options": "1.2.0-*", "NETStandard.Library": "1.6.1-*" }, "frameworks": { diff --git a/src/Microsoft.Owin.Security.Interop/project.json b/src/Microsoft.Owin.Security.Interop/project.json index be6e48490b..82e22660d8 100644 --- a/src/Microsoft.Owin.Security.Interop/project.json +++ b/src/Microsoft.Owin.Security.Interop/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", @@ -18,7 +18,7 @@ ] }, "dependencies": { - "Microsoft.AspNetCore.DataProtection.Extensions": "1.1.0-*", + "Microsoft.AspNetCore.DataProtection.Extensions": "1.2.0-*", "Microsoft.Owin.Security": "3.0.1", "NETStandard.Library": "1.6.1-*" }, diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 8bbb453200..719a55c19c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -4,15 +4,15 @@ }, "dependencies": { "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.Google": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0-*", - "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0-*", - "Microsoft.AspNetCore.TestHost": "1.1.0-*", - "Microsoft.AspNetCore.Testing": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.Facebook": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.Google": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.JwtBearer": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.2.0-*", + "Microsoft.AspNetCore.Authentication.Twitter": "1.2.0-*", + "Microsoft.AspNetCore.TestHost": "1.2.0-*", + "Microsoft.AspNetCore.Testing": "1.2.0-*", "xunit": "2.2.0-*" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index c483cee312..15bb60f492 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -4,10 +4,10 @@ }, "dependencies": { "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Authorization": "1.1.0-*", - "Microsoft.AspNetCore.Testing": "1.1.0-*", - "Microsoft.Extensions.DependencyInjection": "1.1.0-*", - "Microsoft.Extensions.Logging": "1.1.0-*", + "Microsoft.AspNetCore.Authorization": "1.2.0-*", + "Microsoft.AspNetCore.Testing": "1.2.0-*", + "Microsoft.Extensions.DependencyInjection": "1.2.0-*", + "Microsoft.Extensions.Logging": "1.2.0-*", "xunit": "2.2.0-*" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json index 0597e0fab8..920882e455 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json @@ -5,10 +5,10 @@ "dependencies": { "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.ChunkingCookieManager.Sources": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "build" }, - "Microsoft.AspNetCore.Http": "1.1.0-*", + "Microsoft.AspNetCore.Http": "1.2.0-*", "xunit": "2.2.0-*" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index df7e38f4ab..cce61bd691 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -4,10 +4,10 @@ }, "dependencies": { "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", - "Microsoft.AspNetCore.CookiePolicy": "1.1.0-*", - "Microsoft.AspNetCore.TestHost": "1.1.0-*", - "Microsoft.Extensions.DependencyInjection": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", + "Microsoft.AspNetCore.CookiePolicy": "1.2.0-*", + "Microsoft.AspNetCore.TestHost": "1.2.0-*", + "Microsoft.Extensions.DependencyInjection": "1.2.0-*", "xunit": "2.2.0-*" }, "frameworks": { diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index 89709865e0..bd37d47b91 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -4,10 +4,10 @@ }, "dependencies": { "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*", - "Microsoft.AspNetCore.TestHost": "1.1.0-*", + "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", + "Microsoft.AspNetCore.TestHost": "1.2.0-*", "Microsoft.Owin.Security.Cookies": "3.0.1", - "Microsoft.Owin.Security.Interop": "1.1.0-*", + "Microsoft.Owin.Security.Interop": "1.2.0-*", "Microsoft.Owin.Testing": "3.0.1", "NETStandard.Library": "1.6.1-*", "xunit": "2.2.0-*" From 6bf2430899c7b545be80865bff2faa1edb8cca2b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 18 Nov 2016 10:57:09 -0800 Subject: [PATCH 660/900] Clean tmp folder after unzipping KoreBuild --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index f4208100eb..4fd7ede788 100755 --- a/build.sh +++ b/build.sh @@ -38,7 +38,7 @@ if test ! -d $buildFolder; then chmod +x $buildFile # Cleanup - if test ! -d $tempFolder; then + if test -d $tempFolder; then rm -rf $tempFolder fi fi From db6135bb792e6fbf017035d5e1059dedb38d8f3d Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 23 Nov 2016 16:00:22 -0800 Subject: [PATCH 661/900] Pin global.json SDK to 1.0.0-preview2-1-003177. --- global.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 983ba0401e..f45e8cc925 100644 --- a/global.json +++ b/global.json @@ -1,3 +1,8 @@ { - "projects": ["src"] -} + "projects": [ + "src" + ], + "sdk": { + "version": "1.0.0-preview2-1-003177" + } +} \ No newline at end of file From 219617fa2123b42eab13f81704f9dd967ab2e01f Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 8 Dec 2016 10:04:15 -0800 Subject: [PATCH 662/900] Update .travis.yml osx image to xcode7.3. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d7636fa329..a0be886892 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ mono: os: - linux - osx -osx_image: xcode7.1 +osx_image: xcode7.3 branches: only: - master From f00db3e66dcd2974bbc61e8caf0f4d76c52b27c9 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Mon, 12 Dec 2016 00:50:48 -0800 Subject: [PATCH 663/900] Removed packages list in NuGetPackageVerifier.json --- NuGetPackageVerifier.json | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index c522f4c1a8..348835e2d2 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -1,23 +1,4 @@ { - "adx": { // Packages written by the ADX team and that ship on NuGet.org - "rules": [ - "AdxVerificationCompositeRule" - ], - "packages": { - "Microsoft.AspNetCore.Authentication": { }, - "Microsoft.AspNetCore.Authentication.Cookies": { }, - "Microsoft.AspNetCore.Authentication.Facebook": { }, - "Microsoft.AspNetCore.Authentication.Google": { }, - "Microsoft.AspNetCore.Authentication.JwtBearer": { }, - "Microsoft.AspNetCore.Authentication.MicrosoftAccount": { }, - "Microsoft.AspNetCore.Authentication.OAuth": { }, - "Microsoft.AspNetCore.Authentication.OpenIdConnect": { }, - "Microsoft.AspNetCore.Authentication.Twitter": { }, - "Microsoft.AspNetCore.Authorization": { }, - "Microsoft.AspNetCore.CookiePolicy": { }, - "Microsoft.Owin.Security.Interop": { } - } - }, "adx-nonshipping": { "rules": [], "packages": { From da4730a3922dd885fdda013f5efa72010a7d0170 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 12 Dec 2016 15:39:18 -0800 Subject: [PATCH 664/900] #1044 Revert "Auth: Always call prior handlers during Challenge" This reverts commit e12838e38f5f8be8371c0a7b02d9ce47e0663ce0. --- .../AuthenticationHandler.cs | 10 +++++----- .../AuthenticationHandlerFacts.cs | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index ae32424ebd..8e7e427659 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -327,7 +327,6 @@ namespace Microsoft.AspNetCore.Authentication /// Override this method to deal with a challenge that is forbidden. /// /// - /// The returned boolean is ignored. protected virtual Task HandleForbiddenAsync(ChallengeContext context) { Response.StatusCode = 403; @@ -340,7 +339,7 @@ namespace Microsoft.AspNetCore.Authentication /// changing the 401 result to 302 of a login page or external sign-in location.) /// /// - /// The returned boolean is no longer used. + /// True if no other handlers should be called protected virtual Task HandleUnauthorizedAsync(ChallengeContext context) { Response.StatusCode = 401; @@ -350,6 +349,7 @@ namespace Microsoft.AspNetCore.Authentication public async Task ChallengeAsync(ChallengeContext context) { ChallengeCalled = true; + var handled = false; if (ShouldHandleScheme(context.AuthenticationScheme, Options.AutomaticChallenge)) { switch (context.Behavior) @@ -363,18 +363,18 @@ namespace Microsoft.AspNetCore.Authentication } goto case ChallengeBehavior.Unauthorized; case ChallengeBehavior.Unauthorized: - await HandleUnauthorizedAsync(context); + handled = await HandleUnauthorizedAsync(context); Logger.AuthenticationSchemeChallenged(Options.AuthenticationScheme); break; case ChallengeBehavior.Forbidden: - await HandleForbiddenAsync(context); + handled = await HandleForbiddenAsync(context); Logger.AuthenticationSchemeForbidden(Options.AuthenticationScheme); break; } context.Accept(); } - if (PriorHandler != null) + if (!handled && PriorHandler != null) { await PriorHandler.ChallengeAsync(context); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs index 2cf11669d3..fade43716e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs @@ -75,16 +75,17 @@ namespace Microsoft.AspNetCore.Authentication Assert.Equal(1, handler.AuthCount); } - // Prior to https://github.com/aspnet/Security/issues/930 we wouldn't call prior if handled - [Fact] - public async Task AuthHandlerChallengeAlwaysCallsPriorHandler() + [Theory] + [InlineData("Alpha", false)] + [InlineData("Bravo", true)] + public async Task AuthHandlerChallengeCallsPriorHandlerIfNotHandled(string challenge, bool passedThrough) { var handler = await TestHandler.Create("Alpha"); var previous = new PreviousHandler(); handler.PriorHandler = previous; - await handler.ChallengeAsync(new ChallengeContext("Alpha")); - Assert.True(previous.ChallengeCalled); + await handler.ChallengeAsync(new ChallengeContext(challenge)); + Assert.Equal(passedThrough, previous.ChallengeCalled); } private class PreviousHandler : IAuthenticationHandler From 7ab28ecdc60a565e467bd911f4cd556d780c92f9 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 5 Dec 2016 09:03:50 -0800 Subject: [PATCH 665/900] Updating to 4.4 CoreFx packages --- global.json | 2 +- samples/CookieSample/project.json | 2 +- samples/CookieSessionSample/project.json | 2 +- samples/JwtBearerSample/project.json | 2 +- samples/OpenIdConnect.AzureAdSample/project.json | 2 +- samples/OpenIdConnectSample/project.json | 2 +- samples/SocialSample/project.json | 2 +- src/Microsoft.AspNetCore.Authentication.Cookies/project.json | 2 +- src/Microsoft.AspNetCore.Authentication.Facebook/project.json | 2 +- src/Microsoft.AspNetCore.Authentication.Google/project.json | 2 +- .../project.json | 2 +- .../project.json | 2 +- src/Microsoft.AspNetCore.Authentication.OAuth/project.json | 4 ++-- .../project.json | 2 +- src/Microsoft.AspNetCore.Authentication.Twitter/project.json | 2 +- src/Microsoft.AspNetCore.Authentication/project.json | 2 +- src/Microsoft.AspNetCore.Authorization/project.json | 4 ++-- .../project.json | 2 +- src/Microsoft.AspNetCore.CookiePolicy/project.json | 2 +- src/Microsoft.Owin.Security.Interop/project.json | 2 +- test/Microsoft.AspNetCore.Authentication.Test/project.json | 2 +- test/Microsoft.AspNetCore.Authorization.Test/project.json | 2 +- .../project.json | 2 +- test/Microsoft.AspNetCore.CookiePolicy.Test/project.json | 2 +- test/Microsoft.Owin.Security.Interop.Test/project.json | 2 +- 25 files changed, 27 insertions(+), 27 deletions(-) diff --git a/global.json b/global.json index f45e8cc925..0ad1995dd2 100644 --- a/global.json +++ b/global.json @@ -3,6 +3,6 @@ "src" ], "sdk": { - "version": "1.0.0-preview2-1-003177" + "version": "1.0.0-preview2-1-003180" } } \ No newline at end of file diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index ae4abcc286..9815401c95 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -15,7 +15,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json index 0892ae8fb9..728956503b 100644 --- a/samples/CookieSessionSample/project.json +++ b/samples/CookieSessionSample/project.json @@ -16,7 +16,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json index a70a9bea97..794cc4a6a3 100644 --- a/samples/JwtBearerSample/project.json +++ b/samples/JwtBearerSample/project.json @@ -16,7 +16,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json index 26da355f36..9d3c75d288 100644 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ b/samples/OpenIdConnect.AzureAdSample/project.json @@ -14,7 +14,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json index c429cfd2bd..446afd02a9 100644 --- a/samples/OpenIdConnectSample/project.json +++ b/samples/OpenIdConnectSample/project.json @@ -16,7 +16,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json index c46f461b78..c1cf78b49e 100644 --- a/samples/SocialSample/project.json +++ b/samples/SocialSample/project.json @@ -22,7 +22,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json index 8cdb4bf1ef..454540392c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json @@ -37,7 +37,7 @@ "type": "build" }, "Microsoft.Extensions.WebEncoders": "1.2.0-*", - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json index 5f60a7f810..4d581dce1e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json @@ -24,7 +24,7 @@ "Microsoft.AspNetCore.Authentication.OAuth": { "target": "project" }, - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json index 1b24f2c996..f8d8e34171 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/project.json @@ -24,7 +24,7 @@ "Microsoft.AspNetCore.Authentication.OAuth": { "target": "project" }, - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json index 65a3888243..271e353392 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json @@ -29,7 +29,7 @@ "type": "build" }, "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.1.0", - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json index 7a2a8436ba..634b455af4 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json @@ -24,7 +24,7 @@ "Microsoft.AspNetCore.Authentication.OAuth": { "target": "project" }, - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json index 565b72537b..525f21fc0c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json @@ -28,14 +28,14 @@ "version": "1.2.0-*", "type": "build" }, - "NETStandard.Library": "1.6.1-*", + "NETStandard.Library": "1.6.2-*", "Newtonsoft.Json": "9.0.1" }, "frameworks": { "net451": {}, "netstandard1.3": { "dependencies": { - "System.Runtime.Serialization.Primitives": "4.3.0-*" + "System.Runtime.Serialization.Primitives": "4.4.0-*" } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json index dc137510a4..1b513d926c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json @@ -29,7 +29,7 @@ "type": "build" }, "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.1.0", - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json index c4fa7ea462..2d31ec0b20 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json @@ -28,7 +28,7 @@ "version": "1.2.0-*", "type": "build" }, - "NETStandard.Library": "1.6.1-*", + "NETStandard.Library": "1.6.2-*", "Newtonsoft.Json": "9.0.1" }, "frameworks": { diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json index 2006c8497a..0dcf5a7896 100644 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ b/src/Microsoft.AspNetCore.Authentication/project.json @@ -35,7 +35,7 @@ "type": "build" }, "Microsoft.Extensions.WebEncoders": "1.2.0-*", - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": { diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json index 3875aae17e..883e92641b 100644 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ b/src/Microsoft.AspNetCore.Authorization/project.json @@ -26,7 +26,7 @@ "version": "1.2.0-*", "type": "build" }, - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": { @@ -38,7 +38,7 @@ }, "netstandard1.3": { "dependencies": { - "System.Security.Claims": "4.3.0-*" + "System.Security.Claims": "4.4.0-*" } } } diff --git a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json index 693fba630a..7ccf0307dc 100644 --- a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json +++ b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json @@ -4,7 +4,7 @@ "dependencies": { "Microsoft.AspNetCore.Http.Abstractions": "1.2.0-*", "Microsoft.Net.Http.Headers": "1.2.0-*", - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json index 5a0eca5f43..95eede5db2 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/project.json @@ -21,7 +21,7 @@ "dependencies": { "Microsoft.AspNetCore.Http": "1.2.0-*", "Microsoft.Extensions.Options": "1.2.0-*", - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {}, diff --git a/src/Microsoft.Owin.Security.Interop/project.json b/src/Microsoft.Owin.Security.Interop/project.json index 82e22660d8..54b4c97ccc 100644 --- a/src/Microsoft.Owin.Security.Interop/project.json +++ b/src/Microsoft.Owin.Security.Interop/project.json @@ -20,7 +20,7 @@ "dependencies": { "Microsoft.AspNetCore.DataProtection.Extensions": "1.2.0-*", "Microsoft.Owin.Security": "3.0.1", - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json index 719a55c19c..7477e93fae 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ b/test/Microsoft.AspNetCore.Authentication.Test/project.json @@ -19,7 +19,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json index 15bb60f492..dfb4e72881 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ b/test/Microsoft.AspNetCore.Authorization.Test/project.json @@ -14,7 +14,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json index 920882e455..d8761ffa3d 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json @@ -15,7 +15,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json index cce61bd691..d849b6bc24 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json @@ -14,7 +14,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json index bd37d47b91..43738eba99 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ b/test/Microsoft.Owin.Security.Interop.Test/project.json @@ -9,7 +9,7 @@ "Microsoft.Owin.Security.Cookies": "3.0.1", "Microsoft.Owin.Security.Interop": "1.2.0-*", "Microsoft.Owin.Testing": "3.0.1", - "NETStandard.Library": "1.6.1-*", + "NETStandard.Library": "1.6.2-*", "xunit": "2.2.0-*" }, "frameworks": { From ba8f85d9726d9810cf9c017a4f51762cd52abd9b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 4 Jan 2017 16:48:28 -0800 Subject: [PATCH 666/900] Upgrade to VS 2017 --- Security.sln | 68 +++++++----------- build.ps1 | 2 +- build.sh | 2 +- {tools => build}/Key.snk | Bin build/common.props | 20 ++++++ global.json | 8 --- makefile.shade | 8 +++ samples/CookieSample/CookieSample.csproj | 44 ++++++++++++ samples/CookieSample/CookieSample.xproj | 18 ----- samples/CookieSample/project.json | 35 --------- .../CookieSessionSample.csproj | 44 ++++++++++++ .../CookieSessionSample.xproj | 18 ----- samples/CookieSessionSample/project.json | 36 ---------- .../JwtBearerSample/JwtBearerSample.csproj | 45 ++++++++++++ samples/JwtBearerSample/JwtBearerSample.xproj | 23 ------ samples/JwtBearerSample/project.json | 39 ---------- .../OpenIdConnect.AzureAdSample.csproj | 50 +++++++++++++ .../OpenIdConnect.AzureAdSample.xproj | 23 ------ .../OpenIdConnect.AzureAdSample/project.json | 40 ----------- .../OpenIdConnectSample.csproj | 51 +++++++++++++ .../OpenIdConnectSample.xproj | 18 ----- samples/OpenIdConnectSample/project.json | 42 ----------- samples/SocialSample/SocialSample.csproj | 53 ++++++++++++++ samples/SocialSample/SocialSample.xproj | 18 ----- samples/SocialSample/project.json | 44 ------------ .../ChunkingCookieManager.cs | 0 shared/build.proj | 24 +++++++ shared/sources.nuspec | 19 +++++ ...t.AspNetCore.Authentication.Cookies.csproj | 42 +++++++++++ ...ft.AspNetCore.Authentication.Cookies.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../__TemporarySources__/TaskCache.cs | 23 ++++++ .../__TemporarySources__/TaskCacheOfT.cs | 16 +++++ .../project.json | 46 ------------ ....AspNetCore.Authentication.Facebook.csproj | 37 ++++++++++ ...t.AspNetCore.Authentication.Facebook.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../project.json | 33 --------- ...ft.AspNetCore.Authentication.Google.csproj | 37 ++++++++++ ...oft.AspNetCore.Authentication.Google.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../project.json | 33 --------- ...AspNetCore.Authentication.JwtBearer.csproj | 39 ++++++++++ ....AspNetCore.Authentication.JwtBearer.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../__TemporarySources__/TaskCache.cs | 23 ++++++ .../__TemporarySources__/TaskCacheOfT.cs | 16 +++++ .../project.json | 38 ---------- ...ore.Authentication.MicrosoftAccount.csproj | 37 ++++++++++ ...Core.Authentication.MicrosoftAccount.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../project.json | 33 --------- ...oft.AspNetCore.Authentication.OAuth.csproj | 43 +++++++++++ ...soft.AspNetCore.Authentication.OAuth.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../__TemporarySources__/TaskCache.cs | 23 ++++++ .../__TemporarySources__/TaskCacheOfT.cs | 16 +++++ .../project.json | 42 ----------- ...etCore.Authentication.OpenIdConnect.csproj | 39 ++++++++++ ...NetCore.Authentication.OpenIdConnect.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../__TemporarySources__/TaskCache.cs | 23 ++++++ .../__TemporarySources__/TaskCacheOfT.cs | 16 +++++ .../project.json | 38 ---------- ...t.AspNetCore.Authentication.Twitter.csproj | 39 ++++++++++ ...ft.AspNetCore.Authentication.Twitter.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../__TemporarySources__/TaskCache.cs | 23 ++++++ .../__TemporarySources__/TaskCacheOfT.cs | 16 +++++ .../project.json | 38 ---------- ...Microsoft.AspNetCore.Authentication.csproj | 40 +++++++++++ .../Microsoft.AspNetCore.Authentication.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../__TemporarySources__/SecurityHelper.cs | 40 +++++++++++ .../__TemporarySources__/TaskCache.cs | 23 ++++++ .../__TemporarySources__/TaskCacheOfT.cs | 16 +++++ .../project.json | 48 ------------- .../Microsoft.AspNetCore.Authorization.csproj | 41 +++++++++++ .../Microsoft.AspNetCore.Authorization.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../__TemporarySources__/TaskCache.cs | 23 ++++++ .../__TemporarySources__/TaskCacheOfT.cs | 16 +++++ .../project.json | 45 ------------ ...etCore.ChunkingCookieManager.Sources.xproj | 18 ----- .../project.json | 13 ---- .../Microsoft.AspNetCore.CookiePolicy.csproj | 29 ++++++++ .../Microsoft.AspNetCore.CookiePolicy.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 11 --- .../project.json | 30 -------- .../Microsoft.Owin.Security.Interop.csproj | 29 ++++++++ .../Microsoft.Owin.Security.Interop.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 9 +-- .../project.json | 28 -------- ...soft.AspNetCore.Authentication.Test.csproj | 50 +++++++++++++ ...osoft.AspNetCore.Authentication.Test.xproj | 20 ------ .../project.json | 30 -------- ...osoft.AspNetCore.Authorization.Test.csproj | 39 ++++++++++ ...rosoft.AspNetCore.Authorization.Test.xproj | 20 ------ .../project.json | 25 ------- ....ChunkingCookieManager.Sources.Test.csproj | 31 ++++++++ ...e.ChunkingCookieManager.Sources.Test.xproj | 21 ------ .../project.json | 26 ------- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 42 +++++++++++ ...crosoft.AspNetCore.CookiePolicy.Test.xproj | 20 ------ .../project.json | 25 ------- ...icrosoft.Owin.Security.Interop.Test.csproj | 40 +++++++++++ ...Microsoft.Owin.Security.Interop.Test.xproj | 20 ------ .../project.json | 19 ----- version.props | 7 ++ 109 files changed, 1360 insertions(+), 1449 deletions(-) rename {tools => build}/Key.snk (100%) create mode 100644 build/common.props delete mode 100644 global.json create mode 100644 makefile.shade create mode 100644 samples/CookieSample/CookieSample.csproj delete mode 100644 samples/CookieSample/CookieSample.xproj delete mode 100644 samples/CookieSample/project.json create mode 100644 samples/CookieSessionSample/CookieSessionSample.csproj delete mode 100644 samples/CookieSessionSample/CookieSessionSample.xproj delete mode 100644 samples/CookieSessionSample/project.json create mode 100644 samples/JwtBearerSample/JwtBearerSample.csproj delete mode 100644 samples/JwtBearerSample/JwtBearerSample.xproj delete mode 100644 samples/JwtBearerSample/project.json create mode 100644 samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj delete mode 100644 samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj delete mode 100644 samples/OpenIdConnect.AzureAdSample/project.json create mode 100644 samples/OpenIdConnectSample/OpenIdConnectSample.csproj delete mode 100644 samples/OpenIdConnectSample/OpenIdConnectSample.xproj delete mode 100644 samples/OpenIdConnectSample/project.json create mode 100644 samples/SocialSample/SocialSample.csproj delete mode 100644 samples/SocialSample/SocialSample.xproj delete mode 100644 samples/SocialSample/project.json rename {src => shared}/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs (100%) create mode 100644 shared/build.proj create mode 100644 shared/sources.nuspec create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCache.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/project.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/project.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.Google/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Google/project.json create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCache.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json create mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCache.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/project.json create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCache.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCache.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/project.json create mode 100644 src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj delete mode 100644 src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj delete mode 100644 src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/__TemporarySources__/SecurityHelper.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCache.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/project.json create mode 100644 src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj delete mode 100644 src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj delete mode 100644 src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCache.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authorization/project.json delete mode 100644 src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/Microsoft.AspNetCore.ChunkingCookieManager.Sources.xproj delete mode 100644 src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json create mode 100644 src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj delete mode 100644 src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj delete mode 100644 src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNetCore.CookiePolicy/project.json create mode 100644 src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj delete mode 100644 src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj delete mode 100644 src/Microsoft.Owin.Security.Interop/project.json create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj delete mode 100644 test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj delete mode 100644 test/Microsoft.AspNetCore.Authentication.Test/project.json create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj delete mode 100644 test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj delete mode 100644 test/Microsoft.AspNetCore.Authorization.Test/project.json create mode 100644 test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj delete mode 100644 test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.xproj delete mode 100644 test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json create mode 100644 test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj delete mode 100644 test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj delete mode 100644 test/Microsoft.AspNetCore.CookiePolicy.Test/project.json create mode 100644 test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj delete mode 100644 test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj delete mode 100644 test/Microsoft.Owin.Security.Interop.Test/project.json create mode 100644 version.props diff --git a/Security.sln b/Security.sln index c84ec1bd96..50805feb16 100644 --- a/Security.sln +++ b/Security.sln @@ -1,65 +1,58 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26020.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F8C0AA27-F3FB-4286-8E4C-47EF86B539FF}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CookieSample", "samples\CookieSample\CookieSample.xproj", "{558C2C2A-AED8-49DE-BB60-D5F8AE06C714}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookieSample", "samples\CookieSample\CookieSample.csproj", "{558C2C2A-AED8-49DE-BB60-D5F8AE06C714}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{7BF11F3A-60B6-4796-B504-579C67FFBA34}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C40A5A3B-ABA3-4819-9C44-D821E6DA1BA1}" - ProjectSection(SolutionItems) = preProject - global.json = global.json - EndProjectSection +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SocialSample", "samples\SocialSample\SocialSample.csproj", "{8C73D216-332D-41D8-BFD0-45BC4BC36552}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SocialSample", "samples\SocialSample\SocialSample.xproj", "{8C73D216-332D-41D8-BFD0-45BC4BC36552}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookieSessionSample", "samples\CookieSessionSample\CookieSessionSample.csproj", "{19711880-46DA-4A26-9E0F-9B2E41D27651}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CookieSessionSample", "samples\CookieSessionSample\CookieSessionSample.xproj", "{19711880-46DA-4A26-9E0F-9B2E41D27651}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenIdConnectSample", "samples\OpenIdConnectSample\OpenIdConnectSample.csproj", "{BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "OpenIdConnectSample", "samples\OpenIdConnectSample\OpenIdConnectSample.xproj", "{BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Cookies", "src\Microsoft.AspNetCore.Authentication.Cookies\Microsoft.AspNetCore.Authentication.Cookies.csproj", "{FC152CC4-054B-457E-8D91-389C5DE3C561}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Cookies", "src\Microsoft.AspNetCore.Authentication.Cookies\Microsoft.AspNetCore.Authentication.Cookies.xproj", "{FC152CC4-054B-457E-8D91-389C5DE3C561}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication", "src\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.csproj", "{2286250A-52C8-4126-9F93-B1E45F0AD078}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication", "src\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.xproj", "{2286250A-52C8-4126-9F93-B1E45F0AD078}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Facebook", "src\Microsoft.AspNetCore.Authentication.Facebook\Microsoft.AspNetCore.Authentication.Facebook.csproj", "{EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Facebook", "src\Microsoft.AspNetCore.Authentication.Facebook\Microsoft.AspNetCore.Authentication.Facebook.xproj", "{EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Google", "src\Microsoft.AspNetCore.Authentication.Google\Microsoft.AspNetCore.Authentication.Google.csproj", "{76579C39-B829-490D-B8BE-1BD35FE8412E}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Google", "src\Microsoft.AspNetCore.Authentication.Google\Microsoft.AspNetCore.Authentication.Google.xproj", "{76579C39-B829-490D-B8BE-1BD35FE8412E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.OpenIdConnect", "src\Microsoft.AspNetCore.Authentication.OpenIdConnect\Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj", "{35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.OpenIdConnect", "src\Microsoft.AspNetCore.Authentication.OpenIdConnect\Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj", "{35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.MicrosoftAccount", "src\Microsoft.AspNetCore.Authentication.MicrosoftAccount\Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj", "{ACB45E19-F520-4D0C-8916-B0CEB9C017FE}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.MicrosoftAccount", "src\Microsoft.AspNetCore.Authentication.MicrosoftAccount\Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj", "{ACB45E19-F520-4D0C-8916-B0CEB9C017FE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Twitter", "src\Microsoft.AspNetCore.Authentication.Twitter\Microsoft.AspNetCore.Authentication.Twitter.csproj", "{0330FFF6-B4B5-42DD-8C99-26A789569000}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Twitter", "src\Microsoft.AspNetCore.Authentication.Twitter\Microsoft.AspNetCore.Authentication.Twitter.xproj", "{0330FFF6-B4B5-42DD-8C99-26A789569000}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.OAuth", "src\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj", "{1657C79E-7755-4AEE-9D61-571295B69A30}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.OAuth", "src\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.xproj", "{1657C79E-7755-4AEE-9D61-571295B69A30}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Test", "test\Microsoft.AspNetCore.Authentication.Test\Microsoft.AspNetCore.Authentication.Test.csproj", "{8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Test", "test\Microsoft.AspNetCore.Authentication.Test\Microsoft.AspNetCore.Authentication.Test.xproj", "{8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authorization.Test", "test\Microsoft.AspNetCore.Authorization.Test\Microsoft.AspNetCore.Authorization.Test.csproj", "{7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authorization.Test", "test\Microsoft.AspNetCore.Authorization.Test\Microsoft.AspNetCore.Authorization.Test.xproj", "{7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authorization", "src\Microsoft.AspNetCore.Authorization\Microsoft.AspNetCore.Authorization.csproj", "{6AB3E514-5894-4131-9399-DC7D5284ADDB}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authorization", "src\Microsoft.AspNetCore.Authorization\Microsoft.AspNetCore.Authorization.xproj", "{6AB3E514-5894-4131-9399-DC7D5284ADDB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.CookiePolicy", "src\Microsoft.AspNetCore.CookiePolicy\Microsoft.AspNetCore.CookiePolicy.csproj", "{86183DC3-02A8-4A68-8B60-71ECEC066E79}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.CookiePolicy", "src\Microsoft.AspNetCore.CookiePolicy\Microsoft.AspNetCore.CookiePolicy.xproj", "{86183DC3-02A8-4A68-8B60-71ECEC066E79}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.CookiePolicy.Test", "test\Microsoft.AspNetCore.CookiePolicy.Test\Microsoft.AspNetCore.CookiePolicy.Test.csproj", "{1790E052-646F-4529-B90E-6FEA95520D69}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.CookiePolicy.Test", "test\Microsoft.AspNetCore.CookiePolicy.Test\Microsoft.AspNetCore.CookiePolicy.Test.xproj", "{1790E052-646F-4529-B90E-6FEA95520D69}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.JwtBearer", "src\Microsoft.AspNetCore.Authentication.JwtBearer\Microsoft.AspNetCore.Authentication.JwtBearer.csproj", "{2755BFE5-7421-4A31-A644-F817DF5CAA98}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.JwtBearer", "src\Microsoft.AspNetCore.Authentication.JwtBearer\Microsoft.AspNetCore.Authentication.JwtBearer.xproj", "{2755BFE5-7421-4A31-A644-F817DF5CAA98}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtBearerSample", "samples\JwtBearerSample\JwtBearerSample.csproj", "{D399B84F-591B-4E98-92BA-B0F63E7B6957}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JwtBearerSample", "samples\JwtBearerSample\JwtBearerSample.xproj", "{D399B84F-591B-4E98-92BA-B0F63E7B6957}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Owin.Security.Interop", "src\Microsoft.Owin.Security.Interop\Microsoft.Owin.Security.Interop.csproj", "{A7922DD8-09F1-43E4-938B-CC523EA08898}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Owin.Security.Interop", "src\Microsoft.Owin.Security.Interop\Microsoft.Owin.Security.Interop.xproj", "{A7922DD8-09F1-43E4-938B-CC523EA08898}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Owin.Security.Interop.Test", "test\Microsoft.Owin.Security.Interop.Test\Microsoft.Owin.Security.Interop.Test.csproj", "{A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Owin.Security.Interop.Test", "test\Microsoft.Owin.Security.Interop.Test\Microsoft.Owin.Security.Interop.Test.xproj", "{A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenIdConnect.AzureAdSample", "samples\OpenIdConnect.AzureAdSample\OpenIdConnect.AzureAdSample.csproj", "{3A7AD414-EBDE-4F92-B307-4E8F19B6117E}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "OpenIdConnect.AzureAdSample", "samples\OpenIdConnect.AzureAdSample\OpenIdConnect.AzureAdSample.xproj", "{3A7AD414-EBDE-4F92-B307-4E8F19B6117E}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.ChunkingCookieManager.Sources", "src\Microsoft.AspNetCore.ChunkingCookieManager.Sources\Microsoft.AspNetCore.ChunkingCookieManager.Sources.xproj", "{2690FBE6-9D27-4C84-B82C-11188B0BCDA3}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test", "test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.xproj", "{51563775-C659-4907-9BAF-9995BAB87D01}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test", "test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj", "{51563775-C659-4907-9BAF-9995BAB87D01}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -329,16 +322,6 @@ Global {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|Mixed Platforms.Build.0 = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|x86.ActiveCfg = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|x86.Build.0 = Release|Any CPU - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Debug|x86.ActiveCfg = Debug|Any CPU - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Debug|x86.Build.0 = Debug|Any CPU - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Release|Any CPU.Build.0 = Release|Any CPU - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Release|x86.ActiveCfg = Release|Any CPU - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3}.Release|x86.Build.0 = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Any CPU.Build.0 = Debug|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -378,7 +361,6 @@ Global {A7922DD8-09F1-43E4-938B-CC523EA08898} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} - {2690FBE6-9D27-4C84-B82C-11188B0BCDA3} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} EndGlobalSection EndGlobal diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..0605b59c01 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index 4fd7ede788..07997d6c83 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi diff --git a/tools/Key.snk b/build/Key.snk similarity index 100% rename from tools/Key.snk rename to build/Key.snk diff --git a/build/common.props b/build/common.props new file mode 100644 index 0000000000..700582a850 --- /dev/null +++ b/build/common.props @@ -0,0 +1,20 @@ + + + + + + https://github.com/aspnet/Security + git + $(MSBuildThisFileDirectory)Key.snk + true + true + Microsoft ASP.NET Core + + + + + + \ No newline at end of file diff --git a/global.json b/global.json deleted file mode 100644 index 0ad1995dd2..0000000000 --- a/global.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "projects": [ - "src" - ], - "sdk": { - "version": "1.0.0-preview2-1-003180" - } -} \ No newline at end of file diff --git a/makefile.shade b/makefile.shade new file mode 100644 index 0000000000..f5ea5ac9eb --- /dev/null +++ b/makefile.shade @@ -0,0 +1,8 @@ + +var VERSION='0.1' +var FULL_VERSION='0.1' +use-standard-lifecycle +k-standard-goals + +#pack-sources target='build-pack' + dotnet command='msbuild shared/build.proj /t:Pack /v:n' diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj new file mode 100644 index 0000000000..623896b736 --- /dev/null +++ b/samples/CookieSample/CookieSample.csproj @@ -0,0 +1,44 @@ + + + + net451;netcoreapp1.1 + Exe + + win7-x64 + + + + + PreserveNewest + + + + + + + true + + + + + + true + + + + + + + + + + + + + + + + + + + diff --git a/samples/CookieSample/CookieSample.xproj b/samples/CookieSample/CookieSample.xproj deleted file mode 100644 index f6575c3e0a..0000000000 --- a/samples/CookieSample/CookieSample.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 558c2c2a-aed8-49de-bb60-d5f8ae06c714 - .\obj - .\bin\ - - - 2.0 - 22569 - - - \ No newline at end of file diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json deleted file mode 100644 index 9815401c95..0000000000 --- a/samples/CookieSample/project.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", - "Microsoft.AspNetCore.DataProtection": "1.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*" - }, - "buildOptions": { - "emitEntryPoint": true - }, - "frameworks": { - "net451": {}, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - } - }, - "publishOptions": { - "include": [ - "web.config" - ] - }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" - }, - "scripts": { - "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - } -} \ No newline at end of file diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj new file mode 100644 index 0000000000..fb189cef4f --- /dev/null +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -0,0 +1,44 @@ + + + + net451;netcoreapp1.1 + Exe + + win7-x64 + + + + + PreserveNewest + + + + + + + true + + + + + + true + + + + + + + + + + + + + + + + + + + diff --git a/samples/CookieSessionSample/CookieSessionSample.xproj b/samples/CookieSessionSample/CookieSessionSample.xproj deleted file mode 100644 index 1c347c845f..0000000000 --- a/samples/CookieSessionSample/CookieSessionSample.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 19711880-46da-4a26-9e0f-9b2e41d27651 - .\obj - .\bin\ - - - 2.0 - 36505 - - - \ No newline at end of file diff --git a/samples/CookieSessionSample/project.json b/samples/CookieSessionSample/project.json deleted file mode 100644 index 728956503b..0000000000 --- a/samples/CookieSessionSample/project.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", - "Microsoft.AspNetCore.DataProtection": "1.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.Extensions.Caching.Memory": "1.2.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*" - }, - "buildOptions": { - "emitEntryPoint": true - }, - "frameworks": { - "net451": {}, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - } - }, - "publishOptions": { - "include": [ - "web.config" - ] - }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" - }, - "scripts": { - "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - } -} \ No newline at end of file diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj new file mode 100644 index 0000000000..2d94cdbdf8 --- /dev/null +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -0,0 +1,45 @@ + + + + 1.1.0 + net451;netcoreapp1.1 + + win7-x64 + Exe + aspnet5-JwtBearerSample-20151210102827 + + + + + PreserveNewest + + + + + + + true + + + + + + true + + + + + + + + + + + + + + + + + + diff --git a/samples/JwtBearerSample/JwtBearerSample.xproj b/samples/JwtBearerSample/JwtBearerSample.xproj deleted file mode 100644 index 97f5837ce5..0000000000 --- a/samples/JwtBearerSample/JwtBearerSample.xproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - d399b84f-591b-4e98-92ba-b0f63e7b6957 - .\obj - .\bin\ - - - 2.0 - - - - - - - - - \ No newline at end of file diff --git a/samples/JwtBearerSample/project.json b/samples/JwtBearerSample/project.json deleted file mode 100644 index 794cc4a6a3..0000000000 --- a/samples/JwtBearerSample/project.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "version": "1.1.0-*", - "buildOptions": { - "emitEntryPoint": true - }, - "dependencies": { - "Microsoft.AspNetCore.Authentication.JwtBearer": "1.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.AspNetCore.StaticFiles": "1.2.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.2.0-*" - }, - "frameworks": { - "net451": {}, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - } - }, - "publishOptions": { - "include": [ - "project.json", - "wwwroot", - "web.config" - ] - }, - "userSecretsId": "aspnet5-JwtBearerSample-20151210102827", - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" - }, - "scripts": { - "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - } -} \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj new file mode 100644 index 0000000000..7331e7f051 --- /dev/null +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -0,0 +1,50 @@ + + + + net451;netcoreapp1.1 + Exe + + win7-x64 + aspnet5-OpenIdConnectSample-20151210110318 + + + + + PreserveNewest + + + + + + + + true + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj deleted file mode 100644 index 26e9f9030b..0000000000 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.xproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 3a7ad414-ebde-4f92-b307-4e8f19b6117e - .\obj - .\bin\ - - - 2.0 - - - - - - - - - \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/project.json b/samples/OpenIdConnect.AzureAdSample/project.json deleted file mode 100644 index 9d3c75d288..0000000000 --- a/samples/OpenIdConnect.AzureAdSample/project.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*", - "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.13.4" - }, - "frameworks": { - "net451": {}, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - } - }, - "buildOptions": { - "emitEntryPoint": true - }, - "publishOptions": { - "include": [ - "project.json", - "web.config" - ] - }, - "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318", - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*", - "Microsoft.Extensions.SecretManager.Tools": "1.0.0-*" - }, - "scripts": { - "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - } -} \ No newline at end of file diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj new file mode 100644 index 0000000000..dfb0231079 --- /dev/null +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -0,0 +1,51 @@ + + + + net451;netcoreapp1.1 + Exe + + win7-x64 + aspnet5-OpenIdConnectSample-20151210110318 + + + + + + + + + + + + true + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.xproj b/samples/OpenIdConnectSample/OpenIdConnectSample.xproj deleted file mode 100644 index 9029ad0f13..0000000000 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - bef0f5c3-ef4e-4649-9c49-d5e279a3ca2b - .\obj - .\bin\ - - - 2.0 - 42023 - - - \ No newline at end of file diff --git a/samples/OpenIdConnectSample/project.json b/samples/OpenIdConnectSample/project.json deleted file mode 100644 index 446afd02a9..0000000000 --- a/samples/OpenIdConnectSample/project.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel.Https": "1.2.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.2.0-*", - "Microsoft.Extensions.FileProviders.Embedded": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*", - "Microsoft.Extensions.Logging.Debug": "1.2.0-*" - }, - "frameworks": { - "net451": {}, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - } - }, - "buildOptions": { - "emitEntryPoint": true - }, - "publishOptions": { - "include": [ - "project.json", - "web.config" - ] - }, - "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318", - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*", - "Microsoft.Extensions.SecretManager.Tools": "1.0.0-*" - }, - "scripts": { - "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - } -} \ No newline at end of file diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj new file mode 100644 index 0000000000..71900b9b5d --- /dev/null +++ b/samples/SocialSample/SocialSample.csproj @@ -0,0 +1,53 @@ + + + + net451;netcoreapp1.1 + Exe + + win7-x64 + aspnet5-SocialSample-20151210111056 + + + + + + + + + + + + + + + true + + + true + + + + + + true + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/SocialSample/SocialSample.xproj b/samples/SocialSample/SocialSample.xproj deleted file mode 100644 index b439f74d10..0000000000 --- a/samples/SocialSample/SocialSample.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 8c73d216-332d-41d8-bfd0-45bc4bc36552 - .\obj - .\bin\ - - - 2.0 - 54540 - - - \ No newline at end of file diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json deleted file mode 100644 index c1cf78b49e..0000000000 --- a/samples/SocialSample/project.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.Facebook": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.Google": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.Twitter": "1.2.0-*", - "Microsoft.AspNetCore.DataProtection": "1.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel.Https": "1.2.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", - "Microsoft.Extensions.Configuration.UserSecrets": "1.2.0-*", - "Microsoft.Extensions.FileProviders.Embedded": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*" - }, - "buildOptions": { - "emitEntryPoint": true - }, - "frameworks": { - "net451": {}, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - } - }, - "userSecretsId": "aspnet5-SocialSample-20151210111056", - "publishOptions": { - "include": [ - "project.json", - "web.config" - ] - }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" - }, - "scripts": { - "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs similarity index 100% rename from src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs rename to shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs diff --git a/shared/build.proj b/shared/build.proj new file mode 100644 index 0000000000..d3fc56ba8a --- /dev/null +++ b/shared/build.proj @@ -0,0 +1,24 @@ + + + + + $(MSBuildThisFileDirectory)..\artifacts\build + $(VersionPrefix) + $(Version)-$(VersionSuffix) + + + + + + + + + + + \ No newline at end of file diff --git a/shared/sources.nuspec b/shared/sources.nuspec new file mode 100644 index 0000000000..0eb708b9b8 --- /dev/null +++ b/shared/sources.nuspec @@ -0,0 +1,19 @@ + + + + $id$ + $version$ + Microsoft + Microsoft + false + $id$ + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj new file mode 100644 index 0000000000..955afcb397 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -0,0 +1,42 @@ + + + + + + ASP.NET Core middleware that enables an application to use cookie based authentication. + net451;netstandard1.3 + $(DefineConstants);SECURITY + $(NoWarn);CS1591 + true + aspnetcore;authentication;security + + + + + + + + + + + + + + + true + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj deleted file mode 100644 index 238c0cec67..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - fc152cc4-054b-457e-8d91-389c5de3c561 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCache.cs new file mode 100644 index 0000000000..67a87fca59 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCache.cs @@ -0,0 +1,23 @@ +// 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.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// A that's already completed successfully. + /// + /// + /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done + /// by Task.CompletedTask. + /// +#if NET451 + public static readonly Task CompletedTask = Task.FromResult(0); +#else + public static readonly Task CompletedTask = Task.CompletedTask; +#endif + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCacheOfT.cs new file mode 100644 index 0000000000..5015e3aba7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCacheOfT.cs @@ -0,0 +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. + +using System.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// Gets a completed with the value of default(T). + /// + public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); + } + +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json b/src/Microsoft.AspNetCore.Authentication.Cookies/project.json deleted file mode 100644 index 454540392c..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/project.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core middleware that enables an application to use cookie based authentication.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore", - "authentication", - "security" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true, - "define": [ - "SECURITY" - ] - }, - "dependencies": { - "Microsoft.AspNetCore.Authentication": { - "target": "project" - }, - "Microsoft.AspNetCore.ChunkingCookieManager.Sources": { - "type": "build", - "target": "project" - }, - "Microsoft.Extensions.Options": "1.2.0-*", - "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.2.0-*", - "type": "build" - }, - "Microsoft.Extensions.WebEncoders": "1.2.0-*", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj new file mode 100644 index 0000000000..a99538405c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -0,0 +1,37 @@ + + + + + + ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow. + net451;netstandard1.3 + $(NoWarn);CS1591 + true + aspnetcore;authentication;security + + + + + + + + + + + true + + + + + + true + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj deleted file mode 100644 index caa72075ed..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - eeaaee68-607b-4e33-af3e-45c66b4dba5a - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json b/src/Microsoft.AspNetCore.Authentication.Facebook/project.json deleted file mode 100644 index 4d581dce1e..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore", - "authentication", - "security" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": { - "target": "project" - }, - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj new file mode 100644 index 0000000000..cce86fac68 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -0,0 +1,37 @@ + + + + + + ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows. + net451;netstandard1.3 + $(NoWarn);CS1591 + true + aspnetcore;authentication;security + + + + + + + + + + + true + + + + + + true + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj deleted file mode 100644 index ab60488729..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 76579c39-b829-490d-b8be-1bd35fe8412e - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Google/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Google/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.Google/project.json b/src/Microsoft.AspNetCore.Authentication.Google/project.json deleted file mode 100644 index f8d8e34171..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Google/project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore", - "authentication", - "security" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": { - "target": "project" - }, - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj new file mode 100644 index 0000000000..41d886031e --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -0,0 +1,39 @@ + + + + + + ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. + net451;netstandard1.4 + $(NoWarn);CS1591 + true + aspnetcore;authentication;security + + + + + + + + + + + + + + true + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj deleted file mode 100644 index 738458398d..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 2755BFE5-7421-4A31-A644-F817DF5CAA98 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCache.cs new file mode 100644 index 0000000000..67a87fca59 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCache.cs @@ -0,0 +1,23 @@ +// 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.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// A that's already completed successfully. + /// + /// + /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done + /// by Task.CompletedTask. + /// +#if NET451 + public static readonly Task CompletedTask = Task.FromResult(0); +#else + public static readonly Task CompletedTask = Task.CompletedTask; +#endif + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCacheOfT.cs new file mode 100644 index 0000000000..5015e3aba7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCacheOfT.cs @@ -0,0 +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. + +using System.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// Gets a completed with the value of default(T). + /// + public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); + } + +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json deleted file mode 100644 index 271e353392..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/project.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore", - "authentication", - "security" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.Authentication": { - "target": "project" - }, - "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.2.0-*", - "type": "build" - }, - "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.1.0", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.4": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj new file mode 100644 index 0000000000..341096369b --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -0,0 +1,37 @@ + + + + + + ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow. + net451;netstandard1.3 + $(NoWarn);CS1591 + true + aspnetcore;authentication;security + + + + + + + + + + + true + + + + + + true + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj deleted file mode 100644 index a4ccc98630..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - acb45e19-f520-4d0c-8916-b0ceb9c017fe - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json deleted file mode 100644 index 634b455af4..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore", - "authentication", - "security" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.Authentication.OAuth": { - "target": "project" - }, - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj new file mode 100644 index 0000000000..1199750e87 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -0,0 +1,43 @@ + + + + + + ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow. + net451;netstandard1.3 + $(NoWarn);CS1591 + true + aspnetcore;authentication;security + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj deleted file mode 100644 index 20b825dca0..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 1657c79e-7755-4aee-9d61-571295b69a30 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCache.cs new file mode 100644 index 0000000000..67a87fca59 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCache.cs @@ -0,0 +1,23 @@ +// 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.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// A that's already completed successfully. + /// + /// + /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done + /// by Task.CompletedTask. + /// +#if NET451 + public static readonly Task CompletedTask = Task.FromResult(0); +#else + public static readonly Task CompletedTask = Task.CompletedTask; +#endif + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCacheOfT.cs new file mode 100644 index 0000000000..5015e3aba7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCacheOfT.cs @@ -0,0 +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. + +using System.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// Gets a completed with the value of default(T). + /// + public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); + } + +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json b/src/Microsoft.AspNetCore.Authentication.OAuth/project.json deleted file mode 100644 index 525f21fc0c..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/project.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore", - "authentication", - "security" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.Authentication": { - "target": "project" - }, - "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.2.0-*", - "type": "build" - }, - "NETStandard.Library": "1.6.2-*", - "Newtonsoft.Json": "9.0.1" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": { - "dependencies": { - "System.Runtime.Serialization.Primitives": "4.4.0-*" - } - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj new file mode 100644 index 0000000000..407dc44ae4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -0,0 +1,39 @@ + + + + + + ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. + net451;netstandard1.4 + $(NoWarn);CS1591 + true + aspnetcore;authentication;security + + + + + + + + + + + + + + true + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj deleted file mode 100644 index 6a07e81203..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 35115d55-b69e-46d4-bb33-c9e9e6ec5e7a - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCache.cs new file mode 100644 index 0000000000..67a87fca59 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCache.cs @@ -0,0 +1,23 @@ +// 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.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// A that's already completed successfully. + /// + /// + /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done + /// by Task.CompletedTask. + /// +#if NET451 + public static readonly Task CompletedTask = Task.FromResult(0); +#else + public static readonly Task CompletedTask = Task.CompletedTask; +#endif + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCacheOfT.cs new file mode 100644 index 0000000000..5015e3aba7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCacheOfT.cs @@ -0,0 +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. + +using System.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// Gets a completed with the value of default(T). + /// + public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); + } + +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json deleted file mode 100644 index 1b513d926c..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/project.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore", - "authentication", - "security" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.Authentication": { - "target": "project" - }, - "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.2.0-*", - "type": "build" - }, - "Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.1.0", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.4": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj new file mode 100644 index 0000000000..a81a883803 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -0,0 +1,39 @@ + + + + + + ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow. + net451;netstandard1.3 + $(NoWarn);CS1591 + true + aspnetcore;authentication;security + + + + + + + + + + + + + + true + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj deleted file mode 100644 index b72a631fa9..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 0330fff6-b4b5-42dd-8c99-26a789569000 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCache.cs new file mode 100644 index 0000000000..67a87fca59 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCache.cs @@ -0,0 +1,23 @@ +// 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.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// A that's already completed successfully. + /// + /// + /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done + /// by Task.CompletedTask. + /// +#if NET451 + public static readonly Task CompletedTask = Task.FromResult(0); +#else + public static readonly Task CompletedTask = Task.CompletedTask; +#endif + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCacheOfT.cs new file mode 100644 index 0000000000..5015e3aba7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCacheOfT.cs @@ -0,0 +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. + +using System.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// Gets a completed with the value of default(T). + /// + public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); + } + +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json b/src/Microsoft.AspNetCore.Authentication.Twitter/project.json deleted file mode 100644 index 2d31ec0b20..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/project.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore", - "authentication", - "security" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.Authentication": { - "target": "project" - }, - "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.2.0-*", - "type": "build" - }, - "NETStandard.Library": "1.6.2-*", - "Newtonsoft.Json": "9.0.1" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj new file mode 100644 index 0000000000..ed11f94ad6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -0,0 +1,40 @@ + + + + + + ASP.NET Core common types used by the various authentication middleware components. + 1.2.0 + net451;netstandard1.3 + $(NoWarn);CS1591 + true + aspnetcore;authentication;security + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj deleted file mode 100644 index b3345c6cfc..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 2286250a-52c8-4126-9f93-b1e45f0ad078 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/SecurityHelper.cs b/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/SecurityHelper.cs new file mode 100644 index 0000000000..408ef6b224 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/SecurityHelper.cs @@ -0,0 +1,40 @@ +// 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.Linq; +using System.Security.Claims; + +namespace Microsoft.Extensions.Internal +{ + /// + /// Helper code used when implementing authentication middleware + /// + internal static class SecurityHelper + { + /// + /// Add all ClaimsIdentities from an additional ClaimPrincipal to the ClaimsPrincipal + /// Merges a new claims principal, placing all new identities first, and eliminating + /// any empty unauthenticated identities from context.User + /// + /// The containing existing . + /// The containing to be added. + public static ClaimsPrincipal MergeUserPrincipal(ClaimsPrincipal existingPrincipal, ClaimsPrincipal additionalPrincipal) + { + var newPrincipal = new ClaimsPrincipal(); + + // New principal identities go first + if (additionalPrincipal != null) + { + newPrincipal.AddIdentities(additionalPrincipal.Identities); + } + + // Then add any existing non empty or authenticated identities + if (existingPrincipal != null) + { + newPrincipal.AddIdentities(existingPrincipal.Identities.Where(i => i.IsAuthenticated || i.Claims.Any())); + } + return newPrincipal; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCache.cs new file mode 100644 index 0000000000..67a87fca59 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCache.cs @@ -0,0 +1,23 @@ +// 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.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// A that's already completed successfully. + /// + /// + /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done + /// by Task.CompletedTask. + /// +#if NET451 + public static readonly Task CompletedTask = Task.FromResult(0); +#else + public static readonly Task CompletedTask = Task.CompletedTask; +#endif + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCacheOfT.cs new file mode 100644 index 0000000000..5015e3aba7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCacheOfT.cs @@ -0,0 +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. + +using System.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// Gets a completed with the value of default(T). + /// + public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); + } + +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/project.json b/src/Microsoft.AspNetCore.Authentication/project.json deleted file mode 100644 index 0dcf5a7896..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/project.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core common types used by the various authentication middleware components.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore", - "authentication", - "security" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.DataProtection": "1.2.0-*", - "Microsoft.AspNetCore.Http": "1.2.0-*", - "Microsoft.AspNetCore.Http.Extensions": "1.2.0-*", - "Microsoft.Extensions.Logging.Abstractions": "1.2.0-*", - "Microsoft.Extensions.Options": "1.2.0-*", - "Microsoft.Extensions.SecurityHelper.Sources": { - "type": "build", - "version": "1.2.0-*" - }, - "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.2.0-*", - "type": "build" - }, - "Microsoft.Extensions.WebEncoders": "1.2.0-*", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": { - "frameworkAssemblies": { - "System.Net.Http": "" - } - }, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj new file mode 100644 index 0000000000..75a9511f39 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -0,0 +1,41 @@ + + + + + + ASP.NET Core authorization classes. +Commonly used types: +Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute +Microsoft.AspNetCore.Authorization.AuthorizeAttribute + net451;netstandard1.3 + $(NoWarn);CS1591 + true + aspnetcore;authorization + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj deleted file mode 100644 index cc6041f8f4..0000000000 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 6ab3e514-5894-4131-9399-dc7d5284addb - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.Authorization/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCache.cs new file mode 100644 index 0000000000..67a87fca59 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCache.cs @@ -0,0 +1,23 @@ +// 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.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// A that's already completed successfully. + /// + /// + /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done + /// by Task.CompletedTask. + /// +#if NET451 + public static readonly Task CompletedTask = Task.FromResult(0); +#else + public static readonly Task CompletedTask = Task.CompletedTask; +#endif + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCacheOfT.cs new file mode 100644 index 0000000000..5015e3aba7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCacheOfT.cs @@ -0,0 +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. + +using System.Threading.Tasks; + +namespace Microsoft.Extensions.Internal +{ + internal static class TaskCache + { + /// + /// Gets a completed with the value of default(T). + /// + public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); + } + +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/project.json b/src/Microsoft.AspNetCore.Authorization/project.json deleted file mode 100644 index 883e92641b..0000000000 --- a/src/Microsoft.AspNetCore.Authorization/project.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core authorization classes.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Authorization.AllowAnonymousAttribute\r\nMicrosoft.AspNetCore.Authorization.AuthorizeAttribute", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore", - "authorization" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "1.2.0-*", - "Microsoft.Extensions.Options": "1.2.0-*", - "Microsoft.Extensions.TaskCache.Sources": { - "version": "1.2.0-*", - "type": "build" - }, - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": { - "frameworkAssemblies": { - "System.Runtime": { - "type": "build" - } - } - }, - "netstandard1.3": { - "dependencies": { - "System.Security.Claims": "4.4.0-*" - } - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/Microsoft.AspNetCore.ChunkingCookieManager.Sources.xproj b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/Microsoft.AspNetCore.ChunkingCookieManager.Sources.xproj deleted file mode 100644 index 593e5d6816..0000000000 --- a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/Microsoft.AspNetCore.ChunkingCookieManager.Sources.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0.25420 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 2690fbe6-9d27-4c84-b82c-11188b0bcda3 - Microsoft.AspNetCore.ChunkingCookieManager.Sources - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json b/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json deleted file mode 100644 index 7ccf0307dc..0000000000 --- a/src/Microsoft.AspNetCore.ChunkingCookieManager.Sources/project.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "1.2.0-*", - "shared": "*.cs", - "dependencies": { - "Microsoft.AspNetCore.Http.Abstractions": "1.2.0-*", - "Microsoft.Net.Http.Headers": "1.2.0-*", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj new file mode 100644 index 0000000000..af3b620b47 --- /dev/null +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -0,0 +1,29 @@ + + + + + + ASP.NET Core cookie policy classes to control the behavior of cookies. + net451;netstandard1.3 + $(NoWarn);CS1591 + true + aspnetcore + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj deleted file mode 100644 index 0cd49f3242..0000000000 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 86183dc3-02a8-4a68-8b60-71ecec066e79 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.cs deleted file mode 100644 index 76feceeff0..0000000000 --- a/src/Microsoft.AspNetCore.CookiePolicy/Properties/AssemblyInfo.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. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.CookiePolicy/project.json b/src/Microsoft.AspNetCore.CookiePolicy/project.json deleted file mode 100644 index 95eede5db2..0000000000 --- a/src/Microsoft.AspNetCore.CookiePolicy/project.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": "1.2.0-*", - "description": "ASP.NET Core cookie policy classes to control the behavior of cookies.", - "packOptions": { - "repository": { - "type": "git", - "url": "git://github.com/aspnet/security" - }, - "tags": [ - "aspnetcore" - ] - }, - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.Http": "1.2.0-*", - "Microsoft.Extensions.Options": "1.2.0-*", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj new file mode 100644 index 0000000000..eae395d84f --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -0,0 +1,29 @@ + + + + + + A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication. + net451 + $(NoWarn);CS1591 + true + aspnetcore;katana;owin;security + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj deleted file mode 100644 index 052e998161..0000000000 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - a7922dd8-09f1-43e4-938b-cc523ea08898 - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs index 56cb77fdc5..490fa7cb2a 100644 --- a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs +++ b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs @@ -1,15 +1,8 @@ // 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.Reflection; -using System.Resources; using System.Runtime.InteropServices; -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] - // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("a7922dd8-09f1-43e4-938b-cc523ea08898")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] + diff --git a/src/Microsoft.Owin.Security.Interop/project.json b/src/Microsoft.Owin.Security.Interop/project.json deleted file mode 100644 index 54b4c97ccc..0000000000 --- a/src/Microsoft.Owin.Security.Interop/project.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "version": "1.2.0-*", - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "description": "A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication.", - "packOptions": { - "tags": [ - "aspnetcore", - "katana", - "owin", - "security" - ] - }, - "dependencies": { - "Microsoft.AspNetCore.DataProtection.Extensions": "1.2.0-*", - "Microsoft.Owin.Security": "3.0.1", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {} - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj new file mode 100644 index 0000000000..0eb8b1269b --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -0,0 +1,50 @@ + + + + + + netcoreapp1.1;net451 + + + + + + + + + + + + + + + + + true + + + true + + + + + + true + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj deleted file mode 100644 index 1050a47adb..0000000000 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 8da26cd1-1302-4cfd-9270-9fa1b7c6138b - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/project.json b/test/Microsoft.AspNetCore.Authentication.Test/project.json deleted file mode 100644 index 7477e93fae..0000000000 --- a/test/Microsoft.AspNetCore.Authentication.Test/project.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "buildOptions": { - "warningsAsErrors": true - }, - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.Facebook": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.Google": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.JwtBearer": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.2.0-*", - "Microsoft.AspNetCore.Authentication.Twitter": "1.2.0-*", - "Microsoft.AspNetCore.TestHost": "1.2.0-*", - "Microsoft.AspNetCore.Testing": "1.2.0-*", - "xunit": "2.2.0-*" - }, - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - }, - "net451": {} - }, - "testRunner": "xunit" -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj new file mode 100644 index 0000000000..f4d6f8c669 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -0,0 +1,39 @@ + + + + + + netcoreapp1.1;net451 + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj deleted file mode 100644 index 59bcbc9c4a..0000000000 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 7af5ad96-eb6e-4d0e-8abe-c0b543c0f4c2 - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authorization.Test/project.json b/test/Microsoft.AspNetCore.Authorization.Test/project.json deleted file mode 100644 index dfb4e72881..0000000000 --- a/test/Microsoft.AspNetCore.Authorization.Test/project.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "buildOptions": { - "warningsAsErrors": true - }, - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Authorization": "1.2.0-*", - "Microsoft.AspNetCore.Testing": "1.2.0-*", - "Microsoft.Extensions.DependencyInjection": "1.2.0-*", - "Microsoft.Extensions.Logging": "1.2.0-*", - "xunit": "2.2.0-*" - }, - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - }, - "net451": {} - }, - "testRunner": "xunit" -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj new file mode 100644 index 0000000000..21ded78c89 --- /dev/null +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -0,0 +1,31 @@ + + + + + + netcoreapp1.1;net451 + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.xproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.xproj deleted file mode 100644 index d95a6c1287..0000000000 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0.25420 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 51563775-c659-4907-9baf-9995bab87d01 - Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json deleted file mode 100644 index d8761ffa3d..0000000000 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/project.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "buildOptions": { - "warningsAsErrors": true - }, - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.ChunkingCookieManager.Sources": { - "version": "1.2.0-*", - "type": "build" - }, - "Microsoft.AspNetCore.Http": "1.2.0-*", - "xunit": "2.2.0-*" - }, - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - }, - "net451": {} - }, - "testRunner": "xunit" -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj new file mode 100644 index 0000000000..c048cdd251 --- /dev/null +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -0,0 +1,42 @@ + + + + + + netcoreapp1.1;net451 + + + + + + + + + + + + true + + + + + + true + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj deleted file mode 100644 index 06582d576f..0000000000 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 1790e052-646f-4529-b90e-6fea95520d69 - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json b/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json deleted file mode 100644 index d849b6bc24..0000000000 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/project.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "buildOptions": { - "warningsAsErrors": true - }, - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", - "Microsoft.AspNetCore.CookiePolicy": "1.2.0-*", - "Microsoft.AspNetCore.TestHost": "1.2.0-*", - "Microsoft.Extensions.DependencyInjection": "1.2.0-*", - "xunit": "2.2.0-*" - }, - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - }, - "net451": {} - }, - "testRunner": "xunit" -} \ No newline at end of file diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj new file mode 100644 index 0000000000..23815e0cca --- /dev/null +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -0,0 +1,40 @@ + + + + + + net451 + + + + + + + + + + + + true + + + + + + true + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj deleted file mode 100644 index d7f7c9d958..0000000000 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - a2b5dc39-68d5-4145-a8cc-6aeab7d33a24 - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.Owin.Security.Interop.Test/project.json b/test/Microsoft.Owin.Security.Interop.Test/project.json deleted file mode 100644 index 43738eba99..0000000000 --- a/test/Microsoft.Owin.Security.Interop.Test/project.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "buildOptions": { - "warningsAsErrors": true - }, - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Authentication.Cookies": "1.2.0-*", - "Microsoft.AspNetCore.TestHost": "1.2.0-*", - "Microsoft.Owin.Security.Cookies": "3.0.1", - "Microsoft.Owin.Security.Interop": "1.2.0-*", - "Microsoft.Owin.Testing": "3.0.1", - "NETStandard.Library": "1.6.2-*", - "xunit": "2.2.0-*" - }, - "frameworks": { - "net451": {} - }, - "testRunner": "xunit" -} \ No newline at end of file diff --git a/version.props b/version.props new file mode 100644 index 0000000000..e77c8d9c38 --- /dev/null +++ b/version.props @@ -0,0 +1,7 @@ + + + + 1.2.0 + preview1 + + \ No newline at end of file From 861026cd76e7791eb3595709de9fa1a6ccf53ce3 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 5 Jan 2017 18:16:07 -0800 Subject: [PATCH 667/900] Remove redundant references --- samples/CookieSample/CookieSample.csproj | 8 -------- samples/CookieSessionSample/CookieSessionSample.csproj | 8 -------- samples/JwtBearerSample/JwtBearerSample.csproj | 8 -------- .../OpenIdConnect.AzureAdSample.csproj | 8 -------- samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 8 -------- samples/SocialSample/SocialSample.csproj | 8 -------- .../Microsoft.AspNetCore.Authentication.Cookies.csproj | 10 +--------- ...Microsoft.AspNetCore.Authentication.Facebook.csproj | 8 -------- .../Microsoft.AspNetCore.Authentication.Google.csproj | 8 -------- ...icrosoft.AspNetCore.Authentication.JwtBearer.csproj | 10 +--------- ...t.AspNetCore.Authentication.MicrosoftAccount.csproj | 8 -------- .../Microsoft.AspNetCore.Authentication.OAuth.csproj | 10 +--------- ...soft.AspNetCore.Authentication.OpenIdConnect.csproj | 10 +--------- .../Microsoft.AspNetCore.Authentication.Twitter.csproj | 10 +--------- .../Microsoft.AspNetCore.Authentication.csproj | 8 +------- .../Microsoft.AspNetCore.Authorization.csproj | 8 +------- .../Microsoft.AspNetCore.CookiePolicy.csproj | 5 ----- .../Microsoft.Owin.Security.Interop.csproj | 5 ----- .../Microsoft.AspNetCore.Authentication.Test.csproj | 8 -------- .../Microsoft.AspNetCore.Authorization.Test.csproj | 7 ------- ...spNetCore.ChunkingCookieManager.Sources.Test.csproj | 5 ----- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 8 -------- .../Microsoft.Owin.Security.Interop.Test.csproj | 8 -------- 23 files changed, 7 insertions(+), 177 deletions(-) diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 623896b736..7a3ab47926 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -20,14 +20,6 @@ - - - true - - - - - diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index fb189cef4f..4a77be1272 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -20,14 +20,6 @@ - - - true - - - - - diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 2d94cdbdf8..273cfaf891 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -22,14 +22,6 @@ - - - true - - - - - diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 7331e7f051..ef7bcae736 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -22,14 +22,6 @@ - - - true - - - - - diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index dfb0231079..78d799be14 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -21,14 +21,6 @@ - - - true - - - - - diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 71900b9b5d..1af3fe1c2b 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -27,14 +27,6 @@ - - - true - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 955afcb397..bdbcff2764 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -21,17 +21,9 @@ - - - true - - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index a99538405c..999bb8bd88 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -22,14 +22,6 @@ - - - true - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index cce86fac68..e66ceff787 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -22,14 +22,6 @@ - - - true - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 41d886031e..e95df79ce3 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -19,16 +19,8 @@ - - - true - - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 341096369b..0af3a9d0d6 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -22,14 +22,6 @@ - - - true - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 1199750e87..1bb635bfc3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -19,16 +19,8 @@ - - - true - - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 407dc44ae4..a90a4846cc 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -19,16 +19,8 @@ - - - true - - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index a81a883803..b7222fd9c6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -19,16 +19,8 @@ - - - true - - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index ed11f94ad6..edc85f76ed 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -22,7 +22,7 @@ - - - - - - - diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index af3b620b47..0d0e37c80f 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -21,9 +21,4 @@ - - - - - diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index eae395d84f..7ec8078c58 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -21,9 +21,4 @@ - - - - - diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 0eb8b1269b..23cc33121c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -27,14 +27,6 @@ - - - true - - - - - diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index f4d6f8c669..2d8f9652b5 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -15,13 +15,6 @@ - - - true - - - - diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 21ded78c89..cf2a629d4c 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -23,9 +23,4 @@ - - - - - diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index c048cdd251..ac83191062 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -19,14 +19,6 @@ - - - true - - - - - diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 23815e0cca..344294e72b 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -19,14 +19,6 @@ - - - true - - - - - From 8c9e27963cb80829b16de8da5d70caab2c55f19e Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 9 Jan 2017 10:40:04 -0800 Subject: [PATCH 668/900] Upgrade appveyor image --- appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index b9a9bcd1e6..c6b856f49c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,4 +10,6 @@ build_script: - build.cmd verify clone_depth: 1 test: off -deploy: off \ No newline at end of file +deploy: off +# Required for dotnet-test to work +os: Visual Studio 2015 From 9917e8bb30417e933c31e111d32e69fdf477a4f0 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 5 Jan 2017 14:53:45 -0800 Subject: [PATCH 669/900] Update launchSettings for new VS 2017 rules --- samples/CookieSample/Properties/launchSettings.json | 5 ++--- samples/CookieSessionSample/Properties/launchSettings.json | 5 ++--- samples/JwtBearerSample/Properties/launchSettings.json | 5 ++--- .../Properties/launchSettings.json | 5 ++--- samples/OpenIdConnectSample/Properties/launchSettings.json | 3 +-- samples/SocialSample/Properties/launchSettings.json | 5 ++--- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/samples/CookieSample/Properties/launchSettings.json b/samples/CookieSample/Properties/launchSettings.json index afe862f4f4..38ca6fc37f 100644 --- a/samples/CookieSample/Properties/launchSettings.json +++ b/samples/CookieSample/Properties/launchSettings.json @@ -18,10 +18,9 @@ "CookieSample": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "http://localhost:12345", + "applicationUrl": "http://localhost:12345", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_URLS": "http://localhost:12345" + "ASPNETCORE_ENVIRONMENT": "Development" } } } diff --git a/samples/CookieSessionSample/Properties/launchSettings.json b/samples/CookieSessionSample/Properties/launchSettings.json index edb6e4dd19..25de3e478e 100644 --- a/samples/CookieSessionSample/Properties/launchSettings.json +++ b/samples/CookieSessionSample/Properties/launchSettings.json @@ -18,10 +18,9 @@ "CookieSessionSample": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "http://localhost:12345", + "applicationUrl": "http://localhost:12345", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_URLS": "http://localhost:12345" + "ASPNETCORE_ENVIRONMENT": "Development" } } } diff --git a/samples/JwtBearerSample/Properties/launchSettings.json b/samples/JwtBearerSample/Properties/launchSettings.json index e89788c48f..6922375c98 100644 --- a/samples/JwtBearerSample/Properties/launchSettings.json +++ b/samples/JwtBearerSample/Properties/launchSettings.json @@ -18,10 +18,9 @@ "JwtBearer": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "http://localhost:42023", + "applicationUrl": "http://localhost:42023", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_URLS": "http://localhost:42023" + "ASPNETCORE_ENVIRONMENT": "Development" } } } diff --git a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json index 62dc4ef778..e6436fee2a 100644 --- a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json +++ b/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json @@ -18,10 +18,9 @@ "OpenIdConnect": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "http://localhost:42023", + "applicationUrl": "http://localhost:42023", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_URLS": "http://localhost:42023" + "ASPNETCORE_ENVIRONMENT": "Development" } } } diff --git a/samples/OpenIdConnectSample/Properties/launchSettings.json b/samples/OpenIdConnectSample/Properties/launchSettings.json index 48610115fa..058fa4c5dd 100644 --- a/samples/OpenIdConnectSample/Properties/launchSettings.json +++ b/samples/OpenIdConnectSample/Properties/launchSettings.json @@ -19,9 +19,8 @@ "OpenIdConnectSample": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "https://localhost:44318/", + "applicationUrl": "https://localhost:44318/", "environmentVariables": { - "ASPNETCORE_URLS": "https://localhost:44318/", "ASPNETCORE_ENVIRONMENT": "Development" } } diff --git a/samples/SocialSample/Properties/launchSettings.json b/samples/SocialSample/Properties/launchSettings.json index 251bfbffd4..30bf2e5f6a 100644 --- a/samples/SocialSample/Properties/launchSettings.json +++ b/samples/SocialSample/Properties/launchSettings.json @@ -19,10 +19,9 @@ "SocialSample": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "https://localhost:44318/", + "applicationUrl": "https://localhost:44318/", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_URLS": "https://localhost:44318/" + "ASPNETCORE_ENVIRONMENT": "Development" } } } From fa64b0c0fb193c584d5d0835293860f92469145a Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Mon, 9 Jan 2017 19:58:22 -0800 Subject: [PATCH 670/900] React to UseHttps change --- samples/OpenIdConnectSample/Program.cs | 18 +++++++++++++----- samples/SocialSample/Program.cs | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs index 49cbf139d6..741dd6ebf5 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -1,4 +1,6 @@ -using System.IO; +using System; +using System.IO; +using System.Net; using System.Reflection; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; @@ -13,11 +15,17 @@ namespace OpenIdConnectSample var host = new WebHostBuilder() .UseKestrel(options => { - // Configure SSL - var serverCertificate = LoadCertificate(); - options.UseHttps(serverCertificate); + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + { + // ANCM is not hosting the process + options.Listen(IPAddress.Loopback, 44318, listenOptions => + { + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); + } }) - .UseUrls("https://localhost:44318") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/samples/SocialSample/Program.cs b/samples/SocialSample/Program.cs index f3cad66ad3..483feec169 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -1,4 +1,6 @@ -using System.IO; +using System; +using System.IO; +using System.Net; using System.Reflection; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; @@ -14,9 +16,16 @@ namespace SocialSample var host = new WebHostBuilder() .UseKestrel(options => { - //Configure SSL - var serverCertificate = LoadCertificate(); - options.UseHttps(serverCertificate); + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + { + // ANCM is not hosting the process + options.Listen(IPAddress.Loopback, 5000, listenOptions => + { + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); + } }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() From 46f0d193c874944a080737892283954a85fe1290 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 11 Jan 2017 14:30:11 -0800 Subject: [PATCH 671/900] React to aspnet/KoreBuild#155 This converts to using Internal.AspNetCore.Sdk instead of importing from the KoreBuild folder directly --- NuGet.config | 1 + build/common.props | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/NuGet.config b/NuGet.config index 0fd623ffdd..93f1ac47df 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,6 +2,7 @@ + diff --git a/build/common.props b/build/common.props index 700582a850..f2d9508e5a 100644 --- a/build/common.props +++ b/build/common.props @@ -1,20 +1,17 @@ - + Microsoft ASP.NET Core https://github.com/aspnet/Security git $(MSBuildThisFileDirectory)Key.snk true true - Microsoft ASP.NET Core - - - + + + + \ No newline at end of file From c64c5db02dea6e793d2fad564c094a219618cece Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Tue, 17 Jan 2017 16:48:52 -0800 Subject: [PATCH 672/900] Change Xunit versions --- .../Microsoft.AspNetCore.Authentication.Test.csproj | 4 ++-- .../Microsoft.AspNetCore.Authorization.Test.csproj | 4 ++-- ...osoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj | 4 ++-- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 4 ++-- .../Microsoft.Owin.Security.Interop.Test.csproj | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 23cc33121c..39c01086e9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -29,10 +29,10 @@ - + - + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 2d8f9652b5..424132eb20 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -18,11 +18,11 @@ - + - + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index cf2a629d4c..4c4da177fd 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -14,9 +14,9 @@ - + - + diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index ac83191062..b46df5b990 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -21,10 +21,10 @@ - + - + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 344294e72b..d78da43973 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -21,12 +21,12 @@ - + - + From f2fd58d8c42f5ebdc70a7714b1183fbad7ff095d Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 19 Jan 2017 13:37:04 -0800 Subject: [PATCH 673/900] Fix the social sample port. --- samples/SocialSample/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/SocialSample/Program.cs b/samples/SocialSample/Program.cs index 483feec169..76fb5e59a9 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -19,7 +19,7 @@ namespace SocialSample if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) { // ANCM is not hosting the process - options.Listen(IPAddress.Loopback, 5000, listenOptions => + options.Listen(IPAddress.Loopback, 44318, listenOptions => { // Configure SSL var serverCertificate = LoadCertificate(); From 3828232d510e5fa4ecb9006f3e4a9f2b08589a73 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 19 Jan 2017 13:45:44 -0800 Subject: [PATCH 674/900] Fix AAD sample --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 84558affb7..5b18a0e13d 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -95,7 +95,7 @@ namespace OpenIdConnect.AzureAdSample var result = await authContext.AcquireTokenByAuthorizationCodeAsync( context.ProtocolMessage.Code, new Uri(currentUri), credential, resource); - context.HandleCodeRedemption(); + context.HandleCodeRedemption(result.AccessToken, result.IdToken); } } }); From fddfad14c9ce757717e4dfd2db5bf4f045b9d52e Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 19 Jan 2017 13:50:46 -0800 Subject: [PATCH 675/900] #1082 Update IdentityModel dependencies to 5.1.2 --- .../OpenIdConnect.AzureAdSample.csproj | 13 +++---------- ...osoft.AspNetCore.Authentication.JwtBearer.csproj | 10 ++-------- ...t.AspNetCore.Authentication.OpenIdConnect.csproj | 10 ++-------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index ef7bcae736..9b27985b71 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,5 +1,4 @@ - - + net451;netcoreapp1.1 Exe @@ -7,13 +6,11 @@ win7-x64 aspnet5-OpenIdConnectSample-20151210110318 - PreserveNewest - @@ -21,22 +18,18 @@ true - - + - - - - + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index e95df79ce3..db5d30bd2f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. net451;netstandard1.4 @@ -9,23 +7,19 @@ true aspnetcore;authentication;security - - - - + - - + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index a90a4846cc..d6b2006290 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. net451;netstandard1.4 @@ -9,23 +7,19 @@ true aspnetcore;authentication;security - - - - + - - + \ No newline at end of file From 7d0841ae1ca88cc8161cdff5daca53215e3b6d0f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 19 Jan 2017 17:11:42 -0800 Subject: [PATCH 676/900] Pin sdk version using global.json --- global.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 global.json diff --git a/global.json b/global.json new file mode 100644 index 0000000000..1e3e060e88 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "1.0.0-preview4-004233" + } +} From 7634c5420a85a28217b0384f34324273aed042c5 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 19 Jan 2017 22:00:32 -0800 Subject: [PATCH 677/900] Upgrade to RC.3 Removes __TemporarySources__ to use contentFiles packages Remove default globs Update test platform --- build/common.props | 9 ++++- global.json | 5 --- makefile.shade | 2 +- samples/CookieSample/CookieSample.csproj | 17 +------- .../CookieSessionSample.csproj | 17 +------- .../JwtBearerSample/JwtBearerSample.csproj | 19 +-------- .../OpenIdConnect.AzureAdSample.csproj | 16 +------- .../OpenIdConnectSample.csproj | 19 +-------- samples/SocialSample/SocialSample.csproj | 19 +-------- shared/build.proj | 24 ----------- shared/sources.csproj | 29 ++++++++++++++ shared/sources.nuspec | 19 --------- ...t.AspNetCore.Authentication.Cookies.csproj | 11 +---- .../__TemporarySources__/TaskCache.cs | 23 ----------- .../__TemporarySources__/TaskCacheOfT.cs | 16 -------- ....AspNetCore.Authentication.Facebook.csproj | 12 ------ ...ft.AspNetCore.Authentication.Google.csproj | 12 ------ ...AspNetCore.Authentication.JwtBearer.csproj | 12 +----- .../__TemporarySources__/TaskCache.cs | 23 ----------- .../__TemporarySources__/TaskCacheOfT.cs | 16 -------- ...ore.Authentication.MicrosoftAccount.csproj | 12 ------ ...oft.AspNetCore.Authentication.OAuth.csproj | 14 +------ .../__TemporarySources__/TaskCache.cs | 23 ----------- .../__TemporarySources__/TaskCacheOfT.cs | 16 -------- ...etCore.Authentication.OpenIdConnect.csproj | 12 +----- .../__TemporarySources__/TaskCache.cs | 23 ----------- .../__TemporarySources__/TaskCacheOfT.cs | 16 -------- ...t.AspNetCore.Authentication.Twitter.csproj | 14 +------ .../__TemporarySources__/TaskCache.cs | 23 ----------- .../__TemporarySources__/TaskCacheOfT.cs | 16 -------- ...Microsoft.AspNetCore.Authentication.csproj | 13 +----- .../__TemporarySources__/SecurityHelper.cs | 40 ------------------- .../__TemporarySources__/TaskCache.cs | 23 ----------- .../__TemporarySources__/TaskCacheOfT.cs | 16 -------- .../Microsoft.AspNetCore.Authorization.csproj | 11 +---- .../__TemporarySources__/TaskCache.cs | 23 ----------- .../__TemporarySources__/TaskCacheOfT.cs | 16 -------- .../Microsoft.AspNetCore.CookiePolicy.csproj | 6 --- .../Microsoft.Owin.Security.Interop.csproj | 6 --- ...soft.AspNetCore.Authentication.Test.csproj | 20 +--------- ...osoft.AspNetCore.Authorization.Test.csproj | 15 +------ ....ChunkingCookieManager.Sources.Test.csproj | 8 +--- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 17 +------- ...icrosoft.Owin.Security.Interop.Test.csproj | 14 +------ 44 files changed, 58 insertions(+), 659 deletions(-) delete mode 100644 global.json delete mode 100644 shared/build.proj create mode 100644 shared/sources.csproj delete mode 100644 shared/sources.nuspec delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCache.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCache.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCache.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCache.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCache.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/__TemporarySources__/SecurityHelper.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCache.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCacheOfT.cs delete mode 100644 src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCache.cs delete mode 100644 src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCacheOfT.cs diff --git a/build/common.props b/build/common.props index f2d9508e5a..7ce50d277a 100644 --- a/build/common.props +++ b/build/common.props @@ -8,10 +8,17 @@ $(MSBuildThisFileDirectory)Key.snk true true + 1.2.0-* + 1.6.2-* + $(VersionSuffix)-$(BuildNumber) - + + + + + \ No newline at end of file diff --git a/global.json b/global.json deleted file mode 100644 index 1e3e060e88..0000000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "version": "1.0.0-preview4-004233" - } -} diff --git a/makefile.shade b/makefile.shade index f5ea5ac9eb..76d5bf85e4 100644 --- a/makefile.shade +++ b/makefile.shade @@ -5,4 +5,4 @@ use-standard-lifecycle k-standard-goals #pack-sources target='build-pack' - dotnet command='msbuild shared/build.proj /t:Pack /v:n' + dotnet command='msbuild shared/sources.csproj "/t:Restore;PackAll" /v:n' diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 7a3ab47926..e9987f3a86 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -5,22 +5,11 @@ Exe win7-x64 + 1.2.0-* - - - PreserveNewest - - - - - true - - - - @@ -29,8 +18,4 @@ - - - - diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 4a77be1272..62bb9f4a9f 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -5,22 +5,11 @@ Exe win7-x64 + 1.2.0-* - - - PreserveNewest - - - - - true - - - - @@ -29,8 +18,4 @@ - - - - diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 273cfaf891..83c0c643d7 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -7,22 +7,11 @@ win7-x64 Exe aspnet5-JwtBearerSample-20151210102827 - - - - - PreserveNewest - - + 1.2.0-* + - - true - - - - @@ -30,8 +19,4 @@ - - - - diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 9b27985b71..6cb421a2a0 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -5,31 +5,17 @@ win7-x64 aspnet5-OpenIdConnectSample-20151210110318 + 1.2.0-* - - - PreserveNewest - - - - true - - - - - - - - \ No newline at end of file diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 78d799be14..acbae28b43 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -6,22 +6,12 @@ win7-x64 aspnet5-OpenIdConnectSample-20151210110318 + 1.2.0-* - - - - - - - true - - - - @@ -30,13 +20,6 @@ - - - - - - - diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 1af3fe1c2b..1c137b6d5c 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -6,28 +6,15 @@ win7-x64 aspnet5-SocialSample-20151210111056 + 1.2.0-* - - - - - - - true - - - true - - - - @@ -38,8 +25,4 @@ - - - - diff --git a/shared/build.proj b/shared/build.proj deleted file mode 100644 index d3fc56ba8a..0000000000 --- a/shared/build.proj +++ /dev/null @@ -1,24 +0,0 @@ - - - - - $(MSBuildThisFileDirectory)..\artifacts\build - $(VersionPrefix) - $(Version)-$(VersionSuffix) - - - - - - - - - - - \ No newline at end of file diff --git a/shared/sources.csproj b/shared/sources.csproj new file mode 100644 index 0000000000..70c6cdbf2c --- /dev/null +++ b/shared/sources.csproj @@ -0,0 +1,29 @@ + + + + + + $(MSBuildThisFileDirectory)..\artifacts\build + $(MSBuildThisFileDirectory)\$(PackageId) + netstandard1.0 + false + $(PackageId) + false + contentFiles + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shared/sources.nuspec b/shared/sources.nuspec deleted file mode 100644 index 0eb708b9b8..0000000000 --- a/shared/sources.nuspec +++ /dev/null @@ -1,19 +0,0 @@ - - - - $id$ - $version$ - Microsoft - Microsoft - false - $id$ - - - - - - - - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index bdbcff2764..01f5b635d1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -12,23 +12,14 @@ - - - - - - + - diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCache.cs deleted file mode 100644 index 67a87fca59..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCache.cs +++ /dev/null @@ -1,23 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// A that's already completed successfully. - /// - /// - /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done - /// by Task.CompletedTask. - /// -#if NET451 - public static readonly Task CompletedTask = Task.FromResult(0); -#else - public static readonly Task CompletedTask = Task.CompletedTask; -#endif - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCacheOfT.cs deleted file mode 100644 index 5015e3aba7..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/__TemporarySources__/TaskCacheOfT.cs +++ /dev/null @@ -1,16 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// Gets a completed with the value of default(T). - /// - public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); - } - -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index 999bb8bd88..7d7e3ad043 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -10,20 +10,8 @@ aspnetcore;authentication;security - - - - - - - true - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index e66ceff787..30545dd69b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -10,20 +10,8 @@ aspnetcore;authentication;security - - - - - - - true - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index db5d30bd2f..b53e5ee85d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -7,19 +7,9 @@ true aspnetcore;authentication;security - - - - - - - + - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCache.cs deleted file mode 100644 index 67a87fca59..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCache.cs +++ /dev/null @@ -1,23 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// A that's already completed successfully. - /// - /// - /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done - /// by Task.CompletedTask. - /// -#if NET451 - public static readonly Task CompletedTask = Task.FromResult(0); -#else - public static readonly Task CompletedTask = Task.CompletedTask; -#endif - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCacheOfT.cs deleted file mode 100644 index 5015e3aba7..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/__TemporarySources__/TaskCacheOfT.cs +++ /dev/null @@ -1,16 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// Gets a completed with the value of default(T). - /// - public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); - } - -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 0af3a9d0d6..559b78a3c9 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -10,20 +10,8 @@ aspnetcore;authentication;security - - - - - - - true - - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 1bb635bfc3..3a0ad122c5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -10,21 +10,9 @@ aspnetcore;authentication;security - - - - - - - - - - + diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCache.cs deleted file mode 100644 index 67a87fca59..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCache.cs +++ /dev/null @@ -1,23 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// A that's already completed successfully. - /// - /// - /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done - /// by Task.CompletedTask. - /// -#if NET451 - public static readonly Task CompletedTask = Task.FromResult(0); -#else - public static readonly Task CompletedTask = Task.CompletedTask; -#endif - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCacheOfT.cs deleted file mode 100644 index 5015e3aba7..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/__TemporarySources__/TaskCacheOfT.cs +++ /dev/null @@ -1,16 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// Gets a completed with the value of default(T). - /// - public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); - } - -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index d6b2006290..72da65f4c5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -7,19 +7,9 @@ true aspnetcore;authentication;security - - - - - - - + - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCache.cs deleted file mode 100644 index 67a87fca59..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCache.cs +++ /dev/null @@ -1,23 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// A that's already completed successfully. - /// - /// - /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done - /// by Task.CompletedTask. - /// -#if NET451 - public static readonly Task CompletedTask = Task.FromResult(0); -#else - public static readonly Task CompletedTask = Task.CompletedTask; -#endif - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCacheOfT.cs deleted file mode 100644 index 5015e3aba7..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/__TemporarySources__/TaskCacheOfT.cs +++ /dev/null @@ -1,16 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// Gets a completed with the value of default(T). - /// - public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); - } - -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index b7222fd9c6..0368a8be0e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -10,21 +10,9 @@ aspnetcore;authentication;security - - - - - - - - - - + diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCache.cs deleted file mode 100644 index 67a87fca59..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCache.cs +++ /dev/null @@ -1,23 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// A that's already completed successfully. - /// - /// - /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done - /// by Task.CompletedTask. - /// -#if NET451 - public static readonly Task CompletedTask = Task.FromResult(0); -#else - public static readonly Task CompletedTask = Task.CompletedTask; -#endif - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCacheOfT.cs deleted file mode 100644 index 5015e3aba7..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/__TemporarySources__/TaskCacheOfT.cs +++ /dev/null @@ -1,16 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// Gets a completed with the value of default(T). - /// - public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); - } - -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index edc85f76ed..e93061de63 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -11,24 +11,15 @@ aspnetcore;authentication;security - - - - - - + + - diff --git a/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/SecurityHelper.cs b/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/SecurityHelper.cs deleted file mode 100644 index 408ef6b224..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/SecurityHelper.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Linq; -using System.Security.Claims; - -namespace Microsoft.Extensions.Internal -{ - /// - /// Helper code used when implementing authentication middleware - /// - internal static class SecurityHelper - { - /// - /// Add all ClaimsIdentities from an additional ClaimPrincipal to the ClaimsPrincipal - /// Merges a new claims principal, placing all new identities first, and eliminating - /// any empty unauthenticated identities from context.User - /// - /// The containing existing . - /// The containing to be added. - public static ClaimsPrincipal MergeUserPrincipal(ClaimsPrincipal existingPrincipal, ClaimsPrincipal additionalPrincipal) - { - var newPrincipal = new ClaimsPrincipal(); - - // New principal identities go first - if (additionalPrincipal != null) - { - newPrincipal.AddIdentities(additionalPrincipal.Identities); - } - - // Then add any existing non empty or authenticated identities - if (existingPrincipal != null) - { - newPrincipal.AddIdentities(existingPrincipal.Identities.Where(i => i.IsAuthenticated || i.Claims.Any())); - } - return newPrincipal; - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCache.cs deleted file mode 100644 index 67a87fca59..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCache.cs +++ /dev/null @@ -1,23 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// A that's already completed successfully. - /// - /// - /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done - /// by Task.CompletedTask. - /// -#if NET451 - public static readonly Task CompletedTask = Task.FromResult(0); -#else - public static readonly Task CompletedTask = Task.CompletedTask; -#endif - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCacheOfT.cs deleted file mode 100644 index 5015e3aba7..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/__TemporarySources__/TaskCacheOfT.cs +++ /dev/null @@ -1,16 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// Gets a completed with the value of default(T). - /// - public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); - } - -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index fdc54f10bd..6a1c60f94a 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -13,19 +13,10 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute aspnetcore;authorization - - - - - - - + diff --git a/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCache.cs b/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCache.cs deleted file mode 100644 index 67a87fca59..0000000000 --- a/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCache.cs +++ /dev/null @@ -1,23 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// A that's already completed successfully. - /// - /// - /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done - /// by Task.CompletedTask. - /// -#if NET451 - public static readonly Task CompletedTask = Task.FromResult(0); -#else - public static readonly Task CompletedTask = Task.CompletedTask; -#endif - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCacheOfT.cs deleted file mode 100644 index 5015e3aba7..0000000000 --- a/src/Microsoft.AspNetCore.Authorization/__TemporarySources__/TaskCacheOfT.cs +++ /dev/null @@ -1,16 +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.Threading.Tasks; - -namespace Microsoft.Extensions.Internal -{ - internal static class TaskCache - { - /// - /// Gets a completed with the value of default(T). - /// - public static Task DefaultCompletedTask { get; } = Task.FromResult(default(T)); - } - -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 0d0e37c80f..2f5b094c07 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -10,15 +10,9 @@ aspnetcore - - - - - - diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index 7ec8078c58..4c6cb7a834 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -10,15 +10,9 @@ aspnetcore;katana;owin;security - - - - - - diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 39c01086e9..0a9adfd437 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -6,11 +6,6 @@ netcoreapp1.1;net451 - - - - - @@ -19,24 +14,11 @@ - - true - - - true - - - - - + - - - - diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 424132eb20..62b041f372 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -6,18 +6,9 @@ netcoreapp1.1;net451 - - - - - - - - - - + @@ -25,8 +16,4 @@ - - - - diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 4c4da177fd..672309b928 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -7,20 +7,14 @@ - - - + - - - - diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index b46df5b990..91e98ad986 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -6,29 +6,14 @@ netcoreapp1.1;net451 - - - - - - - true - - - - - + - - - - diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index d78da43973..408703450c 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -6,26 +6,14 @@ net451 - - - - - - - true - - - - - + - From a031c4badb0466c9a95a43691e5bf07fce096034 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 25 Jan 2017 16:07:46 -0800 Subject: [PATCH 678/900] Update OpenId package versions --- .../Microsoft.AspNetCore.Authentication.JwtBearer.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index b53e5ee85d..1e8ecac61e 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 72da65f4c5..aa44423133 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -10,6 +10,6 @@ - + \ No newline at end of file From 0113df6075104c4081d3838f9d8bde35c4181e5f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 30 Jan 2017 11:10:41 -0800 Subject: [PATCH 679/900] Revert "Update OpenId package versions" This reverts commit a031c4badb0466c9a95a43691e5bf07fce096034. --- .../Microsoft.AspNetCore.Authentication.JwtBearer.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 1e8ecac61e..b53e5ee85d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index aa44423133..72da65f4c5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -10,6 +10,6 @@ - + \ No newline at end of file From c18a3d3a7d9e9771638b74ad5c7777f33e4363a6 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 31 Jan 2017 06:51:51 -0800 Subject: [PATCH 680/900] Revert "Revert "Update OpenId package versions"" This reverts commit 0113df6075104c4081d3838f9d8bde35c4181e5f. --- .../Microsoft.AspNetCore.Authentication.JwtBearer.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index b53e5ee85d..1e8ecac61e 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 72da65f4c5..aa44423133 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -10,6 +10,6 @@ - + \ No newline at end of file From 7dd6ee791ac24bc3a28f75d67ae8cb5935f557db Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 31 Jan 2017 17:09:55 -0800 Subject: [PATCH 681/900] Simplify packing --- shared/sources.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shared/sources.csproj b/shared/sources.csproj index 70c6cdbf2c..d8796f1a45 100644 --- a/shared/sources.csproj +++ b/shared/sources.csproj @@ -13,8 +13,7 @@ - - + From fea5d5cfdc8fc9413ba7816cc108f4d893ac16e1 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Mon, 6 Feb 2017 22:36:42 +0000 Subject: [PATCH 682/900] Truncate SystemClock to Seconds Precision (#1110) --- src/Microsoft.AspNetCore.Authentication/SystemClock.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/SystemClock.cs b/src/Microsoft.AspNetCore.Authentication/SystemClock.cs index 0f9c2a30a0..e1c79192aa 100644 --- a/src/Microsoft.AspNetCore.Authentication/SystemClock.cs +++ b/src/Microsoft.AspNetCore.Authentication/SystemClock.cs @@ -7,7 +7,7 @@ using System; namespace Microsoft.AspNetCore.Authentication { /// - /// Provides access to the normal system clock. + /// Provides access to the normal system clock with precision in seconds. /// public class SystemClock : ISystemClock { @@ -20,8 +20,8 @@ namespace Microsoft.AspNetCore.Authentication { // the clock measures whole seconds only, to have integral expires_in results, and // because milliseconds do not round-trip serialization formats - DateTimeOffset utcNow = DateTimeOffset.UtcNow; - return utcNow.AddMilliseconds(-utcNow.Millisecond); + var utcNowPrecisionSeconds = new DateTime((DateTime.UtcNow.Ticks / TimeSpan.TicksPerSecond) * TimeSpan.TicksPerSecond, DateTimeKind.Utc); + return new DateTimeOffset(utcNowPrecisionSeconds); } } } From 61e7ceba45d64e04b90cf18c9c459c32f1fe2da2 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 8 Feb 2017 17:44:52 -0800 Subject: [PATCH 683/900] React to aspnet/Configuration#594 --- samples/JwtBearerSample/Startup.cs | 2 +- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- samples/OpenIdConnectSample/Startup.cs | 2 +- samples/SocialSample/Startup.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index ac599bc57f..4d1ca74761 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -24,7 +24,7 @@ namespace JwtBearerSample if (env.IsDevelopment()) { // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 - builder.AddUserSecrets(); + builder.AddUserSecrets(); } builder.AddEnvironmentVariables(); diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 5b18a0e13d..ec80cd651d 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -28,7 +28,7 @@ namespace OpenIdConnect.AzureAdSample if (env.IsDevelopment()) { // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 - builder.AddUserSecrets(); + builder.AddUserSecrets(); } builder.AddEnvironmentVariables(); diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 90ed3db25d..587e1e9c16 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -28,7 +28,7 @@ namespace OpenIdConnectSample if (env.IsDevelopment()) { // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 - builder.AddUserSecrets(); + builder.AddUserSecrets(); } builder.AddEnvironmentVariables(); diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 5bd848067e..4c0faaa16f 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -34,7 +34,7 @@ namespace SocialSample if (env.IsDevelopment()) { // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 - builder.AddUserSecrets(); + builder.AddUserSecrets(); } builder.AddEnvironmentVariables(); From cbceba6fa801f344964426e480144a743ab28a2a Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 10 Feb 2017 12:30:06 -0800 Subject: [PATCH 684/900] Remove makefile.shade and sources.csproj --- NuGetPackageVerifier.json | 20 ++++++++++---------- makefile.shade | 8 -------- shared/sources.csproj | 28 ---------------------------- 3 files changed, 10 insertions(+), 46 deletions(-) delete mode 100644 makefile.shade delete mode 100644 shared/sources.csproj diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index 348835e2d2..974eb365c9 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -1,13 +1,13 @@ { - "adx-nonshipping": { - "rules": [], - "packages": { - "Microsoft.AspNetCore.ChunkingCookieManager.Sources": { } - } - }, - "Default": { // Rules to run for packages not listed in any other set. - "rules": [ - "DefaultCompositeRule" - ] + "adx-nonshipping": { + "rules": [], + "packages": { + "Microsoft.AspNetCore.ChunkingCookieManager.Sources": {} } + }, + "Default": { + "rules": [ + "DefaultCompositeRule" + ] + } } \ No newline at end of file diff --git a/makefile.shade b/makefile.shade deleted file mode 100644 index 76d5bf85e4..0000000000 --- a/makefile.shade +++ /dev/null @@ -1,8 +0,0 @@ - -var VERSION='0.1' -var FULL_VERSION='0.1' -use-standard-lifecycle -k-standard-goals - -#pack-sources target='build-pack' - dotnet command='msbuild shared/sources.csproj "/t:Restore;PackAll" /v:n' diff --git a/shared/sources.csproj b/shared/sources.csproj deleted file mode 100644 index d8796f1a45..0000000000 --- a/shared/sources.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)..\artifacts\build - $(MSBuildThisFileDirectory)\$(PackageId) - netstandard1.0 - false - $(PackageId) - false - contentFiles - - - - - - - - - - - - - - \ No newline at end of file From 9847f4065467ca01c051cb0d1e2b49b103b602fb Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 14 Feb 2017 16:03:54 -0800 Subject: [PATCH 685/900] Downgrade to stable packages --- build/common.props | 7 +++---- build/dependencies.props | 6 ++++++ samples/CookieSample/CookieSample.csproj | 3 +-- samples/CookieSessionSample/CookieSessionSample.csproj | 3 +-- samples/JwtBearerSample/JwtBearerSample.csproj | 3 +-- .../OpenIdConnect.AzureAdSample.csproj | 5 ++--- samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 3 +-- samples/SocialSample/SocialSample.csproj | 3 +-- .../Microsoft.AspNetCore.Authentication.Cookies.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.Facebook.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.Google.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.JwtBearer.csproj | 4 ++-- ...osoft.AspNetCore.Authentication.MicrosoftAccount.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.OAuth.csproj | 6 +++--- ...icrosoft.AspNetCore.Authentication.OpenIdConnect.csproj | 4 ++-- .../Microsoft.AspNetCore.Authentication.Twitter.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.csproj | 2 +- .../Microsoft.AspNetCore.Authorization.csproj | 4 ++-- .../Microsoft.AspNetCore.CookiePolicy.csproj | 2 +- .../Microsoft.Owin.Security.Interop.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.Test.csproj | 2 +- .../Microsoft.AspNetCore.Authorization.Test.csproj | 2 +- ...ft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj | 2 +- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 2 +- .../Microsoft.Owin.Security.Interop.Test.csproj | 2 +- 25 files changed, 38 insertions(+), 39 deletions(-) create mode 100644 build/dependencies.props diff --git a/build/common.props b/build/common.props index 7ce50d277a..52413444ee 100644 --- a/build/common.props +++ b/build/common.props @@ -1,4 +1,5 @@ + @@ -8,8 +9,6 @@ $(MSBuildThisFileDirectory)Key.snk true true - 1.2.0-* - 1.6.2-* $(VersionSuffix)-$(BuildNumber) @@ -20,5 +19,5 @@ - - \ No newline at end of file + + diff --git a/build/dependencies.props b/build/dependencies.props new file mode 100644 index 0000000000..e704edaec0 --- /dev/null +++ b/build/dependencies.props @@ -0,0 +1,6 @@ + + + 1.6.1 + 4.3.0 + + diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index e9987f3a86..a2cab9171e 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,11 +1,10 @@ - + net451;netcoreapp1.1 Exe win7-x64 - 1.2.0-* diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 62bb9f4a9f..aa5f0ca272 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,11 +1,10 @@ - + net451;netcoreapp1.1 Exe win7-x64 - 1.2.0-* diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 83c0c643d7..790bd0827b 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,4 +1,4 @@ - + 1.1.0 @@ -7,7 +7,6 @@ win7-x64 Exe aspnet5-JwtBearerSample-20151210102827 - 1.2.0-* diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 6cb421a2a0..8c8c3f2b18 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,11 +1,10 @@ - + net451;netcoreapp1.1 Exe win7-x64 aspnet5-OpenIdConnectSample-20151210110318 - 1.2.0-* @@ -18,4 +17,4 @@ - \ No newline at end of file + diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index acbae28b43..5a9683f6cb 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,4 +1,4 @@ - + net451;netcoreapp1.1 @@ -6,7 +6,6 @@ win7-x64 aspnet5-OpenIdConnectSample-20151210110318 - 1.2.0-* diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 1c137b6d5c..30f0742dea 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,4 +1,4 @@ - + net451;netcoreapp1.1 @@ -6,7 +6,6 @@ win7-x64 aspnet5-SocialSample-20151210111056 - 1.2.0-* diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 01f5b635d1..0d7dd04303 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index 7d7e3ad043..6be798cc19 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index 30545dd69b..dc6ef94d64 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 1e8ecac61e..518526d419 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -1,4 +1,4 @@ - + ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. @@ -12,4 +12,4 @@ - \ No newline at end of file + diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 559b78a3c9..5f9a5bb3e4 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 3a0ad122c5..e40377c09f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -1,4 +1,4 @@ - + @@ -17,7 +17,7 @@ - + - \ No newline at end of file + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index aa44423133..e5665f579b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -1,4 +1,4 @@ - + ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. @@ -12,4 +12,4 @@ - \ No newline at end of file + diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 0368a8be0e..78557532c5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index e93061de63..3b5c7d6314 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 6a1c60f94a..d1360f868c 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -1,4 +1,4 @@ - + @@ -20,7 +20,7 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute - + diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 2f5b094c07..862ab2ac72 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index 4c6cb7a834..153eb6ae9f 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -1,4 +1,4 @@ - + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 0a9adfd437..66d9dfed6c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -1,4 +1,4 @@ - + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 62b041f372..b57e099048 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -1,4 +1,4 @@ - + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 672309b928..f5ca9c2d3e 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -1,4 +1,4 @@ - + diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index 91e98ad986..f0a8a28d90 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -1,4 +1,4 @@ - + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 408703450c..09433d2994 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -1,4 +1,4 @@ - + From 591a2b0e6b1093afc046a1e382d2931c4219f5e0 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 16 Feb 2017 11:23:03 -0800 Subject: [PATCH 686/900] React to aspnet/KoreBuild#160 --- build/repo.props | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 build/repo.props diff --git a/build/repo.props b/build/repo.props new file mode 100644 index 0000000000..d4bab3eebd --- /dev/null +++ b/build/repo.props @@ -0,0 +1,5 @@ + + + + + From 7637f2ea44c7f296623615ecab0370048155958f Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Wed, 15 Feb 2017 19:29:55 -0800 Subject: [PATCH 687/900] Bump test projects up to .NET 4.5.2 - aspnet/Testing#248 - xUnit no longer supports .NET 4.5.1 - target .NET 4.6.1 in Microsoft.Owin.Security.Interop.Test; avoids .NET 4.5.2 System.Xml casing issue - build tests for desktop .NET only on Windows - except Microsoft.Owin.Security.Interop.Test; already skipped using repo.props - enable binding redirects for one test project --- .../Microsoft.AspNetCore.Authentication.Test.csproj | 3 ++- .../Microsoft.AspNetCore.Authorization.Test.csproj | 3 ++- ...osoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj | 3 ++- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 3 ++- .../Microsoft.Owin.Security.Interop.Test.csproj | 4 +++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 66d9dfed6c..446469ba46 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -3,7 +3,8 @@ - netcoreapp1.1;net451 + netcoreapp1.1;net452 + netcoreapp1.1 diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index b57e099048..5eaa318a3d 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -3,7 +3,8 @@ - netcoreapp1.1;net451 + netcoreapp1.1;net452 + netcoreapp1.1 diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index f5ca9c2d3e..0cf30727b6 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -3,7 +3,8 @@ - netcoreapp1.1;net451 + netcoreapp1.1;net452 + netcoreapp1.1 diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index f0a8a28d90..aa00d90e0a 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -3,7 +3,8 @@ - netcoreapp1.1;net451 + netcoreapp1.1;net452 + netcoreapp1.1 diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 09433d2994..635fffe331 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -3,7 +3,9 @@ - net451 + net461 + true + true From ad425163b29b1e09a41e84423b0dcbac797c9164 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 14 Feb 2017 16:19:55 -0800 Subject: [PATCH 688/900] #969 Make social auth claims mapping more configurable #1024 Remove OIDC protocol claims --- samples/SocialSample/Startup.cs | 71 ++---- .../FacebookHandler.cs | 85 +------- .../FacebookHelper.cs | 206 ------------------ .../FacebookOptions.cs | 17 ++ .../GoogleHandler.cs | 37 +--- .../GoogleHelper.cs | 80 ------- .../GoogleOptions.cs | 9 + .../MicrosoftAccountHandler.cs | 34 +-- .../MicrosoftAccountHelper.cs | 81 ------- .../MicrosoftAccountOptions.cs | 10 +- .../Claims/ClaimAction.cs | 42 ++++ .../Claims/ClaimActionCollection.cs | 52 +++++ .../ClaimActionCollectionMapExtensions.cs | 100 +++++++++ .../Claims/CustomJsonClaimAction.cs | 46 ++++ .../Claims/DeleteClaimAction.cs | 33 +++ .../Claims/JsonKeyClaimAction.cs | 42 ++++ .../Claims/JsonSubKeyClaimAction.cs | 58 +++++ .../Events/OAuthCreatingTicketContext.cs | 18 ++ .../OAuthHandler.cs | 3 +- .../OAuthOptions.cs | 7 +- .../ClaimActionCollectionUniqueExtensions.cs | 39 ++++ .../Claims/UniqueJsonKeyClaimAction.cs | 61 ++++++ ...etCore.Authentication.OpenIdConnect.csproj | 2 +- .../OpenIdConnectHandler.cs | 34 +-- .../OpenIdConnectOptions.cs | 33 ++- .../Utility/ClaimsHelper.cs | 81 ------- .../Events/TwitterCreatingTicketContext.cs | 1 + ...t.AspNetCore.Authentication.Twitter.csproj | 3 +- .../TwitterHandler.cs | 11 +- .../TwitterOptions.cs | 10 +- .../Google/GoogleMiddlewareTests.cs | 10 +- ...soft.AspNetCore.Authentication.Test.csproj | 4 + ...osoft.AspNetCore.Authorization.Test.csproj | 4 + ....ChunkingCookieManager.Sources.Test.csproj | 4 + ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 4 + 35 files changed, 637 insertions(+), 695 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollection.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Claims/CustomJsonClaimAction.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Claims/DeleteClaimAction.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonSubKeyClaimAction.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/ClaimActionCollectionUniqueExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/UniqueJsonKeyClaimAction.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 4c0faaa16f..42ce6a29db 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -112,7 +112,7 @@ namespace SocialSample // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project - app.UseGoogleAuthentication(new GoogleOptions + var googleOptions = new GoogleOptions { ClientId = Configuration["google:clientid"], ClientSecret = Configuration["google:clientsecret"], @@ -126,11 +126,14 @@ namespace SocialSample return Task.FromResult(0); } } - }); + }; + googleOptions.ClaimActions.MapJsonSubKey("urn:google:image", "image", "url"); + googleOptions.ClaimActions.Remove(ClaimTypes.GivenName); + app.UseGoogleAuthentication(googleOptions); // You must first create an app with Twitter and add its key and Secret to your user-secrets. // https://apps.twitter.com/ - app.UseTwitterAuthentication(new TwitterOptions + var twitterOptions = new TwitterOptions { ConsumerKey = Configuration["twitter:consumerkey"], ConsumerSecret = Configuration["twitter:consumersecret"], @@ -140,12 +143,6 @@ namespace SocialSample SaveTokens = true, Events = new TwitterEvents() { - OnCreatingTicket = ctx => - { - var profilePic = ctx.User.Value("profile_image_url"); - ctx.Principal.Identities.First().AddClaim(new Claim("urn:twitter:profilepicture", profilePic, ClaimTypes.Uri, ctx.Options.ClaimsIssuer)); - return Task.FromResult(0); - }, OnRemoteFailure = ctx => { ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); @@ -153,7 +150,9 @@ namespace SocialSample return Task.FromResult(0); } } - }); + }; + twitterOptions.ClaimActions.MapJsonKey("urn:twitter:profilepicture", "profile_image_url", ClaimTypes.Uri); + app.UseTwitterAuthentication(twitterOptions); /* Azure AD app model v2 has restrictions that prevent the use of plain HTTP for redirect URLs. Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL: @@ -200,7 +199,7 @@ namespace SocialSample // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ - app.UseOAuthAuthentication(new OAuthOptions + var githubOptions = new OAuthOptions { AuthenticationScheme = "GitHub", DisplayName = "Github", @@ -227,48 +226,16 @@ namespace SocialSample var user = JObject.Parse(await response.Content.ReadAsStringAsync()); - var identifier = user.Value("id"); - if (!string.IsNullOrEmpty(identifier)) - { - context.Identity.AddClaim(new Claim( - ClaimTypes.NameIdentifier, identifier, - ClaimValueTypes.String, context.Options.ClaimsIssuer)); - } - - var userName = user.Value("login"); - if (!string.IsNullOrEmpty(userName)) - { - context.Identity.AddClaim(new Claim( - ClaimsIdentity.DefaultNameClaimType, userName, - ClaimValueTypes.String, context.Options.ClaimsIssuer)); - } - - var name = user.Value("name"); - if (!string.IsNullOrEmpty(name)) - { - context.Identity.AddClaim(new Claim( - "urn:github:name", name, - ClaimValueTypes.String, context.Options.ClaimsIssuer)); - } - - var email = user.Value("email"); - if (!string.IsNullOrEmpty(email)) - { - context.Identity.AddClaim(new Claim( - ClaimTypes.Email, email, - ClaimValueTypes.Email, context.Options.ClaimsIssuer)); - } - - var link = user.Value("url"); - if (!string.IsNullOrEmpty(link)) - { - context.Identity.AddClaim(new Claim( - "urn:github:url", link, - ClaimValueTypes.String, context.Options.ClaimsIssuer)); - } + context.RunClaimActions(user); } } - }); + }; + githubOptions.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); + githubOptions.ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); + githubOptions.ClaimActions.MapJsonKey("urn:github:name", "name"); + githubOptions.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); + githubOptions.ClaimActions.MapJsonKey("urn:github:url", "url"); + app.UseOAuthAuthentication(githubOptions); // Choose an authentication type app.Map("/login", signoutApp => @@ -357,7 +324,7 @@ namespace SocialSample } await context.Response.WriteAsync("Tokens:
"); - + await context.Response.WriteAsync("Access Token: " + await context.Authentication.GetTokenAsync("access_token") + "
"); await context.Response.WriteAsync("Refresh Token: " + await context.Authentication.GetTokenAsync("refresh_token") + "
"); await context.Response.WriteAsync("Token Type: " + await context.Authentication.GetTokenAsync("token_type") + "
"); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index be1c8f8f83..3c3c14c86f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -45,90 +45,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Options.AuthenticationScheme); var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens, payload); - - var identifier = FacebookHelper.GetId(payload); - if (!string.IsNullOrEmpty(identifier)) - { - identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, identifier, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var ageRangeMin = FacebookHelper.GetAgeRangeMin(payload); - if (!string.IsNullOrEmpty(ageRangeMin)) - { - identity.AddClaim(new Claim("urn:facebook:age_range_min", ageRangeMin, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var ageRangeMax = FacebookHelper.GetAgeRangeMax(payload); - if (!string.IsNullOrEmpty(ageRangeMax)) - { - identity.AddClaim(new Claim("urn:facebook:age_range_max", ageRangeMax, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var birthday = FacebookHelper.GetBirthday(payload); - if (!string.IsNullOrEmpty(birthday)) - { - identity.AddClaim(new Claim(ClaimTypes.DateOfBirth, birthday, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var email = FacebookHelper.GetEmail(payload); - if (!string.IsNullOrEmpty(email)) - { - identity.AddClaim(new Claim(ClaimTypes.Email, email, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var firstName = FacebookHelper.GetFirstName(payload); - if (!string.IsNullOrEmpty(firstName)) - { - identity.AddClaim(new Claim(ClaimTypes.GivenName, firstName, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var gender = FacebookHelper.GetGender(payload); - if (!string.IsNullOrEmpty(gender)) - { - identity.AddClaim(new Claim(ClaimTypes.Gender, gender, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var lastName = FacebookHelper.GetLastName(payload); - if (!string.IsNullOrEmpty(lastName)) - { - identity.AddClaim(new Claim(ClaimTypes.Surname, lastName, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var link = FacebookHelper.GetLink(payload); - if (!string.IsNullOrEmpty(link)) - { - identity.AddClaim(new Claim("urn:facebook:link", link, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var location = FacebookHelper.GetLocation(payload); - if (!string.IsNullOrEmpty(location)) - { - identity.AddClaim(new Claim("urn:facebook:location", location, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var locale = FacebookHelper.GetLocale(payload); - if (!string.IsNullOrEmpty(locale)) - { - identity.AddClaim(new Claim(ClaimTypes.Locality, locale, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var middleName = FacebookHelper.GetMiddleName(payload); - if (!string.IsNullOrEmpty(middleName)) - { - identity.AddClaim(new Claim("urn:facebook:middle_name", middleName, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var name = FacebookHelper.GetName(payload); - if (!string.IsNullOrEmpty(name)) - { - identity.AddClaim(new Claim(ClaimTypes.Name, name, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var timeZone = FacebookHelper.GetTimeZone(payload); - if (!string.IsNullOrEmpty(timeZone)) - { - identity.AddClaim(new Claim("urn:facebook:timezone", timeZone, ClaimValueTypes.String, Options.ClaimsIssuer)); - } + context.RunClaimActions(); await Options.Events.CreatingTicket(context); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs deleted file mode 100644 index 48e3590990..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHelper.cs +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Newtonsoft.Json.Linq; - -namespace Microsoft.AspNetCore.Authentication.Facebook -{ - /// - /// Contains static methods that allow to extract user's information from a - /// instance retrieved from Facebook after a successful authentication process. - /// - public static class FacebookHelper - { - /// - /// Gets the Facebook user ID. - /// - public static string GetId(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("id"); - } - - /// - /// Gets the user's min age. - /// - public static string GetAgeRangeMin(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - return TryGetValue(user, "age_range", "min"); - } - - /// - /// Gets the user's max age. - /// - public static string GetAgeRangeMax(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return TryGetValue(user, "age_range", "max"); - } - - /// - /// Gets the user's birthday. - /// - public static string GetBirthday(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - return user.Value("birthday"); - } - - /// - /// Gets the Facebook email. - /// - public static string GetEmail(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("email"); - } - - /// - /// Gets the user's first name. - /// - public static string GetFirstName(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("first_name"); - } - - /// - /// Gets the user's gender. - /// - public static string GetGender(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - return user.Value("gender"); - } - - /// - /// Gets the user's family name. - /// - public static string GetLastName(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("last_name"); - } - - /// - /// Gets the user's link. - /// - public static string GetLink(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - return user.Value("link"); - } - - /// - /// Gets the user's location. - /// - public static string GetLocation(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - return TryGetValue(user, "location", "name"); - } - - /// - /// Gets the user's locale. - /// - public static string GetLocale(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - return user.Value("locale"); - } - - /// - /// Gets the user's middle name. - /// - public static string GetMiddleName(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("middle_name"); - } - - /// - /// Gets the user's name. - /// - public static string GetName(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("name"); - } - - /// - /// Gets the user's timezone. - /// - public static string GetTimeZone(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - return user.Value("timezone"); - } - - // Get the given subProperty from a property. - private static string TryGetValue(JObject user, string propertyName, string subProperty) - { - JToken value; - if (user.TryGetValue(propertyName, out value)) - { - var subObject = JObject.Parse(value.ToString()); - if (subObject != null && subObject.TryGetValue(subProperty, out value)) - { - return value.ToString(); - } - } - return null; - } - - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs index 8e86b37c1f..ae875bfafb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using System.Security.Claims; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Facebook; using Microsoft.AspNetCore.Http; @@ -30,6 +32,21 @@ namespace Microsoft.AspNetCore.Builder Fields.Add("email"); Fields.Add("first_name"); Fields.Add("last_name"); + + ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); + ClaimActions.MapJsonSubKey("urn:facebook:age_range_min", "age_range", "min"); + ClaimActions.MapJsonSubKey("urn:facebook:age_range_max", "age_range", "max"); + ClaimActions.MapJsonKey(ClaimTypes.DateOfBirth, "birthday"); + ClaimActions.MapJsonKey(ClaimTypes.Email, "email"); + ClaimActions.MapJsonKey(ClaimTypes.Name, "name"); + ClaimActions.MapJsonKey(ClaimTypes.GivenName, "first_name"); + ClaimActions.MapJsonKey("urn:facebook:middle_name", "middle_name"); + ClaimActions.MapJsonKey(ClaimTypes.Surname, "last_name"); + ClaimActions.MapJsonKey(ClaimTypes.Gender, "gender"); + ClaimActions.MapJsonKey("urn:facebook:link", "link"); + ClaimActions.MapJsonSubKey("urn:facebook:location", "location", "name"); + ClaimActions.MapJsonKey(ClaimTypes.Locality, "locale"); + ClaimActions.MapJsonKey("urn:facebook:timezone", "timezone"); } // Facebook uses a non-standard term for this field. diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index f28ab4d14a..87506e080f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -42,42 +42,7 @@ namespace Microsoft.AspNetCore.Authentication.Google var principal = new ClaimsPrincipal(identity); var ticket = new AuthenticationTicket(principal, properties, Options.AuthenticationScheme); var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens, payload); - - var identifier = GoogleHelper.GetId(payload); - if (!string.IsNullOrEmpty(identifier)) - { - identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, identifier, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var givenName = GoogleHelper.GetGivenName(payload); - if (!string.IsNullOrEmpty(givenName)) - { - identity.AddClaim(new Claim(ClaimTypes.GivenName, givenName, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var familyName = GoogleHelper.GetFamilyName(payload); - if (!string.IsNullOrEmpty(familyName)) - { - identity.AddClaim(new Claim(ClaimTypes.Surname, familyName, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var name = GoogleHelper.GetName(payload); - if (!string.IsNullOrEmpty(name)) - { - identity.AddClaim(new Claim(ClaimTypes.Name, name, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var email = GoogleHelper.GetEmail(payload); - if (!string.IsNullOrEmpty(email)) - { - identity.AddClaim(new Claim(ClaimTypes.Email, email, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var profile = GoogleHelper.GetProfile(payload); - if (!string.IsNullOrEmpty(profile)) - { - identity.AddClaim(new Claim("urn:google:profile", profile, ClaimValueTypes.String, Options.ClaimsIssuer)); - } + context.RunClaimActions(); await Options.Events.CreatingTicket(context); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs index 336536c512..2cac949a03 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs @@ -12,71 +12,6 @@ namespace Microsoft.AspNetCore.Authentication.Google ///
public static class GoogleHelper { - /// - /// Gets the Google user ID. - /// - public static string GetId(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("id"); - } - - /// - /// Gets the user's name. - /// - public static string GetName(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("displayName"); - } - - /// - /// Gets the user's given name. - /// - public static string GetGivenName(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return TryGetValue(user, "name", "givenName"); - } - - /// - /// Gets the user's family name. - /// - public static string GetFamilyName(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return TryGetValue(user, "name", "familyName"); - } - - /// - /// Gets the user's profile link. - /// - public static string GetProfile(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("url"); - } - /// /// Gets the user's email. /// @@ -90,21 +25,6 @@ namespace Microsoft.AspNetCore.Authentication.Google return TryGetFirstValue(user, "emails", "value"); } - // Get the given subProperty from a property. - private static string TryGetValue(JObject user, string propertyName, string subProperty) - { - JToken value; - if (user.TryGetValue(propertyName, out value)) - { - var subObject = JObject.Parse(value.ToString()); - if (subObject != null && subObject.TryGetValue(subProperty, out value)) - { - return value.ToString(); - } - } - return null; - } - // Get the given subProperty from a list property. private static string TryGetFirstValue(JObject user, string propertyName, string subProperty) { diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs index 3d93b96ea8..d269779703 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs @@ -1,6 +1,8 @@ // 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.Security.Claims; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Google; using Microsoft.AspNetCore.Http; @@ -25,6 +27,13 @@ namespace Microsoft.AspNetCore.Builder Scope.Add("openid"); Scope.Add("profile"); Scope.Add("email"); + + ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); + ClaimActions.MapJsonKey(ClaimTypes.Name, "displayName"); + ClaimActions.MapJsonSubKey(ClaimTypes.GivenName, "name", "givenName"); + ClaimActions.MapJsonSubKey(ClaimTypes.Surname, "name", "familyName"); + ClaimActions.MapJsonKey("urn:google:profile", "url"); + ClaimActions.MapCustomJson(ClaimTypes.Email, GoogleHelper.GetEmail); } /// diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 21f567d15e..2426cafe07 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -35,39 +35,7 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Options.AuthenticationScheme); var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens, payload); - var identifier = MicrosoftAccountHelper.GetId(payload); - if (!string.IsNullOrEmpty(identifier)) - { - identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, identifier, ClaimValueTypes.String, Options.ClaimsIssuer)); - identity.AddClaim(new Claim("urn:microsoftaccount:id", identifier, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var name = MicrosoftAccountHelper.GetDisplayName(payload); - if (!string.IsNullOrEmpty(name)) - { - identity.AddClaim(new Claim(ClaimTypes.Name, name, ClaimValueTypes.String, Options.ClaimsIssuer)); - identity.AddClaim(new Claim("urn:microsoftaccount:name", name, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var givenName = MicrosoftAccountHelper.GetGivenName(payload); - if (!string.IsNullOrEmpty(givenName)) - { - identity.AddClaim(new Claim(ClaimTypes.GivenName, givenName, ClaimValueTypes.String, Options.ClaimsIssuer)); - identity.AddClaim(new Claim("urn:microsoftaccount:givenname", givenName, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var surname = MicrosoftAccountHelper.GetSurname(payload); - if (!string.IsNullOrEmpty(surname)) - { - identity.AddClaim(new Claim(ClaimTypes.Surname, surname, ClaimValueTypes.String, Options.ClaimsIssuer)); - identity.AddClaim(new Claim("urn:microsoftaccount:surname", surname, ClaimValueTypes.String, Options.ClaimsIssuer)); - } - - var email = MicrosoftAccountHelper.GetEmail(payload); - if (!string.IsNullOrEmpty(email)) - { - identity.AddClaim(new Claim(ClaimTypes.Email, email, ClaimValueTypes.String, Options.ClaimsIssuer)); - } + context.RunClaimActions(); await Options.Events.CreatingTicket(context); return context.Ticket; diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs deleted file mode 100644 index cce8dcc73b..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHelper.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Newtonsoft.Json.Linq; - -namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount -{ - /// - /// Contains static methods that allow to extract user's information from a - /// instance retrieved from Microsoft after a successful authentication process. - /// http://graph.microsoft.io/en-us/docs/api-reference/v1.0/resources/user - /// - public static class MicrosoftAccountHelper - { - /// - /// Gets the Microsoft Account user ID. - /// - public static string GetId(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("id"); - } - - /// - /// Gets the user's name. - /// - public static string GetDisplayName(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("displayName"); - } - - /// - /// Gets the user's given name. - /// - public static string GetGivenName(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("givenName"); - } - - /// - /// Gets the user's surname. - /// - public static string GetSurname(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("surname"); - } - - /// - /// Gets the user's email address. - /// - public static string GetEmail(JObject user) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - return user.Value("mail") ?? user.Value("userPrincipalName"); - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs index 625d4baf9c..1aa4009a56 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -1,8 +1,10 @@ // 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.AspNetCore.Http; +using System.Security.Claims; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; +using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Builder { @@ -23,6 +25,12 @@ namespace Microsoft.AspNetCore.Builder TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; UserInformationEndpoint = MicrosoftAccountDefaults.UserInformationEndpoint; Scope.Add("https://graph.microsoft.com/user.read"); + + ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); + ClaimActions.MapJsonKey(ClaimTypes.Name, "displayName"); + ClaimActions.MapJsonKey(ClaimTypes.GivenName, "givenName"); + ClaimActions.MapJsonKey(ClaimTypes.Surname, "surname"); + ClaimActions.MapCustomJson(ClaimTypes.Email, user => user.Value("mail") ?? user.Value("userPrincipalName")); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs new file mode 100644 index 0000000000..965ca5fdb3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs @@ -0,0 +1,42 @@ +// 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.Security.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication.OAuth.Claims +{ + /// + /// Infrastructure for mapping user data from a json structure to claims on the ClaimsIdentity. + /// + public abstract class ClaimAction + { + /// + /// Create a new claim manipulation action. + /// + /// The value to use for Claim.Type when creating a Claim. + /// The value to use for Claim.ValueType when creating a Claim. + public ClaimAction(string claimType, string valueType) + { + ClaimType = claimType; + ValueType = valueType; + } + + /// + /// The value to use for Claim.Type when creating a Claim. + /// + public string ClaimType { get; } + + // The value to use for Claim.ValueType when creating a Claim. + public string ValueType { get; } + + /// + /// Exhamine the given userData json, determine if the requisite data is present, and optionally add it + /// as a new Claim on the ClaimsIdentity. + /// + /// The source data to exhamine. This value may be null. + /// The identity to add Claims to. + /// The value to use for Claim.Issuer when creating a Claim. + public abstract void Run(JObject userData, ClaimsIdentity identity, string issuer); + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollection.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollection.cs new file mode 100644 index 0000000000..63da155d7c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollection.cs @@ -0,0 +1,52 @@ +// 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.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.AspNetCore.Authentication.OAuth.Claims +{ + /// + /// A collection of ClaimActions used when mapping user data to Claims. + /// + public class ClaimActionCollection : IEnumerable + { + private IList Actions { get; } = new List(); + + /// + /// Remove all claim actions. + /// + public void Clear() => Actions.Clear(); + + /// + /// Remove all claim actions for the given ClaimType. + /// + /// The ClaimType of maps to remove. + public void Remove(string claimType) + { + var itemsToRemove = Actions.Where(map => string.Equals(claimType, map.ClaimType, StringComparison.OrdinalIgnoreCase)).ToList(); + itemsToRemove.ForEach(map => Actions.Remove(map)); + } + + /// + /// Add a claim action to the collection. + /// + /// The claim action to add. + public void Add(ClaimAction action) + { + Actions.Add(action); + } + + public IEnumerator GetEnumerator() + { + return Actions.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return Actions.GetEnumerator(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs new file mode 100644 index 0000000000..f3fee6a229 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs @@ -0,0 +1,100 @@ +// 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.Security.Claims; +using Microsoft.AspNetCore.Authentication.OAuth.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication +{ + public static class ClaimActionCollectionMapExtensions + { + /// + /// Select a top level value from the json user data with the given key name and add it as a Claim. + /// This no-ops if the key is not found or the value is empty. + /// + /// + /// The value to use for Claim.Type when creating a Claim. + /// The top level key to look for in the json user data. + public static void MapJsonKey(this ClaimActionCollection collection, string claimType, string jsonKey) + { + collection.MapJsonKey(claimType, jsonKey, ClaimValueTypes.String); + } + + /// + /// Select a top level value from the json user data with the given key name and add it as a Claim. + /// This no-ops if the key is not found or the value is empty. + /// + /// + /// The value to use for Claim.Type when creating a Claim. + /// The top level key to look for in the json user data. + /// The value to use for Claim.ValueType when creating a Claim. + public static void MapJsonKey(this ClaimActionCollection collection, string claimType, string jsonKey, string valueType) + { + collection.Add(new JsonKeyClaimAction(claimType, valueType, jsonKey)); + } + + /// + /// Select a second level value from the json user data with the given top level key name and second level sub key name and add it as a Claim. + /// This no-ops if the keys are not found or the value is empty. + /// + /// + /// The value to use for Claim.Type when creating a Claim. + /// The top level key to look for in the json user data. + /// The second level key to look for in the json user data. + public static void MapJsonSubKey(this ClaimActionCollection collection, string claimType, string jsonKey, string subKey) + { + collection.MapJsonSubKey(claimType, jsonKey, subKey, ClaimValueTypes.String); + } + + /// + /// Select a second level value from the json user data with the given top level key name and second level sub key name and add it as a Claim. + /// This no-ops if the keys are not found or the value is empty. + /// + /// + /// The value to use for Claim.Type when creating a Claim. + /// The top level key to look for in the json user data. + /// The second level key to look for in the json user data. + /// The value to use for Claim.ValueType when creating a Claim. + public static void MapJsonSubKey(this ClaimActionCollection collection, string claimType, string jsonKey, string subKey, string valueType) + { + collection.Add(new JsonSubKeyClaimAction(claimType, valueType, jsonKey, subKey)); + } + + /// + /// Run the given resolver to select a value from the json user data to add as a claim. + /// This no-ops if the returned value is empty. + /// + /// + /// The value to use for Claim.Type when creating a Claim. + /// The Func that will be called to select value from the given json user data. + public static void MapCustomJson(this ClaimActionCollection collection, string claimType, Func resolver) + { + collection.MapCustomJson(claimType, ClaimValueTypes.String, resolver); + } + + /// + /// Run the given resolver to select a value from the json user data to add as a claim. + /// This no-ops if the returned value is empty. + /// + /// + /// The value to use for Claim.Type when creating a Claim. + /// The value to use for Claim.ValueType when creating a Claim. + /// The Func that will be called to select value from the given json user data. + public static void MapCustomJson(this ClaimActionCollection collection, string claimType, string valueType, Func resolver) + { + collection.Add(new CustomJsonClaimAction(claimType, valueType, resolver)); + } + + /// + /// Delete all claims from the given ClaimsIdentity with the given ClaimType. + /// + /// + /// + public static void DeleteClaim(this ClaimActionCollection collection, string claimType) + { + collection.Add(new DeleteClaimAction(claimType)); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/CustomJsonClaimAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/CustomJsonClaimAction.cs new file mode 100644 index 0000000000..21a4f70e12 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/CustomJsonClaimAction.cs @@ -0,0 +1,46 @@ +// 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.Security.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication.OAuth.Claims +{ + /// + /// A ClaimAction that selects the value from the json user data by running the given Func resolver. + /// + public class CustomJsonClaimAction : ClaimAction + { + /// + /// Creates a new CustomJsonClaimAction. + /// + /// The value to use for Claim.Type when creating a Claim. + /// The value to use for Claim.ValueType when creating a Claim. + /// The Func that will be called to select value from the given json user data. + public CustomJsonClaimAction(string claimType, string valueType, Func resolver) + : base(claimType, valueType) + { + Resolver = resolver; + } + + /// + /// The Func that will be called to select value from the given json user data. + /// + public Func Resolver { get; } + + /// + public override void Run(JObject userData, ClaimsIdentity identity, string issuer) + { + if (userData == null) + { + return; + } + var value = Resolver(userData); + if (!string.IsNullOrEmpty(value)) + { + identity.AddClaim(new Claim(ClaimType, value, ValueType, issuer)); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/DeleteClaimAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/DeleteClaimAction.cs new file mode 100644 index 0000000000..75167cabcb --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/DeleteClaimAction.cs @@ -0,0 +1,33 @@ +// 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.Linq; +using System.Security.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication.OAuth.Claims +{ + /// + /// A ClaimAction that deletes all claims from the given ClaimsIdentity with the given ClaimType. + /// + public class DeleteClaimAction : ClaimAction + { + /// + /// Creates a new DeleteClaimAction. + /// + /// The ClaimType of Claims to delete. + public DeleteClaimAction(string claimType) + : base(claimType, ClaimValueTypes.String) + { + } + + /// + public override void Run(JObject userData, ClaimsIdentity identity, string issuer) + { + foreach (var claim in identity.FindAll(ClaimType).ToList()) + { + identity.TryRemoveClaim(claim); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs new file mode 100644 index 0000000000..e628904de5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs @@ -0,0 +1,42 @@ +// 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.Security.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication.OAuth.Claims +{ + /// + /// A ClaimAction that selects a top level value from the json user data with the given key name and adds it as a Claim. + /// This no-ops if the key is not found or the value is empty. + /// + public class JsonKeyClaimAction : ClaimAction + { + /// + /// Creates a new JsonKeyClaimAction. + /// + /// The value to use for Claim.Type when creating a Claim. + /// The value to use for Claim.ValueType when creating a Claim. + /// The top level key to look for in the json user data. + public JsonKeyClaimAction(string claimType, string valueType, string jsonKey) + : base(claimType, valueType) + { + JsonKey = jsonKey; + } + + /// + /// The top level key to look for in the json user data. + /// + public string JsonKey { get; } + + /// + public override void Run(JObject userData, ClaimsIdentity identity, string issuer) + { + var value = userData?.Value(JsonKey); + if (!string.IsNullOrEmpty(value)) + { + identity.AddClaim(new Claim(ClaimType, value, ValueType, issuer)); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonSubKeyClaimAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonSubKeyClaimAction.cs new file mode 100644 index 0000000000..bc29672d0f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonSubKeyClaimAction.cs @@ -0,0 +1,58 @@ +// 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 Newtonsoft.Json.Linq; +using System.Security.Claims; + +namespace Microsoft.AspNetCore.Authentication.OAuth.Claims +{ + /// + /// A ClaimAction that selects a second level value from the json user data with the given top level key + /// name and second level sub key name and add it as a Claim. + /// This no-ops if the keys are not found or the value is empty. + /// + public class JsonSubKeyClaimAction : JsonKeyClaimAction + { + /// + /// Creates a new JsonSubKeyClaimAction. + /// + /// The value to use for Claim.Type when creating a Claim. + /// The value to use for Claim.ValueType when creating a Claim. + /// The top level key to look for in the json user data. + /// The second level key to look for in the json user data. + public JsonSubKeyClaimAction(string claimType, string valueType, string jsonKey, string subKey) + : base(claimType, valueType, jsonKey) + { + SubKey = subKey; + } + + /// + /// The second level key to look for in the json user data. + /// + public string SubKey { get; } + + /// + public override void Run(JObject userData, ClaimsIdentity identity, string issuer) + { + var value = GetValue(userData, JsonKey, SubKey); + if (!string.IsNullOrEmpty(value)) + { + identity.AddClaim(new Claim(ClaimType, value, ValueType, issuer)); + } + } + + // Get the given subProperty from a property. + private static string GetValue(JObject userData, string propertyName, string subProperty) + { + if (userData != null && userData.TryGetValue(propertyName, out var value)) + { + var subObject = JObject.Parse(value.ToString()); + if (subObject != null && subObject.TryGetValue(subProperty, out value)) + { + return value.ToString(); + } + } + return null; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs index 15f9c91c74..b17d23c9bb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -144,5 +144,23 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// This property returns null when is null. /// public ClaimsIdentity Identity => Ticket?.Principal.Identity as ClaimsIdentity; + + public void RunClaimActions() + { + RunClaimActions(User); + } + + public void RunClaimActions(JObject userData) + { + if (userData == null) + { + throw new ArgumentNullException(nameof(userData)); + } + + foreach (var action in Options.ClaimActions) + { + action.Run(userData, Identity, Options.ClaimsIssuer); + } + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 1c5143842f..a5c36c1c45 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -11,11 +11,10 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; -using Microsoft.AspNetCore.WebUtilities; namespace Microsoft.AspNetCore.Authentication.OAuth { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs index 9591d9c44d..9bd08dfd84 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; -using System.ComponentModel; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Builder @@ -55,6 +55,11 @@ namespace Microsoft.AspNetCore.Builder set { base.Events = value; } } + /// + /// A collection of claim actions used to select values from the json user data and create Claims. + /// + public ClaimActionCollection ClaimActions { get; } = new ClaimActionCollection(); + /// /// Gets the list of permissions to request. /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/ClaimActionCollectionUniqueExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/ClaimActionCollectionUniqueExtensions.cs new file mode 100644 index 0000000000..4e349579f3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/ClaimActionCollectionUniqueExtensions.cs @@ -0,0 +1,39 @@ +// 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.Security.Claims; +using Microsoft.AspNetCore.Authentication.OAuth.Claims; +using Microsoft.AspNetCore.Authentication.OpenIdConnect.Claims; + +namespace Microsoft.AspNetCore.Authentication +{ + public static class ClaimActionCollectionUniqueExtensions + { + /// + /// Selects a top level value from the json user data with the given key name and adds it as a Claim. + /// This no-ops if the ClaimsIdentity already contains a Claim with the given ClaimType. + /// This no-ops if the key is not found or the value is empty. + /// + /// + /// The value to use for Claim.Type when creating a Claim. + /// The top level key to look for in the json user data. + public static void MapUniqueJsonKey(this ClaimActionCollection collection, string claimType, string jsonKey) + { + collection.MapUniqueJsonKey(claimType, jsonKey, ClaimValueTypes.String); + } + + /// + /// Selects a top level value from the json user data with the given key name and adds it as a Claim. + /// This no-ops if the ClaimsIdentity already contains a Claim with the given ClaimType. + /// This no-ops if the key is not found or the value is empty. + /// + /// + /// The value to use for Claim.Type when creating a Claim. + /// The top level key to look for in the json user data. + /// The value to use for Claim.ValueType when creating a Claim. + public static void MapUniqueJsonKey(this ClaimActionCollection collection, string claimType, string jsonKey, string valueType) + { + collection.Add(new UniqueJsonKeyClaimAction(claimType, valueType, jsonKey)); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/UniqueJsonKeyClaimAction.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/UniqueJsonKeyClaimAction.cs new file mode 100644 index 0000000000..132885b3ca --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/UniqueJsonKeyClaimAction.cs @@ -0,0 +1,61 @@ +// 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.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using Microsoft.AspNetCore.Authentication.OAuth.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect.Claims +{ + /// + /// A ClaimAction that selects a top level value from the json user data with the given key name and adds it as a Claim. + /// This no-ops if the ClaimsIdentity already contains a Claim with the given ClaimType. + /// This no-ops if the key is not found or the value is empty. + /// + public class UniqueJsonKeyClaimAction : JsonKeyClaimAction + { + /// + /// Creates a new UniqueJsonKeyClaimAction. + /// + /// The value to use for Claim.Type when creating a Claim. + /// The value to use for Claim.ValueType when creating a Claim. + /// The top level key to look for in the json user data. + public UniqueJsonKeyClaimAction(string claimType, string valueType, string jsonKey) + : base(claimType, valueType, jsonKey) + { + } + + /// + public override void Run(JObject userData, ClaimsIdentity identity, string issuer) + { + var value = userData?.Value(JsonKey); + if (string.IsNullOrEmpty(value)) + { + // Not found + return; + } + + var claim = identity.FindFirst(c => string.Equals(c.Type, JsonKey, System.StringComparison.OrdinalIgnoreCase)); + if (claim != null && string.Equals(claim.Value, value, System.StringComparison.Ordinal)) + { + // Duplicate + return; + } + + claim = identity.FindFirst(c => + { + // If this claimType is mapped by the JwtSeurityTokenHandler, then this property will be set + return c.Properties.TryGetValue(JwtSecurityTokenHandler.ShortClaimTypeProperty, out var shortType) + && string.Equals(shortType, JsonKey, System.StringComparison.OrdinalIgnoreCase); + }); + if (claim != null && string.Equals(claim.Value, value, System.StringComparison.Ordinal)) + { + // Duplicate with an alternate name. + return; + } + + identity.AddClaim(new Claim(ClaimType, value, ValueType, issuer)); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index e5665f579b..965a940e40 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -8,7 +8,7 @@ aspnetcore;authentication;security - + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index c9c513ea72..a7c20f62ea 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -661,6 +661,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { return await GetUserInformationAsync(tokenEndpointResponse ?? authorizationResponse, jwt, ticket); } + else + { + var identity = (ClaimsIdentity)ticket.Principal.Identity; + foreach (var action in Options.ClaimActions) + { + action.Run(null, identity, Options.ClaimsIssuer); + } + } return AuthenticateResult.Success(ticket); } @@ -727,7 +735,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // Error handling: // 1. If the response body can't be parsed as json, throws. - // 2. If the response's status code is not in 2XX range, throw OpenIdConnectProtocolException. If the body is correct parsed, + // 2. If the response's status code is not in 2XX range, throw OpenIdConnectProtocolException. If the body is correct parsed, // pass the error information from body to the exception. OpenIdConnectMessage message; try @@ -809,29 +817,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var identity = (ClaimsIdentity)ticket.Principal.Identity; - foreach (var claim in identity.Claims) + foreach (var action in Options.ClaimActions) { - // If this claimType is mapped by the JwtSeurityTokenHandler, then this property will be set - var shortClaimTypeName = claim.Properties.ContainsKey(JwtSecurityTokenHandler.ShortClaimTypeProperty) ? - claim.Properties[JwtSecurityTokenHandler.ShortClaimTypeProperty] : string.Empty; - - // checking if claim in the identity (generated from id_token) has the same type as a claim retrieved from userinfo endpoint - JToken value; - var isClaimIncluded = user.TryGetValue(claim.Type, out value) || user.TryGetValue(shortClaimTypeName, out value); - - // if a same claim exists (matching both type and value) both in id_token identity and userinfo response, remove the json entry from the userinfo response - if (isClaimIncluded && claim.Value.Equals(value.ToString(), StringComparison.Ordinal)) - { - if (!user.Remove(claim.Type)) - { - user.Remove(shortClaimTypeName); - } - } + action.Run(user, identity, Options.ClaimsIssuer); } - // adding remaining unique claims from userinfo endpoint to the identity - ClaimsHelper.AddClaimsToIdentity(user, identity, jwt.Issuer); - return AuthenticateResult.Success(ticket); } @@ -908,7 +898,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect ///
/// the nonce that we are looking for. /// echos 'nonce' if a cookie is found that matches, null otherwise. - /// Examine of that start with the prefix: 'OpenIdConnectAuthenticationDefaults.Nonce'. + /// Examine of that start with the prefix: 'OpenIdConnectAuthenticationDefaults.Nonce'. /// of is used to obtain the actual 'nonce'. If the nonce is found, then of is called. private string ReadNonceCookie(string nonce) { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index f0b26f75b2..a46c2956c6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -4,7 +4,9 @@ using System; using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; @@ -55,6 +57,30 @@ namespace Microsoft.AspNetCore.Builder Events = new OpenIdConnectEvents(); Scope.Add("openid"); Scope.Add("profile"); + + ClaimActions.DeleteClaim("nonce"); + ClaimActions.DeleteClaim("aud"); + ClaimActions.DeleteClaim("azp"); + ClaimActions.DeleteClaim("acr"); + ClaimActions.DeleteClaim("amr"); + ClaimActions.DeleteClaim("iss"); + ClaimActions.DeleteClaim("iat"); + ClaimActions.DeleteClaim("nbf"); + ClaimActions.DeleteClaim("exp"); + ClaimActions.DeleteClaim("at_hash"); + ClaimActions.DeleteClaim("c_hash"); + ClaimActions.DeleteClaim("auth_time"); + ClaimActions.DeleteClaim("ipaddr"); + ClaimActions.DeleteClaim("platf"); + ClaimActions.DeleteClaim("ver"); + + // http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims + ClaimActions.MapUniqueJsonKey("sub", "sub"); + ClaimActions.MapUniqueJsonKey("name", "name"); + ClaimActions.MapUniqueJsonKey("given_name", "given_name"); + ClaimActions.MapUniqueJsonKey("family_name", "family_name"); + ClaimActions.MapUniqueJsonKey("profile", "profile"); + ClaimActions.MapUniqueJsonKey("email", "email"); } /// @@ -90,6 +116,11 @@ namespace Microsoft.AspNetCore.Builder /// public bool GetClaimsFromUserInfoEndpoint { get; set; } + /// + /// A collection of claim actions used to select values from the json user data and create Claims. + /// + public ClaimActionCollection ClaimActions { get; } = new ClaimActionCollection(); + /// /// Gets or sets if HTTPS is required for the metadata address or authority. /// The default is true. This should be disabled only in development environments. @@ -112,7 +143,7 @@ namespace Microsoft.AspNetCore.Builder /// /// Gets or sets the that is used to ensure that the 'id_token' received - /// is valid per: http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation + /// is valid per: http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation /// /// if 'value' is null. public OpenIdConnectProtocolValidator ProtocolValidator { get; set; } = new OpenIdConnectProtocolValidator() diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs deleted file mode 100644 index 78eea68bfb..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Utility/ClaimsHelper.cs +++ /dev/null @@ -1,81 +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.IdentityModel.Tokens.Jwt; -using System.Security.Claims; -using Newtonsoft.Json.Linq; - -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect -{ - internal static class ClaimsHelper - { - public static void AddClaimsToIdentity( - JObject userInformationPayload, - ClaimsIdentity identity, - string issuer) - { - foreach (var pair in userInformationPayload) - { - var array = pair.Value as JArray; - if (array != null) - { - foreach (var item in array) - { - AddClaimsToIdentity(item, identity, pair.Key, issuer); - } - } - else - { - AddClaimsToIdentity(pair.Value, identity, pair.Key, issuer); - } - } - } - - private static void AddClaimsToIdentity(JToken item, ClaimsIdentity identity, string key, string issuer) - => identity.AddClaim(new Claim(key, item?.ToString() ?? string.Empty, GetClaimValueType(item), issuer)); - - private static string GetClaimValueType(JToken token) - { - if (token == null) - { - return JsonClaimValueTypes.JsonNull; - } - - switch (token.Type) - { - case JTokenType.Array: - return JsonClaimValueTypes.JsonArray; - - case JTokenType.Boolean: - return ClaimValueTypes.Boolean; - - case JTokenType.Date: - return ClaimValueTypes.DateTime; - - case JTokenType.Float: - return ClaimValueTypes.Double; - - case JTokenType.Integer: - { - var value = (long) token; - if (value >= int.MinValue && value <= int.MaxValue) - { - return ClaimValueTypes.Integer; - } - - return ClaimValueTypes.Integer64; - } - - case JTokenType.Object: - return JsonClaimValueTypes.Json; - - case JTokenType.String: - return ClaimValueTypes.String; - } - - // Fall back to ClaimValueTypes.String when no appropriate - // claim value type can be inferred from the claim value. - return ClaimValueTypes.String; - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs index 435196a1e5..21c6189d71 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.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.Security.Claims; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 78557532c5..3694159f6e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -11,9 +11,8 @@ - + - diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 20d06beafc..8481730a8c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -108,6 +108,11 @@ namespace Microsoft.AspNetCore.Authentication.Twitter protected virtual async Task CreateTicketAsync( ClaimsIdentity identity, AuthenticationProperties properties, AccessToken token, JObject user) { + foreach (var action in Options.ClaimActions) + { + action.Run(user, identity, Options.ClaimsIssuer); + } + var context = new TwitterCreatingTicketContext(Context, Options, token.UserId, token.ScreenName, token.Token, token.TokenSecret, user) { Principal = new ClaimsPrincipal(identity), @@ -355,12 +360,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var result = JObject.Parse(responseText); - var email = result.Value("email"); - if (!string.IsNullOrEmpty(email)) - { - identity.AddClaim(new Claim(ClaimTypes.Email, email, ClaimValueTypes.Email, Options.ClaimsIssuer)); - } - return result; } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index bf54b7fbb9..836dd3c0d5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -2,8 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.ComponentModel; +using System.Security.Claims; using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.AspNetCore.Http; @@ -24,6 +25,8 @@ namespace Microsoft.AspNetCore.Builder CallbackPath = new PathString("/signin-twitter"); BackchannelTimeout = TimeSpan.FromSeconds(60); Events = new TwitterEvents(); + + ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); } /// @@ -46,6 +49,11 @@ namespace Microsoft.AspNetCore.Builder /// public bool RetrieveUserDetails { get; set; } + /// + /// A collection of claim actions used to select values from the json user data and create Claims. + /// + public ClaimActionCollection ClaimActions { get; } = new ClaimActionCollection(); + /// /// Gets or sets the type used to secure data handled by the middleware. /// diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 944c322ad3..2a47f1e89c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -653,11 +653,11 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal(context.AccessToken, "Test Access Token"); Assert.Equal(context.RefreshToken, "Test Refresh Token"); Assert.Equal(context.ExpiresIn, TimeSpan.FromSeconds(3600)); - Assert.Equal(GoogleHelper.GetEmail(context.User), "Test email"); - Assert.Equal(GoogleHelper.GetId(context.User), "Test User ID"); - Assert.Equal(GoogleHelper.GetName(context.User), "Test Name"); - Assert.Equal(GoogleHelper.GetFamilyName(context.User), "Test Family Name"); - Assert.Equal(GoogleHelper.GetGivenName(context.User), "Test Given Name"); + Assert.Equal(context.Identity.FindFirst(ClaimTypes.Email)?.Value, "Test email"); + Assert.Equal(context.Identity.FindFirst(ClaimTypes.NameIdentifier)?.Value, "Test User ID"); + Assert.Equal(context.Identity.FindFirst(ClaimTypes.Name)?.Value, "Test Name"); + Assert.Equal(context.Identity.FindFirst(ClaimTypes.Surname)?.Value, "Test Family Name"); + Assert.Equal(context.Identity.FindFirst(ClaimTypes.GivenName)?.Value, "Test Given Name"); return Task.FromResult(0); } }, diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 446469ba46..3ae22642f0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -22,4 +22,8 @@ + + + + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 5eaa318a3d..7b6b30b8cb 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -17,4 +17,8 @@ + + + + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 0cf30727b6..9c49dcd29d 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -18,4 +18,8 @@ + + + + diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index aa00d90e0a..ced555fe90 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -17,4 +17,8 @@ + + + + From 5039f7469374745273b04c8555a343a5df317ba8 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Mar 2017 18:14:13 -0800 Subject: [PATCH 689/900] Change korebuild branch and fix argument forwarding in bootstrapper --- build.ps1 | 16 ++++++++-------- build.sh | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build.ps1 b/build.ps1 index 0605b59c01..5bf0e2c113 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,6 @@ $ErrorActionPreference = "Stop" -function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) +function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) { while($true) { @@ -19,7 +19,7 @@ function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $ret Start-Sleep -Seconds 10 } - else + else { $exception = $_.Exception throw $exception @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP @@ -43,18 +43,18 @@ $buildFolder = ".build" $buildFile="$buildFolder\KoreBuild.ps1" if (!(Test-Path $buildFolder)) { - Write-Host "Downloading KoreBuild from $koreBuildZip" - + Write-Host "Downloading KoreBuild from $koreBuildZip" + $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() New-Item -Path "$tempFolder" -Type directory | Out-Null $localZipFile="$tempFolder\korebuild.zip" - + DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) - + New-Item -Path "$buildFolder" -Type directory | Out-Null copy-item "$tempFolder\**\build\*" $buildFolder -Recurse @@ -64,4 +64,4 @@ if (!(Test-Path $buildFolder)) { } } -&"$buildFile" $args \ No newline at end of file +&"$buildFile" @args diff --git a/build.sh b/build.sh index 07997d6c83..b0bcadb579 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi @@ -12,12 +12,12 @@ buildFile="$buildFolder/KoreBuild.sh" if test ! -d $buildFolder; then echo "Downloading KoreBuild from $koreBuildZip" - - tempFolder="/tmp/KoreBuild-$(uuidgen)" + + tempFolder="/tmp/KoreBuild-$(uuidgen)" mkdir $tempFolder - + localZipFile="$tempFolder/korebuild.zip" - + retries=6 until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) do @@ -29,18 +29,18 @@ if test ! -d $buildFolder; then echo "Waiting 10 seconds before retrying. Retries left: $retries" sleep 10s done - + unzip -q -d $tempFolder $localZipFile - + mkdir $buildFolder cp -r $tempFolder/**/build/** $buildFolder - + chmod +x $buildFile - + # Cleanup if test -d $tempFolder; then - rm -rf $tempFolder + rm -rf $tempFolder fi fi -$buildFile -r $repoFolder "$@" \ No newline at end of file +$buildFile -r $repoFolder "$@" From 4da44021c2098544cbe2d89d81fa63967e7d5ea3 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Mar 2017 18:25:46 -0800 Subject: [PATCH 690/900] Update AppVeyor and Travis settings --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a0be886892..af659e9ae9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,4 +29,4 @@ branches: before_install: - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: - - ./build.sh --quiet verify + - ./build.sh diff --git a/appveyor.yml b/appveyor.yml index c6b856f49c..944c23c8ba 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ branches: - dev - /^(.*\/)?ci-.*$/ build_script: - - build.cmd verify + - ps: .\build.ps1 clone_depth: 1 test: off deploy: off From 80ebf99277b3ef15f32b4ec5fa57726856614cd5 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 9 Mar 2017 11:23:04 -0800 Subject: [PATCH 691/900] Update .travis.yml (#1138) --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index af659e9ae9..b8f60ce2e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,7 @@ env: global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -mono: - - 4.0.5 +mono: none os: - linux - osx From 0fd6f1554a3d60836741d7d319a5654fd1214ee4 Mon Sep 17 00:00:00 2001 From: Zhang Sen Date: Sun, 12 Mar 2017 22:32:47 +0800 Subject: [PATCH 692/900] Fix wrong comment (GitHub -> Google) --- samples/SocialSample/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 42ce6a29db..e99be82f8c 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -110,7 +110,7 @@ namespace SocialSample SaveTokens = true }); - // You must first create an app with GitHub and add its ID and Secret to your user-secrets. + // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project var googleOptions = new GoogleOptions { From 9de5519c8b2c5368ee10de5d10ec46ea15fd1e96 Mon Sep 17 00:00:00 2001 From: Jean Collas Date: Wed, 8 Mar 2017 04:48:02 +0100 Subject: [PATCH 693/900] Update of wrong variable name To avoid confusion when reading the code --- samples/SocialSample/Startup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index e99be82f8c..31ec187a02 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -238,9 +238,9 @@ namespace SocialSample app.UseOAuthAuthentication(githubOptions); // Choose an authentication type - app.Map("/login", signoutApp => + app.Map("/login", signinApp => { - signoutApp.Run(async context => + signinApp.Run(async context => { var authType = context.Request.Query["authscheme"]; if (!string.IsNullOrEmpty(authType)) From 32dd435c6e02267afddbfc715c7b92439f21d8cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Mon, 13 Mar 2017 18:02:59 +0100 Subject: [PATCH 694/900] Add an opt-out DisableTelemetry option in the OpenID Connect middleware (#1140) --- .../OpenIdConnectHandler.cs | 3 +++ .../OpenIdConnectOptions.cs | 7 +++++++ .../OpenIdConnectChallengeTests.cs | 20 +++++++++++++++++-- .../OpenIdConnectMiddlewareTests.cs | 20 ++++++++++++++++++- .../OpenIdConnect/TestSettings.cs | 14 +++++++++++++ 5 files changed, 61 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index a7c20f62ea..6b24996e78 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -161,6 +161,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var message = new OpenIdConnectMessage() { + EnableTelemetryParameters = !Options.DisableTelemetry, IssuerAddress = _configuration?.EndSessionEndpoint ?? string.Empty, // Redirect back to SigneOutCallbackPath first before user agent is redirected to actual post logout redirect uri @@ -309,6 +310,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var message = new OpenIdConnectMessage { ClientId = Options.ClientId, + EnableTelemetryParameters = !Options.DisableTelemetry, IssuerAddress = _configuration?.AuthorizationEndpoint ?? string.Empty, RedirectUri = BuildRedirectUri(Options.CallbackPath), Resource = Options.Resource, @@ -1023,6 +1025,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect ClientSecret = Options.ClientSecret, Code = authorizationResponse.Code, GrantType = OpenIdConnectGrantTypes.AuthorizationCode, + EnableTelemetryParameters = !Options.DisableTelemetry, RedirectUri = properties.Items[OpenIdConnectDefaults.RedirectUriForCodePropertiesKey] }; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index a46c2956c6..8269acbd8f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -241,5 +241,12 @@ namespace Microsoft.AspNetCore.Builder /// This is disabled by default. /// public bool SkipUnrecognizedRequests { get; set; } = false; + + /// + /// Indicates whether telemetry should be disabled. When this feature is enabled, + /// the assembly version of the Microsoft IdentityModel packages is sent to the + /// remote OpenID Connect provider as an authorization/logout request parameter. + /// + public bool DisableTelemetry { get; set; } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index b9c0179aff..1912561b11 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -35,7 +35,23 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect OpenIdConnectParameterNames.ResponseType, OpenIdConnectParameterNames.ResponseMode, OpenIdConnectParameterNames.Scope, - OpenIdConnectParameterNames.RedirectUri); + OpenIdConnectParameterNames.RedirectUri, + OpenIdConnectParameterNames.SkuTelemetry, + OpenIdConnectParameterNames.VersionTelemetry); + } + + [Fact] + public async Task AuthorizationRequestDoesNotIncludeTelemetryParametersWhenDisabled() + { + var settings = new TestSettings(opt => opt.DisableTelemetry = true); + + var server = settings.CreateTestServer(); + var transaction = await server.SendAsync(ChallengeEndpoint); + + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.DoesNotContain(OpenIdConnectParameterNames.SkuTelemetry, res.Headers.Location.Query); + Assert.DoesNotContain(OpenIdConnectParameterNames.VersionTelemetry, res.Headers.Location.Query); } /* @@ -58,7 +74,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect */ [Fact] - public async Task ChallengeIssueedCorrectlyForFormPost() + public async Task ChallengeIssuedCorrectlyForFormPost() { var settings = new TestSettings( opt => opt.AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 6c427c600e..a58d54b650 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -46,7 +46,25 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); Assert.NotNull(res.Headers.Location); - setting.ValidateSignoutRedirect(transaction.Response.Headers.Location); + setting.ValidateSignoutRedirect( + transaction.Response.Headers.Location, + OpenIdConnectParameterNames.SkuTelemetry, + OpenIdConnectParameterNames.VersionTelemetry); + } + + [Fact] + public async Task EndSessionRequestDoesNotIncludeTelemetryParametersWhenDisabled() + { + var setting = new TestSettings(opt => opt.DisableTelemetry = true); + + var server = setting.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.DoesNotContain(OpenIdConnectParameterNames.SkuTelemetry, res.Headers.Location.Query); + Assert.DoesNotContain(OpenIdConnectParameterNames.VersionTelemetry, res.Headers.Location.Query); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 3e50a7abee..a3bea3ebe7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Reflection; using System.Text; using System.Text.Encodings.Web; using System.Xml.Linq; @@ -152,6 +153,12 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect case OpenIdConnectParameterNames.State: ValidateState(actualValues, errors, htmlEncoded); break; + case OpenIdConnectParameterNames.SkuTelemetry: + ValidateSkuTelemetry(actualValues, errors, htmlEncoded); + break; + case OpenIdConnectParameterNames.VersionTelemetry: + ValidateVersionTelemetry(actualValues, errors, htmlEncoded); + break; default: throw new InvalidOperationException($"Unknown parameter \"{paramToValidate}\"."); } @@ -201,6 +208,13 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect private void ValidateState(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => ValidateQueryParameter(OpenIdConnectParameterNames.State, ExpectedState, actualQuery, errors, htmlEncoded); + private void ValidateSkuTelemetry(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => + ValidateQueryParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET", actualQuery, errors, htmlEncoded); + + private void ValidateVersionTelemetry(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => + ValidateQueryParameter(OpenIdConnectParameterNames.VersionTelemetry, + typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualQuery, errors, htmlEncoded); + private void ValidateQueryParameter( string parameterName, string expectedValue, From 35986c778f618b16e706a2f3d50b5daf2528332e Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Sat, 11 Mar 2017 15:43:03 -0800 Subject: [PATCH 695/900] Back up to .NET 4.5.2 - do not have .NET 4.6.1 reference assemblies on all CI machines - have corrected System.XML casing issue mentioned in 7637f2ea nit: sort dependencies --- .../Microsoft.Owin.Security.Interop.Test.csproj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 635fffe331..32c20ae4f5 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -3,7 +3,7 @@ - net461 + net452 true true @@ -11,12 +11,13 @@ - - + + + From 7f0b14a8ef32a6e70621399cc6c05cd00aadef6f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 14 Mar 2017 12:51:09 -0700 Subject: [PATCH 696/900] React to aspnet/DotNetTools#272 --- .../OpenIdConnect.AzureAdSample.csproj | 2 +- samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 8c8c3f2b18..695c6d556e 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -15,6 +15,6 @@ - + diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 5a9683f6cb..6df1141019 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -19,7 +19,7 @@ - + From 8c70684a9d4a584473135bd14ac289f11a8d0d0e Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 14 Mar 2017 13:41:29 -0700 Subject: [PATCH 697/900] Update appveyor and travis settings --- .travis.yml | 1 - appveyor.yml | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b8f60ce2e5..e4c69a2a09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ mono: none os: - linux - osx -osx_image: xcode7.3 branches: only: - master diff --git a/appveyor.yml b/appveyor.yml index 944c23c8ba..1041615c68 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,5 +11,4 @@ build_script: clone_depth: 1 test: off deploy: off -# Required for dotnet-test to work -os: Visual Studio 2015 +os: Visual Studio 2017 From fc57e0aabd0306122b2555b57a61770108b30a5c Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Tue, 14 Mar 2017 21:25:36 -0700 Subject: [PATCH 698/900] React to aspnet/DataProtection#203 --- .../Facebook/FacebookMiddlewareTests.cs | 3 ++- .../Google/GoogleMiddlewareTests.cs | 25 ++++++++++--------- .../MicrosoftAccountMiddlewareTests.cs | 3 ++- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs index f38ca8afc8..4d6cabaf1b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; using Xunit; @@ -163,7 +164,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { var customUserInfoEndpoint = "https://graph.facebook.com/me?fields=email,timezone,picture"; var finalUserInfoEndpoint = string.Empty; - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("FacebookTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("FacebookTest")); var server = CreateServer( app => { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 2a47f1e89c..090f9f1210 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; using Xunit; @@ -293,7 +294,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [InlineData("CustomIssuer")] public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string claimsIssuer) { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -383,7 +384,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [InlineData(false)] public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -436,7 +437,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [InlineData(false)] public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -485,7 +486,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task AuthenticatedEventCanGetRefreshToken() { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -565,7 +566,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task NullRedirectUriWillRedirectToSlash() { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -638,7 +639,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task ValidateAuthenticatedContext() { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -736,7 +737,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task CanRedirectOnError() { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -764,7 +765,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task AuthenticateAutomaticWhenAlreadySignedInSucceeds() { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -807,7 +808,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task AuthenticateGoogleWhenAlreadySignedInSucceeds() { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -850,7 +851,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task ChallengeGoogleWhenAlreadySignedInReturnsForbidden() { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -886,7 +887,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull() { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", @@ -922,7 +923,7 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task ChallengeFacebookWhenAlreadySignedWithGoogleSucceeds() { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(new GoogleOptions { ClientId = "Test Id", diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index 0ddfb5a3c7..0ed164e496 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; using Xunit; @@ -103,7 +104,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount [Fact] public async Task AuthenticatedEventCanGetRefreshToken() { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("MsftTest")); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("MsftTest")); var server = CreateServer(new MicrosoftAccountOptions { ClientId = "Test Client Id", From 10ef26d63c98c3966e7315aee172a7c3fd992520 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 15 Mar 2017 18:12:53 -0700 Subject: [PATCH 699/900] Consolidate dependency versions into one file and remove workarounds --- build/dependencies.props | 9 ++++++- samples/CookieSample/CookieSample.csproj | 20 +++++++------- samples/CookieSample/web.config | 9 ------- .../CookieSessionSample.csproj | 20 +++++++------- samples/CookieSessionSample/web.config | 9 ------- .../JwtBearerSample/JwtBearerSample.csproj | 19 +++++++------- samples/JwtBearerSample/web.config | 9 ------- .../OpenIdConnect.AzureAdSample.csproj | 25 +++++++++++------- .../OpenIdConnect.AzureAdSample/web.config | 9 ------- .../OpenIdConnectSample.csproj | 26 ++++++++++--------- samples/OpenIdConnectSample/web.config | 9 ------- samples/SocialSample/SocialSample.csproj | 24 +++++++++-------- ...t.AspNetCore.Authentication.Cookies.csproj | 6 ++--- ...AspNetCore.Authentication.JwtBearer.csproj | 4 +-- ...oft.AspNetCore.Authentication.OAuth.csproj | 4 +-- ...etCore.Authentication.OpenIdConnect.csproj | 4 +-- ...t.AspNetCore.Authentication.Twitter.csproj | 2 +- ...Microsoft.AspNetCore.Authentication.csproj | 17 ++++++------ .../Microsoft.AspNetCore.Authorization.csproj | 6 ++--- .../Microsoft.AspNetCore.CookiePolicy.csproj | 4 +-- .../Microsoft.Owin.Security.Interop.csproj | 4 +-- ...soft.AspNetCore.Authentication.Test.csproj | 10 +++---- ...osoft.AspNetCore.Authorization.Test.csproj | 12 ++++----- ....ChunkingCookieManager.Sources.Test.csproj | 8 +++--- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 10 +++---- ...icrosoft.Owin.Security.Interop.Test.csproj | 16 +++++++----- 26 files changed, 137 insertions(+), 158 deletions(-) delete mode 100644 samples/CookieSample/web.config delete mode 100644 samples/CookieSessionSample/web.config delete mode 100644 samples/JwtBearerSample/web.config delete mode 100644 samples/OpenIdConnect.AzureAdSample/web.config delete mode 100644 samples/OpenIdConnectSample/web.config diff --git a/build/dependencies.props b/build/dependencies.props index e704edaec0..8ad6e2f5a1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,13 @@ - 1.6.1 + 1.2.0-* 4.3.0 + 3.13.8 + 2.1.3 + 9.0.1 + 1.6.1 + 3.0.1 + 15.0.0 + 2.2.0 diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index a2cab9171e..9b2137343f 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,20 +1,22 @@ + + net451;netcoreapp1.1 - Exe - - win7-x64 - - - - - - + + + + + + + + + diff --git a/samples/CookieSample/web.config b/samples/CookieSample/web.config deleted file mode 100644 index f7ac679334..0000000000 --- a/samples/CookieSample/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index aa5f0ca272..96af9da089 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,20 +1,22 @@ + + net451;netcoreapp1.1 - Exe - - win7-x64 - - - - - - + + + + + + + + + diff --git a/samples/CookieSessionSample/web.config b/samples/CookieSessionSample/web.config deleted file mode 100644 index f7ac679334..0000000000 --- a/samples/CookieSessionSample/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 790bd0827b..890af4eee9 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,21 +1,22 @@ + + - 1.1.0 net451;netcoreapp1.1 - - win7-x64 - Exe aspnet5-JwtBearerSample-20151210102827 - - - - - + + + + + + + + diff --git a/samples/JwtBearerSample/web.config b/samples/JwtBearerSample/web.config deleted file mode 100644 index f7ac679334..0000000000 --- a/samples/JwtBearerSample/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 695c6d556e..62adb16678 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,20 +1,25 @@  + + + net451;netcoreapp1.1 - Exe - - win7-x64 aspnet5-OpenIdConnectSample-20151210110318 + - - - - - - - + + + + + + + + + + + diff --git a/samples/OpenIdConnect.AzureAdSample/web.config b/samples/OpenIdConnect.AzureAdSample/web.config deleted file mode 100644 index f7ac679334..0000000000 --- a/samples/OpenIdConnect.AzureAdSample/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 6df1141019..ba79d1a8ca 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,25 +1,27 @@ + + net451;netcoreapp1.1 - Exe - - win7-x64 aspnet5-OpenIdConnectSample-20151210110318 - - - - - - - - - + + + + + + + + + + + + diff --git a/samples/OpenIdConnectSample/web.config b/samples/OpenIdConnectSample/web.config deleted file mode 100644 index f7ac679334..0000000000 --- a/samples/OpenIdConnectSample/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 30f0742dea..33e6e5052b 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,10 +1,9 @@ + + net451;netcoreapp1.1 - Exe - - win7-x64 aspnet5-SocialSample-20151210111056 @@ -14,14 +13,17 @@ - - - - - - - - + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 0d7dd04303..092631fdf6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -17,9 +17,9 @@ - - - + + + diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 518526d419..18e06c92ef 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -9,7 +9,7 @@ - - + + diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index e40377c09f..f6f808957b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 965a940e40..4eb7fd2a1f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -9,7 +9,7 @@ - - + + diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 3694159f6e..2b34f1d1b4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 3b5c7d6314..0e9afba518 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -4,7 +4,6 @@ ASP.NET Core common types used by the various authentication middleware components. - 1.2.0 net451;netstandard1.3 $(NoWarn);CS1591 true @@ -12,14 +11,14 @@ - - - - - - - - + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index d1360f868c..0cdd0b2678 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -14,9 +14,9 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute - - - + + + diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 862ab2ac72..344d18f253 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index 153eb6ae9f..b779073647 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 3ae22642f0..d0505f36a5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -15,11 +15,11 @@ - - - - - + + + + + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 7b6b30b8cb..a50fc3b01a 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 9c49dcd29d..ea08bbc2f7 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -12,10 +12,10 @@ - - - - + + + + diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index ced555fe90..d2a567d1e9 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -10,11 +10,11 @@ - - - - - + + + + + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 32c20ae4f5..6a869b23fe 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -12,12 +12,16 @@ - - - - - - + + + + + + + + + + From 923804ab676d1d4573e36504883a2940a07fb2ea Mon Sep 17 00:00:00 2001 From: Simon Wendel Date: Mon, 20 Mar 2017 23:12:02 +0100 Subject: [PATCH 700/900] Fix typo in Azure AD sample README.md (#1155) Assuming DEVELOPMENMT should be DEVELOPMENT. --- samples/OpenIdConnect.AzureAdSample/Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Readme.md b/samples/OpenIdConnect.AzureAdSample/Readme.md index 37dda75a72..767e336ac6 100644 --- a/samples/OpenIdConnect.AzureAdSample/Readme.md +++ b/samples/OpenIdConnect.AzureAdSample/Readme.md @@ -10,7 +10,7 @@ 8. In the keys section add a new key. A key value will be generated. Save the value as "Client Secret" ## Configure the local environment -1. Set environment ASPNETCORE_ENVIRONMENT to DEVELOPMENMT. ([Working with Multiple Environments](https://docs.asp.net/en/latest/fundamentals/environments.html)) +1. Set environment ASPNETCORE_ENVIRONMENT to DEVELOPMENT. ([Working with Multiple Environments](https://docs.asp.net/en/latest/fundamentals/environments.html)) 2. Set up user secrets: ``` dotnet user-secrets set oidc:clientid From 5e73fbbec8ccb63f0a27f34db7129726065c142a Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 21 Mar 2017 12:17:39 -0700 Subject: [PATCH 701/900] Update Travis to macOS Sierra [skip appveyor] --- .travis.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index e4c69a2a09..2a46104677 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,6 @@ language: csharp -sudo: required +sudo: false dist: trusty -addons: - apt: - packages: - - gettext - - libcurl4-openssl-dev - - libicu-dev - - libssl-dev - - libunwind8 - - zlib1g env: global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true @@ -18,6 +9,7 @@ mono: none os: - linux - osx +osx_image: xcode8.2 branches: only: - master From ffa45dbd016ce18ae875166d52d29a80bfd352bd Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Mar 2017 17:12:09 -0700 Subject: [PATCH 702/900] Change compilation targets. * Remove net451 as a compilation target * Upgrade to netcoreapp2.0 --- .gitignore | 1 + build/dependencies.props | 1 + samples/CookieSample/CookieSample.csproj | 2 +- samples/CookieSessionSample/CookieSessionSample.csproj | 2 +- samples/JwtBearerSample/JwtBearerSample.csproj | 2 +- .../OpenIdConnect.AzureAdSample.csproj | 2 +- samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 2 +- samples/SocialSample/SocialSample.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.Cookies.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.Facebook.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.Google.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.JwtBearer.csproj | 2 +- ...rosoft.AspNetCore.Authentication.MicrosoftAccount.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.OAuth.csproj | 2 +- ...Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.Twitter.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.csproj | 2 +- .../Microsoft.AspNetCore.Authorization.csproj | 2 +- .../Microsoft.AspNetCore.CookiePolicy.csproj | 2 +- .../Microsoft.Owin.Security.Interop.csproj | 2 +- .../Microsoft.AspNetCore.Authentication.Test.csproj | 6 ++++-- .../Microsoft.AspNetCore.Authorization.Test.csproj | 4 ++-- ...oft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj | 4 ++-- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 6 ++++-- .../Microsoft.Owin.Security.Interop.Test.csproj | 2 +- 25 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 0f91ad1208..bcc811de9a 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ project.lock.json .build/ .testPublish/ /.vs/ +global.json diff --git a/build/dependencies.props b/build/dependencies.props index 8ad6e2f5a1..b58dd4cd7c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -7,6 +7,7 @@ 9.0.1 1.6.1 3.0.1 + 2.0.0-* 15.0.0 2.2.0 diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 9b2137343f..9fd7e9412c 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -3,7 +3,7 @@ - net451;netcoreapp1.1 + net46;netcoreapp2.0 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 96af9da089..e4a42b8c4d 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -3,7 +3,7 @@ - net451;netcoreapp1.1 + net46;netcoreapp2.0 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 890af4eee9..bfff3d5199 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -3,7 +3,7 @@ - net451;netcoreapp1.1 + net46;netcoreapp2.0 aspnet5-JwtBearerSample-20151210102827 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 62adb16678..a5982549bf 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -3,7 +3,7 @@ - net451;netcoreapp1.1 + net46;netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index ba79d1a8ca..eaf3a2e87e 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -3,7 +3,7 @@ - net451;netcoreapp1.1 + net46;netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 33e6e5052b..09ece106cb 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -3,7 +3,7 @@ - net451;netcoreapp1.1 + net46;netcoreapp2.0 aspnet5-SocialSample-20151210111056 diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 092631fdf6..4a711c3180 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to use cookie based authentication. - net451;netstandard1.3 + netstandard1.3 $(DefineConstants);SECURITY $(NoWarn);CS1591 true diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index 6be798cc19..8fddfe5206 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index dc6ef94d64..82a3e474e0 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -4,7 +4,7 @@ ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 18e06c92ef..90566e7793 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. - net451;netstandard1.4 + net46;netstandard1.4 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 5f9a5bb3e4..ac91578ead 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index f6f808957b..c0e7569acb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 4eb7fd2a1f..2367369a4a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. - net451;netstandard1.4 + net46;netstandard1.4 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 2b34f1d1b4..dc4bbf80ae 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 0e9afba518..316defc436 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -4,7 +4,7 @@ ASP.NET Core common types used by the various authentication middleware components. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 0cdd0b2678..0382fd2b55 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -7,7 +7,7 @@ Commonly used types: Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute Microsoft.AspNetCore.Authorization.AuthorizeAttribute - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore;authorization diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 344d18f253..146917cabe 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -4,7 +4,7 @@ ASP.NET Core cookie policy classes to control the behavior of cookies. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index b779073647..1a66791194 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -4,7 +4,7 @@ A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication. - net451 + net46 $(NoWarn);CS1591 true aspnetcore;katana;owin;security diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index d0505f36a5..bbf54ec5e7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -3,8 +3,10 @@ - netcoreapp1.1;net452 - netcoreapp1.1 + netcoreapp2.0;net46 + netcoreapp2.0 + true + true diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index a50fc3b01a..d9065add3a 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -3,8 +3,8 @@ - netcoreapp1.1;net452 - netcoreapp1.1 + netcoreapp2.0;net46 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index ea08bbc2f7..729c01630b 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -3,8 +3,8 @@ - netcoreapp1.1;net452 - netcoreapp1.1 + netcoreapp2.0;net46 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index d2a567d1e9..f4507a37b1 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -3,8 +3,10 @@ - netcoreapp1.1;net452 - netcoreapp1.1 + netcoreapp2.0;net46 + netcoreapp2.0 + true + true diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 6a869b23fe..003e1a18b5 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -3,7 +3,7 @@ - net452 + net46 true true From b8eae7a697e263651f81401fc2bf9247b096f181 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Mar 2017 17:54:58 -0700 Subject: [PATCH 703/900] Add reference to System.Security.Claims --- .../Microsoft.AspNetCore.Authentication.JwtBearer.csproj | 1 + .../Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj | 1 + .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 1 + .../Microsoft.Owin.Security.Interop.Test.csproj | 1 + 4 files changed, 4 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 90566e7793..7311aa3aef 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -11,5 +11,6 @@ + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 2367369a4a..351cb284c5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -11,5 +11,6 @@ + diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index f4507a37b1..b9155b4dfe 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -16,6 +16,7 @@ + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 003e1a18b5..02763b93f2 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -16,6 +16,7 @@ + From 75a4d006aa7e53c110b3c71c66473adbd45becd6 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Tue, 21 Mar 2017 15:53:30 -0700 Subject: [PATCH 704/900] Disable API Check in projects with untracked breaking changes --- .../Microsoft.AspNetCore.Authentication.Facebook.csproj | 1 + .../Microsoft.AspNetCore.Authentication.Google.csproj | 1 + .../Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj | 1 + 3 files changed, 3 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index 8fddfe5206..0cef42b391 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -8,6 +8,7 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security + false diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index 82a3e474e0..491571371e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -8,6 +8,7 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security + false diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index ac91578ead..eecfeb9261 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -8,6 +8,7 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security + false From 2b8a9378282089feb29100d11d8dfd3e648ef2f5 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Tue, 28 Mar 2017 04:28:47 -0700 Subject: [PATCH 705/900] Upgraded Json.NET version to 10.0.1 --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index b58dd4cd7c..8acb4fe47c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 4.3.0 3.13.8 2.1.3 - 9.0.1 + 10.0.1 1.6.1 3.0.1 2.0.0-* From 305ccf9cc5d2ce777e5fb147013966924c9aca8e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 29 Mar 2017 11:30:36 -0700 Subject: [PATCH 706/900] Updating to 2.0.0 Internal.AspNetCore.Sdk --- build/common.props | 2 +- build/dependencies.props | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/common.props b/build/common.props index 52413444ee..9c5464a54c 100644 --- a/build/common.props +++ b/build/common.props @@ -13,7 +13,7 @@ - + diff --git a/build/dependencies.props b/build/dependencies.props index 8acb4fe47c..c5193b750f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,6 +4,7 @@ 4.3.0 3.13.8 2.1.3 + 2.0.0-* 10.0.1 1.6.1 3.0.1 @@ -11,4 +12,4 @@ 15.0.0 2.2.0 - + \ No newline at end of file From 2d7cd6038fea34b84084685648ac9d0c97be610b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 3 Apr 2017 21:41:12 -0700 Subject: [PATCH 707/900] Updating versions to 2.0.0-preview1 --- build/dependencies.props | 2 +- version.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c5193b750f..b9ac0f5f05 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 1.2.0-* + 2.0.0-* 4.3.0 3.13.8 2.1.3 diff --git a/version.props b/version.props index e77c8d9c38..44cb2290b9 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 1.2.0 + 2.0.0 preview1 \ No newline at end of file From 99aa3bd35dd5fbe46a93eef8a2c8ab1f9fe8d05b Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 19 Apr 2017 13:00:03 -0700 Subject: [PATCH 708/900] Auth 2.0 --- Security.sln | 124 ++- samples/CookieSample/Startup.cs | 10 +- samples/CookieSessionSample/Startup.cs | 11 +- .../JwtBearerSample/JwtBearerSample.csproj | 1 + samples/JwtBearerSample/Startup.cs | 59 +- .../AuthPropertiesTokenCache.cs | 12 +- .../OpenIdConnect.AzureAdSample.csproj | 1 + .../OpenIdConnect.AzureAdSample/Startup.cs | 113 ++- .../OpenIdConnectSample.csproj | 1 + samples/OpenIdConnectSample/Startup.cs | 81 +- samples/SocialSample/SocialSample.csproj | 1 + samples/SocialSample/Startup.cs | 236 +++--- .../CookieAppBuilderExtensions.cs | 33 +- .../CookieAuthenticationDefaults.cs | 2 +- .../CookieAuthenticationHandler.cs | 144 +++- .../CookieAuthenticationMiddleware.cs | 66 -- .../CookieAuthenticationOptions.cs | 41 +- .../CookieExtensions.cs | 21 + .../Events/BaseCookieContext.cs | 11 +- .../Events/CookieAuthenticationEvents.cs | 2 +- .../Events/CookieRedirectContext.cs | 12 +- .../Events/CookieSignedInContext.cs | 20 +- .../Events/CookieSigningInContext.cs | 23 +- .../Events/CookieSigningOutContext.cs | 11 +- .../Events/CookieValidatePrincipalContext.cs | 15 +- .../Events/ICookieAuthenticationEvents.cs | 64 -- ...t.AspNetCore.Authentication.Cookies.csproj | 2 - .../FacebookAppBuilderExtensions.cs | 35 +- .../FacebookConfigureOptions.cs | 16 + .../FacebookExtensions.cs | 32 + .../FacebookHandler.cs | 20 +- .../FacebookMiddleware.cs | 89 -- .../FacebookOptions.cs | 28 +- ....AspNetCore.Authentication.Facebook.csproj | 1 + .../GoogleAppBuilderExtensions.cs | 33 +- .../GoogleConfigureOptions.cs | 16 + .../GoogleExtensions.cs | 32 + .../GoogleHandler.cs | 19 +- .../GoogleMiddleware.cs | 81 -- .../GoogleOptions.cs | 8 +- ...ft.AspNetCore.Authentication.Google.csproj | 1 + .../Events/AuthenticationFailedContext.cs | 5 +- .../Events/BaseJwtBearerContext.cs | 11 +- .../Events/IJwtBearerEvents.cs | 33 - .../Events/JwtBearerChallengeContext.cs | 6 +- .../Events/JwtBearerEvents.cs | 4 +- .../Events/MessageReceivedContext.cs | 5 +- .../Events/TokenValidatedContext.cs | 5 +- .../JwtBearerAppBuilderExtensions.cs | 46 +- .../JwtBearerConfigureOptions.cs | 17 + .../JwtBearerExtensions.cs | 32 + .../JwtBearerHandler.cs | 114 ++- .../JwtBearerMiddleware.cs | 108 --- .../JwtBearerOptions.cs | 29 +- ...AspNetCore.Authentication.JwtBearer.csproj | 3 +- ...ore.Authentication.MicrosoftAccount.csproj | 1 + .../MicrosoftAccountAppBuilderExtensions.cs | 35 +- .../MicrosoftAccountConfigureOptions.cs | 17 + .../MicrosoftAccountExtensions.cs | 32 + .../MicrosoftAccountHandler.cs | 20 +- .../MicrosoftAccountMiddleware.cs | 78 -- .../MicrosoftAccountOptions.cs | 7 +- .../Events/IOAuthEvents.cs | 27 - .../Events/OAuthCreatingTicketContext.cs | 19 +- .../Events/OAuthEvents.cs | 6 +- .../OAuthRedirectToAuthorizationContext.cs | 3 +- .../OAuthAppBuilderExtensions.cs | 35 +- .../OAuthExtensions.cs | 15 + .../OAuthHandler.cs | 66 +- .../OAuthMiddleware.cs | 138 ---- .../OAuthOptions.cs | 45 +- .../Events/AuthenticationFailedContext.cs | 4 +- .../AuthorizationCodeReceivedContext.cs | 22 +- .../Events/BaseOpenIdConnectContext.cs | 13 +- .../Events/IOpenIdConnectEvents.cs | 58 -- .../Events/MessageReceivedContext.cs | 6 +- .../Events/OpenIdConnectEvents.cs | 4 +- .../Events/RedirectContext.cs | 8 +- .../Events/RemoteSignoutContext.cs | 4 +- .../Events/TokenResponseReceivedContext.cs | 6 +- .../Events/TokenValidatedContext.cs | 4 +- .../Events/UserInformationReceivedContext.cs | 5 +- ...etCore.Authentication.OpenIdConnect.csproj | 1 + .../OpenIdConnectAppBuilderExtensions.cs | 35 +- .../OpenIdConnectConfigureOptions.cs | 17 + .../OpenIdConnectDefaults.cs | 2 +- .../OpenIdConnectExtensions.cs | 32 + .../OpenIdConnectHandler.cs | 204 +++-- .../OpenIdConnectMiddleware.cs | 209 ----- .../OpenIdConnectOptions.cs | 60 +- .../Events/BaseTwitterContext.cs | 11 +- .../Events/ITwitterEvents.cs | 26 - .../Events/TwitterCreatingTicketContext.cs | 13 +- .../Events/TwitterEvents.cs | 6 +- ...rRedirectToAuthorizationEndpointContext.cs | 19 +- ...t.AspNetCore.Authentication.Twitter.csproj | 1 + .../TwitterAppBuilderExtensions.cs | 33 +- .../TwitterConfigureOptions.cs | 17 + .../TwitterExtensions.cs | 32 + .../TwitterHandler.cs | 75 +- .../TwitterMiddleware.cs | 123 --- .../TwitterOptions.cs | 15 +- .../AuthAppBuilderExtensions.cs | 29 + .../AuthenticateResult.cs | 77 -- .../AuthenticationHandler.cs | 362 +++------ .../AuthenticationMiddleware.cs | 97 +-- .../AuthenticationOptions.cs | 59 -- .../AuthenticationSchemeOptions.cs | 50 ++ ...thenticationServiceCollectionExtensions.cs | 49 +- .../AuthenticationTicket.cs | 47 -- .../AuthenticationToken.cs | 12 - ...laimsTransformationAppBuilderExtensions.cs | 75 -- .../ClaimsTransformationContext.cs | 15 - .../ClaimsTransformationHandler.cs | 92 --- .../ClaimsTransformationMiddleware.cs | 58 -- .../ClaimsTransformationOptions.cs | 18 - .../ClaimsTransformer.cs | 19 - .../{DataHandler => Data}/IDataSerializer.cs | 0 .../ISecureDataFormat.cs | 0 .../PropertiesDataFormat.cs | 0 .../PropertiesSerializer.cs | 0 .../{DataHandler => Data}/SecureDataFormat.cs | 0 .../{DataHandler => Data}/TextEncoder.cs | 0 .../{DataHandler => Data}/TicketDataFormat.cs | 0 .../{DataHandler => Data}/TicketSerializer.cs | 0 .../Events/BaseContext.cs | 27 - .../Events/BaseControlContext.cs | 13 +- .../Events/EventResultState.cs | 2 +- .../Events/FailureContext.cs | 2 +- .../Events/IRemoteAuthenticationEvents.cs | 20 - .../Events/RemoteAuthenticationEvents.cs | 2 +- .../Events/TicketReceivedContext.cs | 3 +- .../HttpContextExtensions.cs | 22 - .../IClaimsTransformer.cs | 21 - ...Microsoft.AspNetCore.Authentication.csproj | 1 + .../Properties/Resources.Designer.cs | 17 + .../RemoteAuthenticationHandler.cs | 148 ++-- .../RemoteAuthenticationOptions.cs | 50 +- .../Resources.resx | 3 + .../SharedAuthenticationOptions.cs | 15 - .../SystemClock.cs | 1 - .../TokenExtensions.cs | 135 ---- .../CookiePolicyAppBuilderExtensions.cs | 10 +- .../AuthenticationHandlerFacts.cs | 282 ------- .../AuthenticationMiddlewareTests.cs | 181 +++++ .../Base64UrlTextEncoderTests.cs | 0 ...ookieMiddlewareTests.cs => CookieTests.cs} | 757 ++++++++---------- .../DynamicSchemeTests.cs | 134 ++++ ...ookMiddlewareTests.cs => FacebookTests.cs} | 243 ++++-- ...oogleMiddlewareTests.cs => GoogleTests.cs} | 454 ++++++----- ...erMiddlewareTests.cs => JwtBearerTests.cs} | 340 ++++---- ...soft.AspNetCore.Authentication.Test.csproj | 5 +- .../MicrosoftAccountMiddlewareTests.cs | 234 ------ .../MicrosoftAccountTests.cs | 291 +++++++ .../OAuthTests.cs | 173 ++++ .../OpenIdConnect/MockOpenIdConnectMessage.cs | 2 +- .../OpenIdConnectChallengeTests.cs | 79 +- .../OpenIdConnectConfigurationTests.cs | 125 +-- .../OpenIdConnect/OpenIdConnectEventTests.cs | 72 +- ...ddlewareTests.cs => OpenIdConnectTests.cs} | 107 ++- .../OpenIdConnect/TestServerBuilder.cs | 42 +- .../OpenIdConnect/TestServerExtensions.cs | 1 - .../OpenIdConnect/TestSettings.cs | 28 +- .../OpenIdConnect/TestTransaction.cs | 2 +- .../SecureDataFormatTests.cs | 0 .../TicketSerializerTests.cs | 0 .../TokenExtensionTests.cs | 102 ++- .../Twitter/TwitterMiddlewareTests.cs | 196 ----- .../TwitterTests.cs | 249 ++++++ ...osoft.AspNetCore.Authorization.Test.csproj | 4 - ....ChunkingCookieManager.Sources.Test.csproj | 4 - .../CookiePolicyTests.cs | 33 +- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 4 - .../CookieInteropTests.cs | 58 +- .../TicketInteropTests.cs | 2 +- 175 files changed, 4280 insertions(+), 5030 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerMiddleware.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/AuthAppBuilderExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/AuthenticationTicket.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/AuthenticationToken.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/ClaimsTransformationContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs rename src/Microsoft.AspNetCore.Authentication/{DataHandler => Data}/IDataSerializer.cs (100%) rename src/Microsoft.AspNetCore.Authentication/{DataHandler => Data}/ISecureDataFormat.cs (100%) rename src/Microsoft.AspNetCore.Authentication/{DataHandler => Data}/PropertiesDataFormat.cs (100%) rename src/Microsoft.AspNetCore.Authentication/{DataHandler => Data}/PropertiesSerializer.cs (100%) rename src/Microsoft.AspNetCore.Authentication/{DataHandler => Data}/SecureDataFormat.cs (100%) rename src/Microsoft.AspNetCore.Authentication/{DataHandler => Data}/TextEncoder.cs (100%) rename src/Microsoft.AspNetCore.Authentication/{DataHandler => Data}/TicketDataFormat.cs (100%) rename src/Microsoft.AspNetCore.Authentication/{DataHandler => Data}/TicketSerializer.cs (100%) delete mode 100644 src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/Events/IRemoteAuthenticationEvents.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs delete mode 100644 test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs rename test/Microsoft.AspNetCore.Authentication.Test/{DataHandler => }/Base64UrlTextEncoderTests.cs (100%) rename test/Microsoft.AspNetCore.Authentication.Test/{Cookies/CookieMiddlewareTests.cs => CookieTests.cs} (67%) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs rename test/Microsoft.AspNetCore.Authentication.Test/{Facebook/FacebookMiddlewareTests.cs => FacebookTests.cs} (53%) rename test/Microsoft.AspNetCore.Authentication.Test/{Google/GoogleMiddlewareTests.cs => GoogleTests.cs} (79%) rename test/Microsoft.AspNetCore.Authentication.Test/{JwtBearer/JwtBearerMiddlewareTests.cs => JwtBearerTests.cs} (75%) delete mode 100644 test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs rename test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/{OpenIdConnectMiddlewareTests.cs => OpenIdConnectTests.cs} (69%) rename test/Microsoft.AspNetCore.Authentication.Test/{DataHandler => }/SecureDataFormatTests.cs (100%) rename test/Microsoft.AspNetCore.Authentication.Test/{DataHandler => }/TicketSerializerTests.cs (100%) delete mode 100644 test/Microsoft.AspNetCore.Authentication.Test/Twitter/TwitterMiddlewareTests.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs diff --git a/Security.sln b/Security.sln index 50805feb16..81d0cc4b9c 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26020.0 +VisualStudioVersion = 15.0.26228.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -18,7 +18,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenIdConnectSample", "samp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Cookies", "src\Microsoft.AspNetCore.Authentication.Cookies\Microsoft.AspNetCore.Authentication.Cookies.csproj", "{FC152CC4-054B-457E-8D91-389C5DE3C561}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication", "src\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.csproj", "{2286250A-52C8-4126-9F93-B1E45F0AD078}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication", "src\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.csproj", "{BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Facebook", "src\Microsoft.AspNetCore.Authentication.Facebook\Microsoft.AspNetCore.Authentication.Facebook.csproj", "{EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}" EndProject @@ -58,9 +58,11 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|Mixed Platforms = Release|Mixed Platforms + Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution @@ -68,272 +70,364 @@ Global {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Debug|Any CPU.Build.0 = Debug|Any CPU {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Debug|x64.ActiveCfg = Debug|Any CPU + {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Debug|x64.Build.0 = Debug|Any CPU {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Debug|x86.ActiveCfg = Debug|Any CPU {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Release|Any CPU.ActiveCfg = Release|Any CPU {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Release|Any CPU.Build.0 = Release|Any CPU {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Release|x64.ActiveCfg = Release|Any CPU + {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Release|x64.Build.0 = Release|Any CPU {558C2C2A-AED8-49DE-BB60-D5F8AE06C714}.Release|x86.ActiveCfg = Release|Any CPU {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Debug|x64.ActiveCfg = Debug|Any CPU + {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Debug|x64.Build.0 = Debug|Any CPU {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Debug|x86.ActiveCfg = Debug|Any CPU {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Release|Any CPU.ActiveCfg = Release|Any CPU {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Release|Any CPU.Build.0 = Release|Any CPU {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Release|x64.ActiveCfg = Release|Any CPU + {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Release|x64.Build.0 = Release|Any CPU {8C73D216-332D-41D8-BFD0-45BC4BC36552}.Release|x86.ActiveCfg = Release|Any CPU {19711880-46DA-4A26-9E0F-9B2E41D27651}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {19711880-46DA-4A26-9E0F-9B2E41D27651}.Debug|Any CPU.Build.0 = Debug|Any CPU {19711880-46DA-4A26-9E0F-9B2E41D27651}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {19711880-46DA-4A26-9E0F-9B2E41D27651}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {19711880-46DA-4A26-9E0F-9B2E41D27651}.Debug|x64.ActiveCfg = Debug|Any CPU + {19711880-46DA-4A26-9E0F-9B2E41D27651}.Debug|x64.Build.0 = Debug|Any CPU {19711880-46DA-4A26-9E0F-9B2E41D27651}.Debug|x86.ActiveCfg = Debug|Any CPU {19711880-46DA-4A26-9E0F-9B2E41D27651}.Release|Any CPU.ActiveCfg = Release|Any CPU {19711880-46DA-4A26-9E0F-9B2E41D27651}.Release|Any CPU.Build.0 = Release|Any CPU {19711880-46DA-4A26-9E0F-9B2E41D27651}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {19711880-46DA-4A26-9E0F-9B2E41D27651}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {19711880-46DA-4A26-9E0F-9B2E41D27651}.Release|x64.ActiveCfg = Release|Any CPU + {19711880-46DA-4A26-9E0F-9B2E41D27651}.Release|x64.Build.0 = Release|Any CPU {19711880-46DA-4A26-9E0F-9B2E41D27651}.Release|x86.ActiveCfg = Release|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Debug|Any CPU.Build.0 = Debug|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Debug|x64.ActiveCfg = Debug|Any CPU + {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Debug|x64.Build.0 = Debug|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Debug|x86.ActiveCfg = Debug|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Debug|x86.Build.0 = Debug|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Release|Any CPU.ActiveCfg = Release|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Release|Any CPU.Build.0 = Release|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Release|x64.ActiveCfg = Release|Any CPU + {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Release|x64.Build.0 = Release|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Release|x86.ActiveCfg = Release|Any CPU {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B}.Release|x86.Build.0 = Release|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Debug|Any CPU.Build.0 = Debug|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {FC152CC4-054B-457E-8D91-389C5DE3C561}.Debug|x64.ActiveCfg = Debug|Any CPU + {FC152CC4-054B-457E-8D91-389C5DE3C561}.Debug|x64.Build.0 = Debug|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Debug|x86.ActiveCfg = Debug|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Debug|x86.Build.0 = Debug|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|Any CPU.ActiveCfg = Release|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|Any CPU.Build.0 = Release|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|x64.ActiveCfg = Release|Any CPU + {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|x64.Build.0 = Release|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|x86.ActiveCfg = Release|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|x86.Build.0 = Release|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Debug|x86.ActiveCfg = Debug|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Debug|x86.Build.0 = Debug|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Release|Any CPU.Build.0 = Release|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Release|x86.ActiveCfg = Release|Any CPU - {2286250A-52C8-4126-9F93-B1E45F0AD078}.Release|x86.Build.0 = Release|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|Any CPU.Build.0 = Debug|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|x64.ActiveCfg = Debug|Any CPU + {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|x64.Build.0 = Debug|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|x86.ActiveCfg = Debug|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|x86.Build.0 = Debug|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Release|Any CPU.ActiveCfg = Release|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Release|Any CPU.Build.0 = Release|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Release|x64.ActiveCfg = Release|Any CPU + {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Release|x64.Build.0 = Release|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Release|x86.ActiveCfg = Release|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Release|x86.Build.0 = Release|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Debug|Any CPU.Build.0 = Debug|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {76579C39-B829-490D-B8BE-1BD35FE8412E}.Debug|x64.ActiveCfg = Debug|Any CPU + {76579C39-B829-490D-B8BE-1BD35FE8412E}.Debug|x64.Build.0 = Debug|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Debug|x86.ActiveCfg = Debug|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Debug|x86.Build.0 = Debug|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Release|Any CPU.ActiveCfg = Release|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Release|Any CPU.Build.0 = Release|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {76579C39-B829-490D-B8BE-1BD35FE8412E}.Release|x64.ActiveCfg = Release|Any CPU + {76579C39-B829-490D-B8BE-1BD35FE8412E}.Release|x64.Build.0 = Release|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Release|x86.ActiveCfg = Release|Any CPU {76579C39-B829-490D-B8BE-1BD35FE8412E}.Release|x86.Build.0 = Release|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Debug|x64.ActiveCfg = Debug|Any CPU + {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Debug|x64.Build.0 = Debug|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Debug|x86.ActiveCfg = Debug|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Debug|x86.Build.0 = Debug|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Release|Any CPU.Build.0 = Release|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Release|x64.ActiveCfg = Release|Any CPU + {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Release|x64.Build.0 = Release|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Release|x86.ActiveCfg = Release|Any CPU {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A}.Release|x86.Build.0 = Release|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Debug|Any CPU.Build.0 = Debug|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Debug|x64.ActiveCfg = Debug|Any CPU + {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Debug|x64.Build.0 = Debug|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Debug|x86.ActiveCfg = Debug|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Debug|x86.Build.0 = Debug|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Release|Any CPU.ActiveCfg = Release|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Release|Any CPU.Build.0 = Release|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Release|x64.ActiveCfg = Release|Any CPU + {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Release|x64.Build.0 = Release|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Release|x86.ActiveCfg = Release|Any CPU {ACB45E19-F520-4D0C-8916-B0CEB9C017FE}.Release|x86.Build.0 = Release|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Debug|Any CPU.Build.0 = Debug|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {0330FFF6-B4B5-42DD-8C99-26A789569000}.Debug|x64.ActiveCfg = Debug|Any CPU + {0330FFF6-B4B5-42DD-8C99-26A789569000}.Debug|x64.Build.0 = Debug|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Debug|x86.ActiveCfg = Debug|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Debug|x86.Build.0 = Debug|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Release|Any CPU.ActiveCfg = Release|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Release|Any CPU.Build.0 = Release|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {0330FFF6-B4B5-42DD-8C99-26A789569000}.Release|x64.ActiveCfg = Release|Any CPU + {0330FFF6-B4B5-42DD-8C99-26A789569000}.Release|x64.Build.0 = Release|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Release|x86.ActiveCfg = Release|Any CPU {0330FFF6-B4B5-42DD-8C99-26A789569000}.Release|x86.Build.0 = Release|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Debug|Any CPU.Build.0 = Debug|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1657C79E-7755-4AEE-9D61-571295B69A30}.Debug|x64.ActiveCfg = Debug|Any CPU + {1657C79E-7755-4AEE-9D61-571295B69A30}.Debug|x64.Build.0 = Debug|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Debug|x86.ActiveCfg = Debug|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Debug|x86.Build.0 = Debug|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Release|Any CPU.ActiveCfg = Release|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Release|Any CPU.Build.0 = Release|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1657C79E-7755-4AEE-9D61-571295B69A30}.Release|x64.ActiveCfg = Release|Any CPU + {1657C79E-7755-4AEE-9D61-571295B69A30}.Release|x64.Build.0 = Release|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Release|x86.ActiveCfg = Release|Any CPU {1657C79E-7755-4AEE-9D61-571295B69A30}.Release|x86.Build.0 = Release|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Debug|Any CPU.Build.0 = Debug|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Debug|x64.ActiveCfg = Debug|Any CPU + {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Debug|x64.Build.0 = Debug|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Debug|x86.ActiveCfg = Debug|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Debug|x86.Build.0 = Debug|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Release|Any CPU.ActiveCfg = Release|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Release|Any CPU.Build.0 = Release|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Release|x64.ActiveCfg = Release|Any CPU + {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Release|x64.Build.0 = Release|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Release|x86.ActiveCfg = Release|Any CPU {8DA26CD1-1302-4CFD-9270-9FA1B7C6138B}.Release|x86.Build.0 = Release|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Debug|Any CPU.Build.0 = Debug|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Debug|x64.ActiveCfg = Debug|Any CPU + {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Debug|x64.Build.0 = Debug|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Debug|x86.ActiveCfg = Debug|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Debug|x86.Build.0 = Debug|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Release|Any CPU.ActiveCfg = Release|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Release|Any CPU.Build.0 = Release|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Release|x64.ActiveCfg = Release|Any CPU + {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Release|x64.Build.0 = Release|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Release|x86.ActiveCfg = Release|Any CPU {7AF5AD96-EB6E-4D0E-8ABE-C0B543C0F4C2}.Release|x86.Build.0 = Release|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Debug|Any CPU.Build.0 = Debug|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Debug|x64.ActiveCfg = Debug|Any CPU + {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Debug|x64.Build.0 = Debug|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Debug|x86.ActiveCfg = Debug|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Debug|x86.Build.0 = Debug|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Release|Any CPU.ActiveCfg = Release|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Release|Any CPU.Build.0 = Release|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Release|x64.ActiveCfg = Release|Any CPU + {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Release|x64.Build.0 = Release|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Release|x86.ActiveCfg = Release|Any CPU {6AB3E514-5894-4131-9399-DC7D5284ADDB}.Release|x86.Build.0 = Release|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Debug|Any CPU.Build.0 = Debug|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Debug|x64.ActiveCfg = Debug|Any CPU + {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Debug|x64.Build.0 = Debug|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Debug|x86.ActiveCfg = Debug|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Debug|x86.Build.0 = Debug|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Release|Any CPU.ActiveCfg = Release|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Release|Any CPU.Build.0 = Release|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Release|x64.ActiveCfg = Release|Any CPU + {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Release|x64.Build.0 = Release|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Release|x86.ActiveCfg = Release|Any CPU {86183DC3-02A8-4A68-8B60-71ECEC066E79}.Release|x86.Build.0 = Release|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Debug|Any CPU.Build.0 = Debug|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1790E052-646F-4529-B90E-6FEA95520D69}.Debug|x64.ActiveCfg = Debug|Any CPU + {1790E052-646F-4529-B90E-6FEA95520D69}.Debug|x64.Build.0 = Debug|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Debug|x86.ActiveCfg = Debug|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Debug|x86.Build.0 = Debug|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Release|Any CPU.ActiveCfg = Release|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Release|Any CPU.Build.0 = Release|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1790E052-646F-4529-B90E-6FEA95520D69}.Release|x64.ActiveCfg = Release|Any CPU + {1790E052-646F-4529-B90E-6FEA95520D69}.Release|x64.Build.0 = Release|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Release|x86.ActiveCfg = Release|Any CPU {1790E052-646F-4529-B90E-6FEA95520D69}.Release|x86.Build.0 = Release|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Debug|Any CPU.Build.0 = Debug|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Debug|x64.ActiveCfg = Debug|Any CPU + {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Debug|x64.Build.0 = Debug|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Debug|x86.ActiveCfg = Debug|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Debug|x86.Build.0 = Debug|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|Any CPU.ActiveCfg = Release|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|Any CPU.Build.0 = Release|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|x64.ActiveCfg = Release|Any CPU + {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|x64.Build.0 = Release|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|x86.ActiveCfg = Release|Any CPU {2755BFE5-7421-4A31-A644-F817DF5CAA98}.Release|x86.Build.0 = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|Any CPU.Build.0 = Debug|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|x64.ActiveCfg = Debug|Any CPU + {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|x64.Build.0 = Debug|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|x86.ActiveCfg = Debug|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Debug|x86.Build.0 = Debug|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|Any CPU.ActiveCfg = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|Any CPU.Build.0 = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x64.ActiveCfg = Release|Any CPU + {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x64.Build.0 = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.ActiveCfg = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.Build.0 = Release|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.Build.0 = Debug|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x64.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x64.Build.0 = Debug|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.ActiveCfg = Debug|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.Build.0 = Debug|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.ActiveCfg = Release|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.Build.0 = Release|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x64.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x64.Build.0 = Release|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.ActiveCfg = Release|Any CPU {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.Build.0 = Release|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.Build.0 = Debug|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x64.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x64.Build.0 = Debug|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.ActiveCfg = Debug|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.Build.0 = Debug|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.ActiveCfg = Release|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.Build.0 = Release|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x64.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x64.Build.0 = Release|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.ActiveCfg = Release|Any CPU {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.Build.0 = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.Build.0 = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|x64.ActiveCfg = Debug|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|x64.Build.0 = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|x86.ActiveCfg = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|x86.Build.0 = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|Any CPU.ActiveCfg = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|Any CPU.Build.0 = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|x64.ActiveCfg = Release|Any CPU + {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|x64.Build.0 = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|x86.ActiveCfg = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Release|x86.Build.0 = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Any CPU.Build.0 = Debug|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|x64.ActiveCfg = Debug|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|x64.Build.0 = Debug|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|x86.ActiveCfg = Debug|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Debug|x86.Build.0 = Debug|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|Any CPU.ActiveCfg = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|Any CPU.Build.0 = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x64.ActiveCfg = Release|Any CPU + {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x64.Build.0 = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.ActiveCfg = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x64.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x64.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x86.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x86.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Any CPU.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x64.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x64.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x86.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -344,7 +438,6 @@ Global {19711880-46DA-4A26-9E0F-9B2E41D27651} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {FC152CC4-054B-457E-8D91-389C5DE3C561} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} - {2286250A-52C8-4126-9F93-B1E45F0AD078} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {76579C39-B829-490D-B8BE-1BD35FE8412E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} @@ -362,5 +455,6 @@ Global {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} EndGlobalSection EndGlobal diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 002d878885..0480556f69 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Security.Claims; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -13,24 +14,21 @@ namespace CookieSample { public void ConfigureServices(IServiceCollection services) { - services.AddAuthentication(); + services.AddCookieAuthentication(); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { loggerfactory.AddConsole(LogLevel.Information); - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AutomaticAuthenticate = true - }); + app.UseAuthentication(); app.Run(async context => { if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) { var user = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "bob") }, CookieAuthenticationDefaults.AuthenticationScheme)); - await context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, user); + await context.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, user); context.Response.ContentType = "text/plain"; await context.Response.WriteAsync("Hello First timer"); diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index ecb61ab665..ca21070dcd 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -4,6 +4,7 @@ using System.Security.Claims; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -14,18 +15,14 @@ namespace CookieSessionSample { public void ConfigureServices(IServiceCollection services) { - services.AddAuthentication(); + services.AddCookieAuthentication(o => o.SessionStore = new MemoryCacheTicketStore()); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { loggerfactory.AddConsole(LogLevel.Information); - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AutomaticAuthenticate = true, - SessionStore = new MemoryCacheTicketStore() - }); + app.UseAuthentication(); app.Run(async context => { @@ -39,7 +36,7 @@ namespace CookieSessionSample claims.Add(new Claim(ClaimTypes.Role, "SomeRandomGroup" + i, ClaimValueTypes.String, "IssuedByBob", "OriginalIssuerJoe")); } - await context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, + await context.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme))); context.Response.ContentType = "text/plain"; diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index bfff3d5199..1f93103294 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -17,6 +17,7 @@ + diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 4d1ca74761..9df41a9ab7 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -42,39 +43,12 @@ namespace JwtBearerSample // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { - services.AddAuthentication(); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app) - { - // Simple error page to avoid a repo dependency. - app.Use(async (context, next) => - { - try - { - await next(); - } - catch (Exception ex) - { - if (context.Response.HasStarted) - { - throw; - } - context.Response.StatusCode = 500; - await context.Response.WriteAsync(ex.ToString()); - } - }); - - app.UseDefaultFiles(); - app.UseStaticFiles(); - - app.UseJwtBearerAuthentication(new JwtBearerOptions + services.AddJwtBearerAuthentication(o => { // You also need to update /wwwroot/app/scripts/app.js - Authority = Configuration["jwt:authority"], - Audience = Configuration["jwt:audience"], - Events = new JwtBearerEvents() + o.Authority = Configuration["jwt:authority"]; + o.Audience = Configuration["jwt:audience"]; + o.Events = new JwtBearerEvents() { OnAuthenticationFailed = c => { @@ -89,24 +63,34 @@ namespace JwtBearerSample } return c.Response.WriteAsync("An error occurred processing your authentication."); } - } + }; }); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app) + { + app.UseDeveloperExceptionPage(); + + app.UseDefaultFiles(); + app.UseStaticFiles(); + + app.UseAuthentication(); // [Authorize] would usually handle this app.Use(async (context, next) => { - // Use this if options.AutomaticAuthenticate = false + // Use this if there are multiple authentication schemes // var user = await context.Authentication.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme); - var user = context.User; // We can do this because of options.AutomaticAuthenticate = true; + var user = context.User; // We can do this because of there's only a single authentication scheme if (user?.Identity?.IsAuthenticated ?? false) { await next(); } else { - // We can do this because of options.AutomaticChallenge = true; - await context.Authentication.ChallengeAsync(); + await context.ChallengeAsync(); } }); @@ -135,5 +119,4 @@ namespace JwtBearerSample }); } } -} - +} \ No newline at end of file diff --git a/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs b/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs index 54989c13a4..7d9b391213 100644 --- a/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs +++ b/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs @@ -1,9 +1,8 @@ using System; using System.Security.Claims; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.IdentityModel.Clients.ActiveDirectory; namespace OpenIdConnect.AzureAdSample @@ -58,10 +57,9 @@ namespace OpenIdConnect.AzureAdSample private void BeforeAccessNotificationWithContext(TokenCacheNotificationArgs args) { // Retrieve the auth session with the cached tokens - var authenticateContext = new AuthenticateContext(_signInScheme); - _httpContext.Authentication.AuthenticateAsync(authenticateContext).Wait(); - _authProperties = new AuthenticationProperties(authenticateContext.Properties); - _principal = authenticateContext.Principal; + var result = _httpContext.AuthenticateAsync(_signInScheme).Result; + _authProperties = result.Ticket.Properties; + _principal = result.Ticket.Principal; BeforeAccessNotificationWithProperties(args); } @@ -87,7 +85,7 @@ namespace OpenIdConnect.AzureAdSample var cachedTokens = Serialize(); var cachedTokensText = Convert.ToBase64String(cachedTokens); _authProperties.Items[TokenCacheKey] = cachedTokensText; - _httpContext.Authentication.SignInAsync(_signInScheme, _principal, _authProperties).Wait(); + _httpContext.SignInAsync(_signInScheme, _principal, _authProperties).Wait(); } } diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index a5982549bf..a37c3659da 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -17,6 +17,7 @@ + diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index ec80cd651d..19bb0ac6a3 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -37,68 +37,55 @@ namespace OpenIdConnect.AzureAdSample public IConfiguration Configuration { get; set; } + private string ClientId => Configuration["oidc:clientid"]; + private string ClientSecret => Configuration["oidc:clientsecret"]; + private string Authority => Configuration["oidc:authority"]; + private string Resource => "https://graph.windows.net"; + public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(sharedOptions => - sharedOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); + { + sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; + }); + + services.AddCookieAuthentication(); + + services.AddOpenIdConnectAuthentication(o => + { + o.ClientId = ClientId; + o.ClientSecret = ClientSecret; // for code flow + o.Authority = Authority; + o.ResponseType = OpenIdConnectResponseType.CodeIdToken; + o.PostLogoutRedirectUri = "/signed-out"; + // GetClaimsFromUserInfoEndpoint = true, + o.Events = new OpenIdConnectEvents() + { + OnAuthorizationCodeReceived = async context => + { + var request = context.HttpContext.Request; + var currentUri = UriHelper.BuildAbsolute(request.Scheme, request.Host, request.PathBase, request.Path); + var credential = new ClientCredential(ClientId, ClientSecret); + var authContext = new AuthenticationContext(Authority, AuthPropertiesTokenCache.ForCodeRedemption(context.Properties)); + + var result = await authContext.AcquireTokenByAuthorizationCodeAsync( + context.ProtocolMessage.Code, new Uri(currentUri), credential, Resource); + + context.HandleCodeRedemption(result.AccessToken, result.IdToken); + } + }; + }); } public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { loggerfactory.AddConsole(Microsoft.Extensions.Logging.LogLevel.Information); - // Simple error page - app.Use(async (context, next) => - { - try - { - await next(); - } - catch (Exception ex) - { - if (!context.Response.HasStarted) - { - context.Response.Clear(); - context.Response.StatusCode = 500; - await context.Response.WriteAsync(ex.ToString()); - } - else - { - throw; - } - } - }); + app.UseDeveloperExceptionPage(); - app.UseCookieAuthentication(new CookieAuthenticationOptions()); - - var clientId = Configuration["oidc:clientid"]; - var clientSecret = Configuration["oidc:clientsecret"]; - var authority = Configuration["oidc:authority"]; - var resource = "https://graph.windows.net"; - app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions - { - ClientId = clientId, - ClientSecret = clientSecret, // for code flow - Authority = authority, - ResponseType = OpenIdConnectResponseType.CodeIdToken, - PostLogoutRedirectUri = "/signed-out", - // GetClaimsFromUserInfoEndpoint = true, - Events = new OpenIdConnectEvents() - { - OnAuthorizationCodeReceived = async context => - { - var request = context.HttpContext.Request; - var currentUri = UriHelper.BuildAbsolute(request.Scheme, request.Host, request.PathBase, request.Path); - var credential = new ClientCredential(clientId, clientSecret); - var authContext = new AuthenticationContext(authority, AuthPropertiesTokenCache.ForCodeRedemption(context.Properties)); - - var result = await authContext.AcquireTokenByAuthorizationCodeAsync( - context.ProtocolMessage.Code, new Uri(currentUri), credential, resource); - - context.HandleCodeRedemption(result.AccessToken, result.IdToken); - } - } - }); + app.UseAuthentication(); app.Run(async context => { @@ -111,13 +98,11 @@ namespace OpenIdConnect.AzureAdSample return; } - await context.Authentication.ChallengeAsync( - OpenIdConnectDefaults.AuthenticationScheme, - new AuthenticationProperties { RedirectUri = "/" }); + await context.ChallengeAsync(new AuthenticationProperties { RedirectUri = "/" }); } else if (context.Request.Path.Equals("/signout")) { - await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await WriteHtmlAsync(context.Response, async response => { @@ -127,8 +112,8 @@ namespace OpenIdConnect.AzureAdSample } else if (context.Request.Path.Equals("/signout-remote")) { - await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); } else if (context.Request.Path.Equals("/signed-out")) { @@ -141,7 +126,7 @@ namespace OpenIdConnect.AzureAdSample } else if (context.Request.Path.Equals("/remote-signedout")) { - await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await WriteHtmlAsync(context.Response, async response => { @@ -153,7 +138,7 @@ namespace OpenIdConnect.AzureAdSample { if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" }); + await context.ChallengeAsync(new AuthenticationProperties { RedirectUri = "/" }); return; } @@ -170,10 +155,10 @@ namespace OpenIdConnect.AzureAdSample try { // Use ADAL to get the right token - var authContext = new AuthenticationContext(authority, AuthPropertiesTokenCache.ForApiCalls(context, CookieAuthenticationDefaults.AuthenticationScheme)); - var credential = new ClientCredential(clientId, clientSecret); + var authContext = new AuthenticationContext(Authority, AuthPropertiesTokenCache.ForApiCalls(context, CookieAuthenticationDefaults.AuthenticationScheme)); + var credential = new ClientCredential(ClientId, ClientSecret); string userObjectID = context.User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; - var result = await authContext.AcquireTokenSilentAsync(resource, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId)); + var result = await authContext.AcquireTokenSilentAsync(Resource, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId)); await response.WriteAsync($"

access_token

{HtmlEncode(result.AccessToken)}
"); } diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index eaf3a2e87e..74661c2f32 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -18,6 +18,7 @@ + diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 587e1e9c16..5faa48b52a 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -42,46 +42,22 @@ namespace OpenIdConnectSample public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(sharedOptions => - sharedOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); - } - - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) - { - loggerfactory.AddConsole(LogLevel.Information); - loggerfactory.AddDebug(LogLevel.Information); - - // Simple error page - app.Use(async (context, next) => { - try - { - await next(); - } - catch (Exception ex) - { - if (!context.Response.HasStarted) - { - context.Response.Clear(); - context.Response.StatusCode = 500; - await context.Response.WriteAsync(ex.ToString()); - } - else - { - throw; - } - } + sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }); - app.UseCookieAuthentication(new CookieAuthenticationOptions()); + services.AddCookieAuthentication(); - app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions + services.AddOpenIdConnectAuthentication(o => { - ClientId = Configuration["oidc:clientid"], - ClientSecret = Configuration["oidc:clientsecret"], // for code flow - Authority = Configuration["oidc:authority"], - ResponseType = OpenIdConnectResponseType.CodeIdToken, - GetClaimsFromUserInfoEndpoint = true, - Events = new OpenIdConnectEvents() + o.ClientId = Configuration["oidc:clientid"]; + o.ClientSecret = Configuration["oidc:clientsecret"]; // for code flow + o.Authority = Configuration["oidc:authority"]; + o.ResponseType = OpenIdConnectResponseType.CodeIdToken; + o.GetClaimsFromUserInfoEndpoint = true; + o.Events = new OpenIdConnectEvents() { OnAuthenticationFailed = c => { @@ -96,8 +72,17 @@ namespace OpenIdConnectSample } return c.Response.WriteAsync("An error occurred processing your authentication."); } - } + }; }); + } + + public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + { + loggerfactory.AddConsole(LogLevel.Information); + loggerfactory.AddDebug(LogLevel.Information); + + app.UseDeveloperExceptionPage(); + app.UseAuthentication(); app.Run(async context => { @@ -113,7 +98,7 @@ namespace OpenIdConnectSample if (context.Request.Path.Equals("/signout")) { - await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await WriteHtmlAsync(context.Response, async res => { await context.Response.WriteAsync($"

Signed out {HtmlEncode(context.User.Identity.Name)}

"); @@ -125,8 +110,8 @@ namespace OpenIdConnectSample if (context.Request.Path.Equals("/signout-remote")) { // Redirects - await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties() + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties() { RedirectUri = "/signedout" }); @@ -135,7 +120,7 @@ namespace OpenIdConnectSample if (context.Request.Path.Equals("/Account/AccessDenied")) { - await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await WriteHtmlAsync(context.Response, async res => { await context.Response.WriteAsync($"

Access Denied for user {HtmlEncode(context.User.Identity.Name)} to resource '{HtmlEncode(context.Request.Query["ReturnUrl"])}'

"); @@ -144,24 +129,23 @@ namespace OpenIdConnectSample return; } - // CookieAuthenticationOptions.AutomaticAuthenticate = true (default) causes User to be set + // DefaultAuthenticateScheme causes User to be set var user = context.User; // This is what [Authorize] calls - // var user = await context.Authentication.AuthenticateAsync(AuthenticationManager.AutomaticScheme); + // var user = await context.AuthenticateAsync(); // This is what [Authorize(ActiveAuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)] calls - // var user = await context.Authentication.AuthenticateAsync(OpenIdConnectDefaults.AuthenticationScheme); + // var user = await context.AuthenticateAsync(OpenIdConnectDefaults.AuthenticationScheme); // Not authenticated if (user == null || !user.Identities.Any(identity => identity.IsAuthenticated)) { // This is what [Authorize] calls - // The cookie middleware will intercept this 401 and redirect to /login - await context.Authentication.ChallengeAsync(); + await context.ChallengeAsync(); // This is what [Authorize(ActiveAuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)] calls - // await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme); + // await context.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme); return; } @@ -169,11 +153,10 @@ namespace OpenIdConnectSample // Authenticated, but not authorized if (context.Request.Path.Equals("/restricted") && !user.Identities.Any(identity => identity.HasClaim("special", "true"))) { - await context.Authentication.ChallengeAsync(); + await context.ChallengeAsync(); return; } - await WriteHtmlAsync(context.Response, async response => { await response.WriteAsync($"

Hello Authenticated User {HtmlEncode(user.Identity.Name)}

"); diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 09ece106cb..fe63ab5ca0 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -22,6 +22,7 @@ +
diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 31ec187a02..3f64d813da 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -14,7 +14,6 @@ using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -45,38 +44,6 @@ namespace SocialSample public void ConfigureServices(IServiceCollection services) { - services.AddAuthentication(options => options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); - } - - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) - { - loggerfactory.AddConsole(LogLevel.Information); - - // Simple error page to avoid a repo dependency. - app.Use(async (context, next) => - { - try - { - await next(); - } - catch (Exception ex) - { - if (context.Response.HasStarted) - { - throw; - } - context.Response.StatusCode = 500; - await context.Response.WriteAsync(ex.ToString()); - } - }); - - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AutomaticAuthenticate = true, - AutomaticChallenge = true, - LoginPath = new PathString("/login") - }); - if (string.IsNullOrEmpty(Configuration["facebook:appid"])) { // User-Secrets: https://docs.asp.net/en/latest/security/app-secrets.html @@ -84,40 +51,51 @@ namespace SocialSample throw new InvalidOperationException("User secrets must be configured for each authentication provider."); } + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + + services.AddCookieAuthentication(o => o.LoginPath = new PathString("/login")); + // You must first create an app with Facebook and add its ID and Secret to your user-secrets. // https://developers.facebook.com/apps/ - app.UseFacebookAuthentication(new FacebookOptions + services.AddFacebookAuthentication(o => { - AppId = Configuration["facebook:appid"], - AppSecret = Configuration["facebook:appsecret"], - Scope = { "email" }, - Fields = { "name", "email" }, - SaveTokens = true, + o.AppId = Configuration["facebook:appid"]; + o.AppSecret = Configuration["facebook:appsecret"]; + o.Scope.Add("email"); + o.Fields.Add("name"); + o.Fields.Add("email"); + o.SaveTokens = true; }); // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project - app.UseOAuthAuthentication(new OAuthOptions + services.AddOAuthAuthentication("Google-AccessToken", o => { - AuthenticationScheme = "Google-AccessToken", - DisplayName = "Google-AccessToken", - ClientId = Configuration["google:clientid"], - ClientSecret = Configuration["google:clientsecret"], - CallbackPath = new PathString("/signin-google-token"), - AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint, - TokenEndpoint = GoogleDefaults.TokenEndpoint, - Scope = { "openid", "profile", "email" }, - SaveTokens = true + o.DisplayName = "Google-AccessToken"; + o.ClientId = Configuration["google:clientid"]; + o.ClientSecret = Configuration["google:clientsecret"]; + o.CallbackPath = new PathString("/signin-google-token"); + o.AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint; + o.TokenEndpoint = GoogleDefaults.TokenEndpoint; + o.Scope.Add("openid"); + o.Scope.Add("profile"); + o.Scope.Add("email"); + o.SaveTokens = true; }); // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project - var googleOptions = new GoogleOptions + services.AddGoogleAuthentication(o => { - ClientId = Configuration["google:clientid"], - ClientSecret = Configuration["google:clientsecret"], - SaveTokens = true, - Events = new OAuthEvents() + o.ClientId = Configuration["google:clientid"]; + o.ClientSecret = Configuration["google:clientsecret"]; + o.SaveTokens = true; + o.Events = new OAuthEvents() { OnRemoteFailure = ctx => { @@ -125,23 +103,23 @@ namespace SocialSample ctx.HandleResponse(); return Task.FromResult(0); } - } - }; - googleOptions.ClaimActions.MapJsonSubKey("urn:google:image", "image", "url"); - googleOptions.ClaimActions.Remove(ClaimTypes.GivenName); - app.UseGoogleAuthentication(googleOptions); + }; + o.ClaimActions.MapJsonSubKey("urn:google:image", "image", "url"); + o.ClaimActions.Remove(ClaimTypes.GivenName); + }); // You must first create an app with Twitter and add its key and Secret to your user-secrets. // https://apps.twitter.com/ - var twitterOptions = new TwitterOptions + services.AddTwitterAuthentication(o => { - ConsumerKey = Configuration["twitter:consumerkey"], - ConsumerSecret = Configuration["twitter:consumersecret"], + o.ConsumerKey = Configuration["twitter:consumerkey"]; + o.ConsumerSecret = Configuration["twitter:consumersecret"]; // http://stackoverflow.com/questions/22627083/can-we-get-email-id-from-twitter-oauth-api/32852370#32852370 // http://stackoverflow.com/questions/36330675/get-users-email-from-twitter-api-for-external-login-authentication-asp-net-mvc?lq=1 - RetrieveUserDetails = true, - SaveTokens = true, - Events = new TwitterEvents() + o.RetrieveUserDetails = true; + o.SaveTokens = true; + o.ClaimActions.MapJsonKey("urn:twitter:profilepicture", "profile_image_url", ClaimTypes.Uri); + o.Events = new TwitterEvents() { OnRemoteFailure = ctx => { @@ -149,10 +127,8 @@ namespace SocialSample ctx.HandleResponse(); return Task.FromResult(0); } - } - }; - twitterOptions.ClaimActions.MapJsonKey("urn:twitter:profilepicture", "profile_image_url", ClaimTypes.Uri); - app.UseTwitterAuthentication(twitterOptions); + }; + }); /* Azure AD app model v2 has restrictions that prevent the use of plain HTTP for redirect URLs. Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL: @@ -160,59 +136,60 @@ namespace SocialSample */ // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. // https://apps.dev.microsoft.com/ - app.UseOAuthAuthentication(new OAuthOptions + services.AddOAuthAuthentication("Microsoft-AccessToken", o => { - AuthenticationScheme = "Microsoft-AccessToken", - DisplayName = "MicrosoftAccount-AccessToken", - ClientId = Configuration["microsoftaccount:clientid"], - ClientSecret = Configuration["microsoftaccount:clientsecret"], - CallbackPath = new PathString("/signin-microsoft-token"), - AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint, - TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint, - Scope = { "https://graph.microsoft.com/user.read" }, - SaveTokens = true + o.DisplayName = "MicrosoftAccount-AccessToken"; + o.ClientId = Configuration["microsoftaccount:clientid"]; + o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; + o.CallbackPath = new PathString("/signin-microsoft-token"); + o.AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint; + o.TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; + o.Scope.Add("https://graph.microsoft.com/user.read"); + o.SaveTokens = true; }); // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. // https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/ - app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions + services.AddMicrosoftAccountAuthentication(o => { - DisplayName = "MicrosoftAccount", - ClientId = Configuration["microsoftaccount:clientid"], - ClientSecret = Configuration["microsoftaccount:clientsecret"], - SaveTokens = true + o.ClientId = Configuration["microsoftaccount:clientid"]; + o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; + o.SaveTokens = true; }); // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ - app.UseOAuthAuthentication(new OAuthOptions + services.AddOAuthAuthentication("GitHub-AccessToken", o => { - AuthenticationScheme = "GitHub-AccessToken", - DisplayName = "Github-AccessToken", - ClientId = Configuration["github-token:clientid"], - ClientSecret = Configuration["github-token:clientsecret"], - CallbackPath = new PathString("/signin-github-token"), - AuthorizationEndpoint = "https://github.com/login/oauth/authorize", - TokenEndpoint = "https://github.com/login/oauth/access_token", - SaveTokens = true + o.DisplayName = "Github-AccessToken"; + o.ClientId = Configuration["github-token:clientid"]; + o.ClientSecret = Configuration["github-token:clientsecret"]; + o.CallbackPath = new PathString("/signin-github-token"); + o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; + o.TokenEndpoint = "https://github.com/login/oauth/access_token"; + o.SaveTokens = true; + o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); + o.ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); + o.ClaimActions.MapJsonKey("urn:github:name", "name"); + o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); + o.ClaimActions.MapJsonKey("urn:github:url", "url"); }); // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ - var githubOptions = new OAuthOptions + services.AddOAuthAuthentication("GitHub", o => { - AuthenticationScheme = "GitHub", - DisplayName = "Github", - ClientId = Configuration["github:clientid"], - ClientSecret = Configuration["github:clientsecret"], - CallbackPath = new PathString("/signin-github"), - AuthorizationEndpoint = "https://github.com/login/oauth/authorize", - TokenEndpoint = "https://github.com/login/oauth/access_token", - UserInformationEndpoint = "https://api.github.com/user", - ClaimsIssuer = "OAuth2-Github", - SaveTokens = true, + o.DisplayName = "Github"; + o.ClientId = Configuration["github:clientid"]; + o.ClientSecret = Configuration["github:clientsecret"]; + o.CallbackPath = new PathString("/signin-github"); + o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; + o.TokenEndpoint = "https://github.com/login/oauth/access_token"; + o.UserInformationEndpoint = "https://api.github.com/user"; + o.ClaimsIssuer = "OAuth2-Github"; + o.SaveTokens = true; // Retrieving user information is unique to each provider. - Events = new OAuthEvents + o.Events = new OAuthEvents { OnCreatingTicket = async context => { @@ -228,14 +205,17 @@ namespace SocialSample context.RunClaimActions(user); } - } - }; - githubOptions.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); - githubOptions.ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); - githubOptions.ClaimActions.MapJsonKey("urn:github:name", "name"); - githubOptions.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); - githubOptions.ClaimActions.MapJsonKey("urn:github:url", "url"); - app.UseOAuthAuthentication(githubOptions); + }; + }); + } + + public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + { + loggerfactory.AddConsole(LogLevel.Information); + + app.UseDeveloperExceptionPage(); + + app.UseAuthentication(); // Choose an authentication type app.Map("/login", signinApp => @@ -247,16 +227,18 @@ namespace SocialSample { // By default the client will be redirect back to the URL that issued the challenge (/login?authtype=foo), // send them to the home page instead (/). - await context.Authentication.ChallengeAsync(authType, new AuthenticationProperties() { RedirectUri = "/" }); + await context.ChallengeAsync(authType, new AuthenticationProperties() { RedirectUri = "/" }); return; } context.Response.ContentType = "text/html"; await context.Response.WriteAsync(""); await context.Response.WriteAsync("Choose an authentication scheme:
"); - foreach (var type in context.Authentication.GetAuthenticationSchemes()) + var schemeProvider = context.RequestServices.GetRequiredService(); + foreach (var provider in await schemeProvider.GetAllSchemesAsync()) { - await context.Response.WriteAsync("" + (type.DisplayName ?? "(suppressed)") + "
"); + // REVIEW: we lost access to display name (which is buried in the handler options) + await context.Response.WriteAsync("" + (provider.Name ?? "(suppressed)") + "
"); } await context.Response.WriteAsync(""); }); @@ -268,7 +250,7 @@ namespace SocialSample signoutApp.Run(async context => { context.Response.ContentType = "text/html"; - await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await context.Response.WriteAsync(""); await context.Response.WriteAsync("You have been logged out. Goodbye " + context.User.Identity.Name + "
"); await context.Response.WriteAsync("Home"); @@ -292,24 +274,24 @@ namespace SocialSample app.Run(async context => { - // CookieAuthenticationOptions.AutomaticAuthenticate = true (default) causes User to be set + // Setting DefaultAuthenticateScheme causes User to be set var user = context.User; // This is what [Authorize] calls - // var user = await context.Authentication.AuthenticateAsync(AuthenticationManager.AutomaticScheme); + // var user = await context.AuthenticateAsync(); // This is what [Authorize(ActiveAuthenticationSchemes = MicrosoftAccountDefaults.AuthenticationScheme)] calls - // var user = await context.Authentication.AuthenticateAsync(MicrosoftAccountDefaults.AuthenticationScheme); + // var user = await context.AuthenticateAsync(MicrosoftAccountDefaults.AuthenticationScheme); // Deny anonymous request beyond this point. if (user == null || !user.Identities.Any(identity => identity.IsAuthenticated)) { // This is what [Authorize] calls // The cookie middleware will intercept this 401 and redirect to /login - await context.Authentication.ChallengeAsync(); + await context.ChallengeAsync(); // This is what [Authorize(ActiveAuthenticationSchemes = MicrosoftAccountDefaults.AuthenticationScheme)] calls - // await context.Authentication.ChallengeAsync(MicrosoftAccountDefaults.AuthenticationScheme); + // await context.ChallengeAsync(MicrosoftAccountDefaults.AuthenticationScheme); return; } @@ -324,11 +306,11 @@ namespace SocialSample } await context.Response.WriteAsync("Tokens:
"); - - await context.Response.WriteAsync("Access Token: " + await context.Authentication.GetTokenAsync("access_token") + "
"); - await context.Response.WriteAsync("Refresh Token: " + await context.Authentication.GetTokenAsync("refresh_token") + "
"); - await context.Response.WriteAsync("Token Type: " + await context.Authentication.GetTokenAsync("token_type") + "
"); - await context.Response.WriteAsync("expires_at: " + await context.Authentication.GetTokenAsync("expires_at") + "
"); + + await context.Response.WriteAsync("Access Token: " + await context.GetTokenAsync("access_token") + "
"); + await context.Response.WriteAsync("Refresh Token: " + await context.GetTokenAsync("refresh_token") + "
"); + await context.Response.WriteAsync("Token Type: " + await context.GetTokenAsync("token_type") + "
"); + await context.Response.WriteAsync("expires_at: " + await context.GetTokenAsync("expires_at") + "
"); await context.Response.WriteAsync("Logout
"); await context.Response.WriteAsync(""); }); diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs index 765d1f51cd..bb5cdfff0e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs @@ -1,9 +1,8 @@ -// 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. using System; using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { @@ -13,38 +12,26 @@ namespace Microsoft.AspNetCore.Builder public static class CookieAppBuilderExtensions { /// - /// Adds the middleware to the specified , which enables cookie authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. + /// The to add the handler to. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuilder app) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - return app.UseMiddleware(); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Adds the middleware to the specified , which enables cookie authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. - /// A that specifies options for the middleware. + /// The to add the handler to. + /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuilder app, CookieAuthenticationOptions options) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(Options.Create(options)); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs index ad0e17a096..700b607976 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.Cookies { /// - /// Default values related to cookie-based authentication middleware + /// Default values related to cookie-based authentication handler /// public static class CookieAuthenticationDefaults { diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 1f2b395b1d..017e7911cc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -1,32 +1,97 @@ // 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.Linq; using System.Security.Claims; +using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Internal; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Authentication.Cookies { - internal class CookieAuthenticationHandler : AuthenticationHandler + public class CookieAuthenticationHandler : AuthenticationHandler { private const string HeaderValueNoCache = "no-cache"; private const string HeaderValueMinusOne = "-1"; private const string SessionIdClaim = "Microsoft.AspNetCore.Authentication.Cookies-SessionId"; private bool _shouldRefresh; + private bool _signInCalled; + private bool _signOutCalled; + private DateTimeOffset? _refreshIssuedUtc; private DateTimeOffset? _refreshExpiresUtc; private string _sessionKey; private Task _readCookieTask; + public CookieAuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) + { } + + /// + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// If it is not provided a default instance is supplied which does nothing when the methods are called. + /// + protected new CookieAuthenticationEvents Events + { + get { return (CookieAuthenticationEvents)base.Events; } + set { base.Events = value; } + } + + protected override Task InitializeHandlerAsync() + { + // Cookies needs to finish the response + Context.Response.OnStarting(FinishResponseAsync); + return TaskCache.CompletedTask; + } + + /// + /// Creates a new instance of the events instance. + /// + /// A new instance of the events instance. + protected override Task CreateEventsAsync() => Task.FromResult(new CookieAuthenticationEvents()); + + protected override void InitializeOptions() + { + base.InitializeOptions(); + + if (String.IsNullOrEmpty(Options.CookieName)) + { + Options.CookieName = CookieAuthenticationDefaults.CookiePrefix + Scheme.Name; + } + if (Options.TicketDataFormat == null) + { + var provider = Options.DataProtectionProvider ?? Context.RequestServices.GetRequiredService(); + // Note: the purpose for the data protector must remain fixed for interop to work. + var dataProtector = provider.CreateProtector("Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", Scheme.Name, "v2"); + Options.TicketDataFormat = new TicketDataFormat(dataProtector); + } + if (Options.CookieManager == null) + { + Options.CookieManager = new ChunkingCookieManager(); + } + if (!Options.LoginPath.HasValue) + { + Options.LoginPath = CookieAuthenticationDefaults.LoginPath; + } + if (!Options.LogoutPath.HasValue) + { + Options.LogoutPath = CookieAuthenticationDefaults.LogoutPath; + } + if (!Options.AccessDeniedPath.HasValue) + { + Options.AccessDeniedPath = CookieAuthenticationDefaults.AccessDeniedPath; + } + } + private Task EnsureCookieTicket() { // We only need to read the ticket once @@ -39,7 +104,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies private void CheckForRefresh(AuthenticationTicket ticket) { - var currentUtc = Options.SystemClock.UtcNow; + var currentUtc = Clock.UtcNow; var issuedUtc = ticket.Properties.IssuedUtc; var expiresUtc = ticket.Properties.ExpiresUtc; var allowRefresh = ticket.Properties.AllowRefresh ?? true; @@ -63,7 +128,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (issuedUtc != null && expiresUtc != null) { _shouldRefresh = true; - var currentUtc = Options.SystemClock.UtcNow; + var currentUtc = Clock.UtcNow; _refreshIssuedUtc = currentUtc; var timeSpan = expiresUtc.Value.Subtract(issuedUtc.Value); _refreshExpiresUtc = currentUtc.Add(timeSpan); @@ -75,7 +140,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var cookie = Options.CookieManager.GetRequestCookie(Context, Options.CookieName); if (string.IsNullOrEmpty(cookie)) { - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } var ticket = Options.TicketDataFormat.Unprotect(cookie, GetTlsTokenBinding()); @@ -99,7 +164,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } } - var currentUtc = Options.SystemClock.UtcNow; + var currentUtc = Clock.UtcNow; var issuedUtc = ticket.Properties.IssuedUtc; var expiresUtc = ticket.Properties.ExpiresUtc; @@ -126,8 +191,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies return result; } - var context = new CookieValidatePrincipalContext(Context, result.Ticket, Options); - await Options.Events.ValidatePrincipal(context); + var context = new CookieValidatePrincipalContext(Context, Scheme, result.Ticket, Options); + await Events.ValidatePrincipal(context); if (context.Principal == null) { @@ -139,7 +204,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies RequestRefresh(result.Ticket); } - return AuthenticateResult.Success(new AuthenticationTicket(context.Principal, context.Properties, Options.AuthenticationScheme)); + return AuthenticateResult.Success(new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name)); } private CookieOptions BuildCookieOptions() @@ -163,10 +228,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies return cookieOptions; } - protected override async Task FinishResponseAsync() + protected virtual async Task FinishResponseAsync() { // Only renew if requested, and neither sign in or sign out was called - if (!_shouldRefresh || SignInAccepted || SignOutAccepted) + if (!_shouldRefresh || _signInCalled || _signOutCalled) { return; } @@ -192,8 +257,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var principal = new ClaimsPrincipal( new ClaimsIdentity( new[] { new Claim(SessionIdClaim, _sessionKey, ClaimValueTypes.String, Options.ClaimsIssuer) }, - Options.AuthenticationScheme)); - ticket = new AuthenticationTicket(principal, null, Options.AuthenticationScheme); + Scheme.Name)); + ticket = new AuthenticationTicket(principal, null, Scheme.Name); } var cookieValue = Options.TicketDataFormat.Protect(ticket, GetTlsTokenBinding()); @@ -216,16 +281,18 @@ namespace Microsoft.AspNetCore.Authentication.Cookies protected override async Task HandleSignInAsync(SignInContext signin) { + _signInCalled = true; + // Process the request cookie to initialize members like _sessionKey. var result = await EnsureCookieTicket(); var cookieOptions = BuildCookieOptions(); var signInContext = new CookieSigningInContext( Context, + Scheme, Options, - Options.AuthenticationScheme, signin.Principal, - new AuthenticationProperties(signin.Properties), + signin.Properties, cookieOptions); DateTimeOffset issuedUtc; @@ -235,7 +302,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } else { - issuedUtc = Options.SystemClock.UtcNow; + issuedUtc = Clock.UtcNow; signInContext.Properties.IssuedUtc = issuedUtc; } @@ -244,7 +311,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.ExpireTimeSpan); } - await Options.Events.SigningIn(signInContext); + await Events.SigningIn(signInContext); if (signInContext.Properties.IsPersistent) { @@ -264,7 +331,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies new ClaimsIdentity( new[] { new Claim(SessionIdClaim, _sessionKey, ClaimValueTypes.String, Options.ClaimsIssuer) }, Options.ClaimsIssuer)); - ticket = new AuthenticationTicket(principal, null, Options.AuthenticationScheme); + ticket = new AuthenticationTicket(principal, null, Scheme.Name); } var cookieValue = Options.TicketDataFormat.Protect(ticket, GetTlsTokenBinding()); @@ -277,12 +344,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var signedInContext = new CookieSignedInContext( Context, + Scheme, Options, - Options.AuthenticationScheme, + Scheme.Name, signInContext.Principal, signInContext.Properties); - await Options.Events.SignedIn(signedInContext); + await Events.SignedIn(signedInContext); // Only redirect on the login path var shouldRedirect = Options.LoginPath.HasValue && OriginalPath == Options.LoginPath; @@ -291,6 +359,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies protected override async Task HandleSignOutAsync(SignOutContext signOutContext) { + _signOutCalled = true; + // Process the request cookie to initialize members like _sessionKey. var ticket = await EnsureCookieTicket(); var cookieOptions = BuildCookieOptions(); @@ -301,11 +371,12 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var context = new CookieSigningOutContext( Context, + Scheme, Options, - new AuthenticationProperties(signOutContext.Properties), + signOutContext.Properties, cookieOptions); - await Options.Events.SigningOut(context); + await Events.SigningOut(context); Options.CookieManager.DeleteCookie( Context, @@ -343,8 +414,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (redirectUri != null) { - await Options.Events.RedirectToReturnUrl( - new CookieRedirectContext(Context, Options, redirectUri, properties)); + await Events.RedirectToReturnUrl( + new CookieRedirectContext(Context, Scheme, Options, redirectUri, properties)); } } } @@ -362,28 +433,27 @@ namespace Microsoft.AspNetCore.Authentication.Cookies return path[0] == '/' && path[1] != '/' && path[1] != '\\'; } - protected override async Task HandleForbiddenAsync(ChallengeContext context) + protected override async Task HandleForbiddenAsync(ChallengeContext context) { - var properties = new AuthenticationProperties(context.Properties); + var properties = context.Properties; var returnUrl = properties.RedirectUri; if (string.IsNullOrEmpty(returnUrl)) { returnUrl = OriginalPathBase + Request.Path + Request.QueryString; } var accessDeniedUri = Options.AccessDeniedPath + QueryString.Create(Options.ReturnUrlParameter, returnUrl); - var redirectContext = new CookieRedirectContext(Context, Options, BuildRedirectUri(accessDeniedUri), properties); - await Options.Events.RedirectToAccessDenied(redirectContext); - return true; + var redirectContext = new CookieRedirectContext(Context, Scheme, Options, BuildRedirectUri(accessDeniedUri), properties); + await Events.RedirectToAccessDenied(redirectContext); } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } - var properties = new AuthenticationProperties(context.Properties); + var properties = context.Properties; var redirectUri = properties.RedirectUri; if (string.IsNullOrEmpty(redirectUri)) { @@ -391,10 +461,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } var loginUri = Options.LoginPath + QueryString.Create(Options.ReturnUrlParameter, redirectUri); - var redirectContext = new CookieRedirectContext(Context, Options, BuildRedirectUri(loginUri), properties); - await Options.Events.RedirectToLogin(redirectContext); - return true; - + var redirectContext = new CookieRedirectContext(Context, Scheme, Options, BuildRedirectUri(loginUri), properties); + await Events.RedirectToLogin(redirectContext); } private string GetTlsTokenBinding() diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs deleted file mode 100644 index 14d152a818..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationMiddleware.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.Cookies -{ - public class CookieAuthenticationMiddleware : AuthenticationMiddleware - { - public CookieAuthenticationMiddleware( - RequestDelegate next, - IDataProtectionProvider dataProtectionProvider, - ILoggerFactory loggerFactory, - UrlEncoder urlEncoder, - IOptions options) - : base(next, options, loggerFactory, urlEncoder) - { - if (dataProtectionProvider == null) - { - throw new ArgumentNullException(nameof(dataProtectionProvider)); - } - - if (Options.Events == null) - { - Options.Events = new CookieAuthenticationEvents(); - } - if (String.IsNullOrEmpty(Options.CookieName)) - { - Options.CookieName = CookieAuthenticationDefaults.CookiePrefix + Options.AuthenticationScheme; - } - if (Options.TicketDataFormat == null) - { - var provider = Options.DataProtectionProvider ?? dataProtectionProvider; - var dataProtector = provider.CreateProtector(typeof(CookieAuthenticationMiddleware).FullName, Options.AuthenticationScheme, "v2"); - Options.TicketDataFormat = new TicketDataFormat(dataProtector); - } - if (Options.CookieManager == null) - { - Options.CookieManager = new ChunkingCookieManager(); - } - if (!Options.LoginPath.HasValue) - { - Options.LoginPath = CookieAuthenticationDefaults.LoginPath; - } - if (!Options.LogoutPath.HasValue) - { - Options.LogoutPath = CookieAuthenticationDefaults.LogoutPath; - } - if (!Options.AccessDeniedPath.HasValue) - { - Options.AccessDeniedPath = CookieAuthenticationDefaults.AccessDeniedPath; - } - } - - protected override AuthenticationHandler CreateHandler() - { - return new CookieAuthenticationHandler(); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index b425612508..56d6ca238a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -2,19 +2,15 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.ComponentModel; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Authentication.Cookies { /// - /// Configuration options for . + /// Configuration options for . /// - public class CookieAuthenticationOptions : AuthenticationOptions, IOptions + public class CookieAuthenticationOptions : AuthenticationSchemeOptions { private string _cookieName; @@ -23,21 +19,18 @@ namespace Microsoft.AspNetCore.Builder /// public CookieAuthenticationOptions() { - AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme; - AutomaticAuthenticate = true; ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; CookieHttpOnly = true; CookieSecure = CookieSecurePolicy.SameAsRequest; - SystemClock = new SystemClock(); Events = new CookieAuthenticationEvents(); } /// /// Determines the cookie name used to persist the identity. The default value is ".AspNetCore.Cookies". /// This value should be changed if you change the name of the AuthenticationScheme, especially if your - /// system uses the cookie authentication middleware multiple times. + /// system uses the cookie authentication handler multiple times. /// public string CookieName { @@ -90,13 +83,13 @@ namespace Microsoft.AspNetCore.Builder public TimeSpan ExpireTimeSpan { get; set; } /// - /// The SlidingExpiration is set to true to instruct the middleware to re-issue a new cookie with a new + /// The SlidingExpiration is set to true to instruct the handler to re-issue a new cookie with a new /// expiration time any time it processes a request which is more than halfway through the expiration window. /// public bool SlidingExpiration { get; set; } /// - /// The LoginPath property informs the middleware that it should change an outgoing 401 Unauthorized status + /// The LoginPath property informs the handler that it should change an outgoing 401 Unauthorized status /// code into a 302 redirection onto the given login path. The current url which generated the 401 is added /// to the LoginPath as a query string parameter named by the ReturnUrlParameter. Once a request to the /// LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect the browser back @@ -105,18 +98,18 @@ namespace Microsoft.AspNetCore.Builder public PathString LoginPath { get; set; } /// - /// If the LogoutPath is provided the middleware then a request to that path will redirect based on the ReturnUrlParameter. + /// If the LogoutPath is provided the handler then a request to that path will redirect based on the ReturnUrlParameter. /// public PathString LogoutPath { get; set; } /// - /// The AccessDeniedPath property informs the middleware that it should change an outgoing 403 Forbidden status + /// The AccessDeniedPath property informs the handler that it should change an outgoing 403 Forbidden status /// code into a 302 redirection onto the given path. /// public PathString AccessDeniedPath { get; set; } /// - /// The ReturnUrlParameter determines the name of the query string parameter which is appended by the middleware + /// The ReturnUrlParameter determines the name of the query string parameter which is appended by the handler /// when a 401 Unauthorized status code is changed to a 302 redirect onto the login path. This is also the query /// string parameter looked for when a request arrives on the login path or logout path, in order to return to the /// original url after the action is performed. @@ -124,11 +117,15 @@ namespace Microsoft.AspNetCore.Builder public string ReturnUrlParameter { get; set; } /// - /// The Provider may be assigned to an instance of an object created by the application at startup time. The middleware + /// The Provider may be assigned to an instance of an object created by the application at startup time. The handler /// calls methods on the provider which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// - public ICookieAuthenticationEvents Events { get; set; } + public new CookieAuthenticationEvents Events + { + get { return (CookieAuthenticationEvents)base.Events; } + set { base.Events = value; } + } /// /// The TicketDataFormat is used to protect and unprotect the identity and other properties which are stored in the @@ -150,13 +147,5 @@ namespace Microsoft.AspNetCore.Builder /// to the client. This can be used to mitigate potential problems with very large identities. /// public ITicketStore SessionStore { get; set; } - - CookieAuthenticationOptions IOptions.Value - { - get - { - return this; - } - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs new file mode 100644 index 0000000000..e8a21d01b1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -0,0 +1,21 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication.Cookies; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class CookieExtensions + { + public static IServiceCollection AddCookieAuthentication(this IServiceCollection services) => services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme); + + public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme) => services.AddCookieAuthentication(authenticationScheme, configureOptions: null); + + public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, Action configureOptions) => + services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions); + + public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) => + services.AddScheme(authenticationScheme, configureOptions); + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs index e5423fed23..4c949bb089 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs @@ -2,17 +2,18 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.Cookies { - public class BaseCookieContext : BaseContext + public class BaseCookieContext : BaseAuthenticationContext { public BaseCookieContext( HttpContext context, - CookieAuthenticationOptions options) - : base(context) + AuthenticationScheme scheme, + CookieAuthenticationOptions options, + AuthenticationProperties properties) + : base(context, scheme.Name, properties) { if (options == null) { @@ -23,5 +24,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } public CookieAuthenticationOptions Options { get; } + + public AuthenticationScheme Scheme { get; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs index 4364a2e546..5cb933ce1d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// application only needs to override a few of the interface methods. This may be used as a base class /// or may be instantiated directly. /// - public class CookieAuthenticationEvents : ICookieAuthenticationEvents + public class CookieAuthenticationEvents { /// /// A delegate assigned to this property will be invoked when the related method is called. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs index 2cbb5ff095..e4259d181e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs @@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.Cookies { /// - /// Context passed when a Challenge, SignIn, or SignOut causes a redirect in the cookie middleware + /// Context passed when a Challenge, SignIn, or SignOut causes a redirect in the cookie handler /// public class CookieRedirectContext : BaseCookieContext { @@ -16,21 +16,19 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// Creates a new context object. /// /// The HTTP request context - /// The cookie middleware options + /// The scheme data + /// The cookie handler options /// The initial redirect URI /// The . - public CookieRedirectContext(HttpContext context, CookieAuthenticationOptions options, string redirectUri, AuthenticationProperties properties) - : base(context, options) + public CookieRedirectContext(HttpContext context, AuthenticationScheme scheme, CookieAuthenticationOptions options, string redirectUri, AuthenticationProperties properties) + : base(context, scheme, options, properties) { RedirectUri = redirectUri; - Properties = properties; } /// /// Gets or Sets the URI used for the redirect operation. /// public string RedirectUri { get; set; } - - public AuthenticationProperties Properties { get; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs index cfb7c5f1d8..0e610c8b2d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -17,36 +15,26 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// Creates a new instance of the context object. /// /// The HTTP request context - /// The middleware options + /// The scheme data + /// The handler options /// Initializes AuthenticationScheme property /// Initializes Principal property /// Initializes Properties property public CookieSignedInContext( HttpContext context, + AuthenticationScheme scheme, CookieAuthenticationOptions options, string authenticationScheme, ClaimsPrincipal principal, AuthenticationProperties properties) - : base(context, options) + : base(context, scheme, options, properties) { - AuthenticationScheme = authenticationScheme; Principal = principal; - Properties = properties; } - /// - /// The name of the AuthenticationScheme creating a cookie - /// - public string AuthenticationScheme { get; } - /// /// Contains the claims that were converted into the outgoing cookie. /// public ClaimsPrincipal Principal { get; } - - /// - /// Contains the extra data that was contained in the outgoing cookie. - /// - public AuthenticationProperties Properties { get; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs index d8b2307f32..b91cb7e184 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -17,43 +15,30 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// Creates a new instance of the context object. /// /// The HTTP request context - /// The middleware options - /// Initializes AuthenticationScheme property + /// The scheme data + /// The handler options /// Initializes Principal property /// Initializes Extra property /// Initializes options for the authentication cookie. public CookieSigningInContext( HttpContext context, + AuthenticationScheme scheme, CookieAuthenticationOptions options, - string authenticationScheme, ClaimsPrincipal principal, AuthenticationProperties properties, CookieOptions cookieOptions) - : base(context, options) + : base(context, scheme, options, properties) { - AuthenticationScheme = authenticationScheme; Principal = principal; - Properties = properties; CookieOptions = cookieOptions; } - /// - /// The name of the AuthenticationScheme creating a cookie - /// - public string AuthenticationScheme { get; } - /// /// Contains the claims about to be converted into the outgoing cookie. /// May be replaced or altered during the SigningIn call. /// public ClaimsPrincipal Principal { get; set; } - /// - /// Contains the extra data about to be contained in the outgoing cookie. - /// May be replaced or altered during the SigningIn call. - /// - public AuthenticationProperties Properties { get; set; } - /// /// The options for creating the outgoing cookie. /// May be replace or altered during the SigningIn call. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs index 51c04a56b9..0f4f4c7dcf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs @@ -1,9 +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 Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -16,18 +14,19 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// /// + /// /// /// /// public CookieSigningOutContext( - HttpContext context, + HttpContext context, + AuthenticationScheme scheme, CookieAuthenticationOptions options, AuthenticationProperties properties, CookieOptions cookieOptions) - : base(context, options) + : base(context, scheme, options, properties) { CookieOptions = cookieOptions; - Properties = properties; } /// @@ -35,7 +34,5 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// May be replace or altered during the SigningOut call. /// public CookieOptions CookieOptions { get; set; } - - public AuthenticationProperties Properties { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs index 57a28191c8..3232ba52ff 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs @@ -3,14 +3,12 @@ using System; using System.Security.Claims; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.Cookies { /// - /// Context object passed to the ICookieAuthenticationProvider method ValidatePrincipal. + /// Context object passed to the CookieAuthenticationEvents ValidatePrincipal method. /// public class CookieValidatePrincipalContext : BaseCookieContext { @@ -18,10 +16,11 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// Creates a new instance of the context object. /// /// + /// /// Contains the initial values for identity and extra data /// - public CookieValidatePrincipalContext(HttpContext context, AuthenticationTicket ticket, CookieAuthenticationOptions options) - : base(context, options) + public CookieValidatePrincipalContext(HttpContext context, AuthenticationScheme scheme, AuthenticationTicket ticket, CookieAuthenticationOptions options) + : base(context, scheme, options, ticket?.Properties) { if (context == null) { @@ -39,7 +38,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } Principal = ticket.Principal; - Properties = ticket.Properties; } /// @@ -48,11 +46,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// public ClaimsPrincipal Principal { get; private set; } - /// - /// Contains the extra meta-data arriving with the request ticket. May be altered. - /// - public AuthenticationProperties Properties { get; private set; } - /// /// If true, the cookie will be renewed /// diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs deleted file mode 100644 index 1406d872dc..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/ICookieAuthenticationEvents.cs +++ /dev/null @@ -1,64 +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.Threading.Tasks; - -namespace Microsoft.AspNetCore.Authentication.Cookies -{ - /// - /// Specifies callback methods which the invokes to enable developer control over the authentication process. /> - /// - public interface ICookieAuthenticationEvents - { - /// - /// Called each time a request principal has been validated by the middleware. By implementing this method the - /// application may alter or reject the principal which has arrived with the request. - /// - /// Contains information about the login session as well as the user . - /// A representing the completed operation. - Task ValidatePrincipal(CookieValidatePrincipalContext context); - - /// - /// Called when an endpoint has provided sign in information before it is converted into a cookie. By - /// 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 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 SignedIn(CookieSignedInContext context); - - /// - /// Called when a SignOut causes a redirect in the cookie middleware. - /// - /// Contains information about the event - Task RedirectToLogout(CookieRedirectContext context); - - /// - /// Called when a SignIn causes a redirect in the cookie middleware. - /// - /// Contains information about the event - Task RedirectToLogin(CookieRedirectContext context); - - /// - /// Called when redirecting back to the return url in the cookie middleware. - /// - /// Contains information about the event - Task RedirectToReturnUrl(CookieRedirectContext context); - - /// - /// Called when an access denied causes a redirect in the cookie middleware. - /// - /// Contains information about the event - Task RedirectToAccessDenied(CookieRedirectContext context); - - /// - /// 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 SigningOut(CookieSigningOutContext context); - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 4a711c3180..3f2f0ee8d3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -17,9 +17,7 @@ - - diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs index 0435db794f..1a9607eea4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs @@ -1,9 +1,8 @@ -// 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. using System; using Microsoft.AspNetCore.Authentication.Facebook; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { @@ -13,38 +12,26 @@ namespace Microsoft.AspNetCore.Builder public static class FacebookAppBuilderExtensions { /// - /// Adds the middleware to the specified , which enables Facebook authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. + /// The to add the handler to. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - return app.UseMiddleware(); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Adds the middleware to the specified , which enables Facebook authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. - /// A that specifies options for the middleware. + /// The to add the handler to. + /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app, FacebookOptions options) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(Options.Create(options)); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs new file mode 100644 index 0000000000..9305623dad --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs @@ -0,0 +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. + +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.Facebook +{ + internal class FacebookConfigureOptions : ConfigureNamedOptions + { + public FacebookConfigureOptions(IConfiguration config) : + base(FacebookDefaults.AuthenticationScheme, + options => config.GetSection(FacebookDefaults.AuthenticationScheme).Bind(options)) + { } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs new file mode 100644 index 0000000000..bcfa95c0ad --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -0,0 +1,32 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication.Facebook; +using Microsoft.Extensions.Options; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class FacebookAuthenticationOptionsExtensions + { + /// + /// Adds facebook authentication with options bound against the "Facebook" section + /// from the IConfiguration in the service container. + /// + /// + /// + public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services) + { + services.AddSingleton, FacebookConfigureOptions>(); + return services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { }); + } + + public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, Action configureOptions) + => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions); + + public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + { + return services.AddScheme(authenticationScheme, configureOptions); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 3c3c14c86f..521684d14a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -1,27 +1,27 @@ // 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.Globalization; using System.Net.Http; using System.Security.Claims; using System.Security.Cryptography; using System.Text; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.Facebook { internal class FacebookHandler : OAuthHandler { - public FacebookHandler(HttpClient httpClient) - : base(httpClient) - { - } + public FacebookHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + : base(sharedOptions, options, logger, encoder, dataProtection, clock) + { } protected override async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) { @@ -43,11 +43,11 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Options.AuthenticationScheme); - var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens, payload); + var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Scheme.Name); + var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens, payload); context.RunClaimActions(); - await Options.Events.CreatingTicket(context); + await Events.CreatingTicket(context); return context.Ticket; } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs deleted file mode 100644 index ac57e8ddeb..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookMiddleware.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Globalization; -using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.Facebook -{ - /// - /// An ASP.NET Core middleware for authenticating users using Facebook. - /// - public class FacebookMiddleware : OAuthMiddleware - { - /// - /// Initializes a new . - /// - /// The next middleware in the HTTP pipeline to invoke. - /// - /// - /// - /// - /// Configuration options for the middleware. - public FacebookMiddleware( - RequestDelegate next, - IDataProtectionProvider dataProtectionProvider, - ILoggerFactory loggerFactory, - UrlEncoder encoder, - IOptions sharedOptions, - IOptions options) - : base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options) - { - if (next == null) - { - throw new ArgumentNullException(nameof(next)); - } - - if (dataProtectionProvider == null) - { - throw new ArgumentNullException(nameof(dataProtectionProvider)); - } - - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - if (encoder == null) - { - throw new ArgumentNullException(nameof(encoder)); - } - - if (sharedOptions == null) - { - throw new ArgumentNullException(nameof(sharedOptions)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - if (string.IsNullOrEmpty(Options.AppId)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.AppId))); - } - - if (string.IsNullOrEmpty(Options.AppSecret)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.AppSecret))); - } - } - - /// - /// Provides the object for processing authentication-related requests. - /// - /// An configured with the supplied to the constructor. - protected override AuthenticationHandler CreateHandler() - { - return new FacebookHandler(Backchannel); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs index ae875bfafb..7010bb20aa 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs @@ -1,16 +1,18 @@ // 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.Collections.Generic; using System.Security.Claims; using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.Facebook; +using System.Globalization; +using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Authentication.Facebook { /// - /// Configuration options for . + /// Configuration options for . /// public class FacebookOptions : OAuthOptions { @@ -19,8 +21,6 @@ namespace Microsoft.AspNetCore.Builder /// public FacebookOptions() { - AuthenticationScheme = FacebookDefaults.AuthenticationScheme; - DisplayName = AuthenticationScheme; CallbackPath = new PathString("/signin-facebook"); SendAppSecretProof = true; AuthorizationEndpoint = FacebookDefaults.AuthorizationEndpoint; @@ -49,6 +49,24 @@ namespace Microsoft.AspNetCore.Builder ClaimActions.MapJsonKey("urn:facebook:timezone", "timezone"); } + /// + /// Check that the options are valid. Should throw an exception if things are not ok. + /// + public override void Validate() + { + if (string.IsNullOrEmpty(AppId)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(AppId)), nameof(AppId)); + } + + if (string.IsNullOrEmpty(AppSecret)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(AppSecret)), nameof(AppSecret)); + } + + base.Validate(); + } + // Facebook uses a non-standard term for this field. /// /// Gets or sets the Facebook-assigned appId. diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index 0cef42b391..8f46ff169a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -13,6 +13,7 @@ + diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs index 85a193d82b..d2687239bb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -3,6 +3,8 @@ using System; using Microsoft.AspNetCore.Authentication.Google; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder @@ -13,41 +15,24 @@ namespace Microsoft.AspNetCore.Builder public static class GoogleAppBuilderExtensions { /// - /// Adds the middleware to the specified , - /// which enables Google authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. + /// The to add the handler to. /// A reference to this instance after the operation has completed. public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - return app.UseMiddleware(); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Adds the middleware to the specified , - /// which enables Google authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. - /// A that specifies options for the middleware. + /// The to add the handler to. + /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app, GoogleOptions options) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(Options.Create(options)); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs new file mode 100644 index 0000000000..e19c1fdb1d --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs @@ -0,0 +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. + +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.Google +{ + internal class GoogleConfigureOptions : ConfigureNamedOptions + { + public GoogleConfigureOptions(IConfiguration config) : + base(GoogleDefaults.AuthenticationScheme, + options => config.GetSection(GoogleDefaults.AuthenticationScheme).Bind(options)) + { } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs new file mode 100644 index 0000000000..d85e3a2d6f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -0,0 +1,32 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication.Google; +using Microsoft.Extensions.Options; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class GoogleExtensions + { + /// + /// Adds google authentication with options bound against the "Google" section + /// from the IConfiguration in the service container. + /// + /// + /// + public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services) + { + services.AddSingleton, GoogleConfigureOptions>(); + return services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { }); + } + + public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, Action configureOptions) + => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions); + + public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + { + return services.AddScheme(authenticationScheme, configureOptions); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 87506e080f..c699f5cc9d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -6,21 +6,22 @@ using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.Google { internal class GoogleHandler : OAuthHandler { - public GoogleHandler(HttpClient httpClient) - : base(httpClient) - { - } + public GoogleHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + : base(sharedOptions, options, logger, encoder, dataProtection, clock) + { } protected override async Task CreateTicketAsync( ClaimsIdentity identity, @@ -40,11 +41,11 @@ namespace Microsoft.AspNetCore.Authentication.Google var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); var principal = new ClaimsPrincipal(identity); - var ticket = new AuthenticationTicket(principal, properties, Options.AuthenticationScheme); - var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens, payload); + var ticket = new AuthenticationTicket(principal, properties, Scheme.Name); + var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens, payload); context.RunClaimActions(); - await Options.Events.CreatingTicket(context); + await Events.CreatingTicket(context); return context.Ticket; } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs deleted file mode 100644 index 5f8afaff2f..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleMiddleware.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.Google -{ - /// - /// An ASP.NET Core middleware for authenticating users using Google OAuth 2.0. - /// - public class GoogleMiddleware : OAuthMiddleware - { - /// - /// Initializes a new . - /// - /// The next middleware in the HTTP pipeline to invoke. - /// - /// - /// - /// - /// Configuration options for the middleware. - public GoogleMiddleware( - RequestDelegate next, - IDataProtectionProvider dataProtectionProvider, - ILoggerFactory loggerFactory, - UrlEncoder encoder, - IOptions sharedOptions, - IOptions options) - : base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options) - { - if (next == null) - { - throw new ArgumentNullException(nameof(next)); - } - - if (dataProtectionProvider == null) - { - throw new ArgumentNullException(nameof(dataProtectionProvider)); - } - - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - if (encoder == null) - { - throw new ArgumentNullException(nameof(encoder)); - } - - if (sharedOptions == null) - { - throw new ArgumentNullException(nameof(sharedOptions)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - } - - /// - /// Provides the object for processing authentication-related requests. - /// - /// - /// An configured with the - /// supplied to the constructor. - /// - protected override AuthenticationHandler CreateHandler() - { - return new GoogleHandler(Backchannel); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs index d269779703..34028bc52b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs @@ -3,13 +3,13 @@ using System.Security.Claims; using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.Google; +using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Authentication.Google { /// - /// Configuration options for . + /// Configuration options for . /// public class GoogleOptions : OAuthOptions { @@ -18,8 +18,6 @@ namespace Microsoft.AspNetCore.Builder /// public GoogleOptions() { - AuthenticationScheme = GoogleDefaults.AuthenticationScheme; - DisplayName = AuthenticationScheme; CallbackPath = new PathString("/signin-google"); AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint; TokenEndpoint = GoogleDefaults.TokenEndpoint; diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index 491571371e..7b6c9ee5df 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -13,6 +13,7 @@ + diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs index b3e0f0bdc8..b47a9bab0f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs @@ -2,15 +2,14 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class AuthenticationFailedContext : BaseJwtBearerContext { - public AuthenticationFailedContext(HttpContext context, JwtBearerOptions options) - : base(context, options) + public AuthenticationFailedContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) + : base(context, scheme, options) { } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs index 5c28f2976e..313e999d0d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs @@ -2,14 +2,13 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class BaseJwtBearerContext : BaseControlContext { - public BaseJwtBearerContext(HttpContext context, JwtBearerOptions options) + public BaseJwtBearerContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) : base(context) { if (options == null) @@ -17,9 +16,17 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer throw new ArgumentNullException(nameof(options)); } + if (scheme == null) + { + throw new ArgumentNullException(nameof(scheme)); + } + Options = options; + Scheme = scheme; } public JwtBearerOptions Options { get; } + + public AuthenticationScheme Scheme { get; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs deleted file mode 100644 index a7b8aeb552..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/IJwtBearerEvents.cs +++ /dev/null @@ -1,33 +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.Threading.Tasks; - -namespace Microsoft.AspNetCore.Authentication.JwtBearer -{ - /// - /// Specifies events which the invokes to enable developer control over the authentication process. - /// - public interface IJwtBearerEvents - { - /// - /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. - /// - Task AuthenticationFailed(AuthenticationFailedContext context); - - /// - /// Invoked when a protocol message is first received. - /// - Task MessageReceived(MessageReceivedContext context); - - /// - /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. - /// - Task TokenValidated(TokenValidatedContext context); - - /// - /// Invoked to apply a challenge sent back to the caller. - /// - Task Challenge(JwtBearerChallengeContext context); - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs index 5846812538..e6f931f6db 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs @@ -2,16 +2,14 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class JwtBearerChallengeContext : BaseJwtBearerContext { - public JwtBearerChallengeContext(HttpContext context, JwtBearerOptions options, AuthenticationProperties properties) - : base(context, options) + public JwtBearerChallengeContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options, AuthenticationProperties properties) + : base(context, scheme, options) { Properties = properties; } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs index 8ac1c3631e..c4e2e7b5a9 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -8,9 +8,9 @@ using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.JwtBearer { /// - /// 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. /// - public class JwtBearerEvents : IJwtBearerEvents + public class JwtBearerEvents { /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs index a23f8356da..530a945cab 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs @@ -1,15 +1,14 @@ // 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.AspNetCore.Builder; using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class MessageReceivedContext : BaseJwtBearerContext { - public MessageReceivedContext(HttpContext context, JwtBearerOptions options) - : base(context, options) + public MessageReceivedContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) + : base(context, scheme, options) { } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs index d6de5ca873..3667865da1 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs @@ -1,7 +1,6 @@ // 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.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Tokens; @@ -9,8 +8,8 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class TokenValidatedContext : BaseJwtBearerContext { - public TokenValidatedContext(HttpContext context, JwtBearerOptions options) - : base(context, options) + public TokenValidatedContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) + : base(context, scheme, options) { } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index 13c06ca382..6b1b1afd4a 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -1,4 +1,4 @@ -// 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. using System; @@ -13,50 +13,26 @@ namespace Microsoft.AspNetCore.Builder public static class JwtBearerAppBuilderExtensions { /// - /// Adds the middleware to the specified , which enables Bearer token processing capabilities. - /// This middleware understands appropriately - /// formatted and secured tokens which appear in the request header. If the Options.AuthenticationMode is Active, the - /// claims within the bearer token are added to the current request's IPrincipal User. If the Options.AuthenticationMode - /// is Passive, then the current request is not modified, but IAuthenticationManager AuthenticateAsync may be used at - /// any time to obtain the claims from the request's bearer token. - /// See also http://tools.ietf.org/html/rfc6749 + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. + /// The to add the handler to. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - return app.UseMiddleware(); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Adds the middleware to the specified , which enables Bearer token processing capabilities. - /// This middleware understands appropriately - /// formatted and secured tokens which appear in the request header. If the Options.AuthenticationMode is Active, the - /// claims within the bearer token are added to the current request's IPrincipal User. If the Options.AuthenticationMode - /// is Passive, then the current request is not modified, but IAuthenticationManager AuthenticateAsync may be used at - /// any time to obtain the claims from the request's bearer token. - /// See also http://tools.ietf.org/html/rfc6749 + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. - /// A that specifies options for the middleware. + /// The to add the handler to. + /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app, JwtBearerOptions options) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(Options.Create(options)); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs new file mode 100644 index 0000000000..f3571a49c4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs @@ -0,0 +1,17 @@ +// 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.Extensions.Configuration; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.JwtBearer +{ + internal class JwtBearerConfigureOptions : ConfigureNamedOptions + { + // Bind to "Bearer" section by default + public JwtBearerConfigureOptions(IConfiguration config) : + base(JwtBearerDefaults.AuthenticationScheme, + options => config.GetSection(JwtBearerDefaults.AuthenticationScheme).Bind(options)) + { } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs new file mode 100644 index 0000000000..77ffd76ff4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -0,0 +1,32 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.Extensions.Options; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class JwtBearerExtensions + { + /// + /// Adds JwtBearer authentication with options bound against the "Bearer" section + /// from the IConfiguration in the service container. + /// + /// + /// + public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services) + { + services.AddSingleton, JwtBearerConfigureOptions>(); + return services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { }); + } + + public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, Action configureOptions) + => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, configureOptions); + + public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + { + return services.AddScheme(authenticationScheme, configureOptions); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index ee5575251d..2ea03a51f0 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -4,14 +4,16 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Security.Claims; using System.Text; +using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; @@ -22,6 +24,65 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { private OpenIdConnectConfiguration _configuration; + public JwtBearerHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + : base(options, logger, encoder, clock) + { } + + /// + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// If it is not provided a default instance is supplied which does nothing when the methods are called. + /// + protected new JwtBearerEvents Events + { + get { return (JwtBearerEvents)base.Events; } + set { base.Events = value; } + } + + protected override Task CreateEventsAsync() => Task.FromResult(new JwtBearerEvents()); + + protected override void InitializeOptions() + { + base.InitializeOptions(); + + if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.Audience)) + { + Options.TokenValidationParameters.ValidAudience = Options.Audience; + } + + if (Options.ConfigurationManager == null) + { + if (Options.Configuration != null) + { + Options.ConfigurationManager = new StaticConfigurationManager(Options.Configuration); + } + else if (!(string.IsNullOrEmpty(Options.MetadataAddress) && string.IsNullOrEmpty(Options.Authority))) + { + if (string.IsNullOrEmpty(Options.MetadataAddress) && !string.IsNullOrEmpty(Options.Authority)) + { + Options.MetadataAddress = Options.Authority; + if (!Options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) + { + Options.MetadataAddress += "/"; + } + + Options.MetadataAddress += ".well-known/openid-configuration"; + } + + if (Options.RequireHttpsMetadata && !Options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); + } + + var httpClient = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); + httpClient.Timeout = Options.BackchannelTimeout; + httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + + Options.ConfigurationManager = new ConfigurationManager(Options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), + new HttpDocumentRetriever(httpClient) { RequireHttps = Options.RequireHttpsMetadata }); + } + } + } + /// /// Searches the 'Authorization' header for a 'Bearer' token. If the 'Bearer' token is found, it is validated using set in the options. /// @@ -33,11 +94,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer try { // Give application opportunity to find from a different location, adjust, or reject token - var messageReceivedContext = new MessageReceivedContext(Context, Options); + var messageReceivedContext = new MessageReceivedContext(Context, Scheme, Options); // event can set the token - await Options.Events.MessageReceived(messageReceivedContext); - if (messageReceivedContext.CheckEventResult(out result)) + await Events.MessageReceived(messageReceivedContext); + if (messageReceivedContext.IsProcessingComplete(out result)) { return result; } @@ -52,7 +113,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer // If no authorization header found, nothing to process further if (string.IsNullOrEmpty(authorization)) { - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } if (authorization.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase)) @@ -63,7 +124,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer // If no token found, no further work possible if (string.IsNullOrEmpty(token)) { - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } } @@ -120,15 +181,15 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Logger.TokenValidationSucceeded(); - var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Options.AuthenticationScheme); - var tokenValidatedContext = new TokenValidatedContext(Context, Options) + var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name); + var tokenValidatedContext = new TokenValidatedContext(Context, Scheme, Options) { Ticket = ticket, SecurityToken = validatedToken, }; - await Options.Events.TokenValidated(tokenValidatedContext); - if (tokenValidatedContext.CheckEventResult(out result)) + await Events.TokenValidated(tokenValidatedContext); + if (tokenValidatedContext.IsProcessingComplete(out result)) { return result; } @@ -148,13 +209,13 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer if (validationFailures != null) { - var authenticationFailedContext = new AuthenticationFailedContext(Context, Options) + var authenticationFailedContext = new AuthenticationFailedContext(Context, Scheme, Options) { Exception = (validationFailures.Count == 1) ? validationFailures[0] : new AggregateException(validationFailures) }; - await Options.Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.CheckEventResult(out result)) + await Events.AuthenticationFailed(authenticationFailedContext); + if (authenticationFailedContext.IsProcessingComplete(out result)) { return result; } @@ -168,13 +229,13 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { Logger.ErrorProcessingMessage(ex); - var authenticationFailedContext = new AuthenticationFailedContext(Context, Options) + var authenticationFailedContext = new AuthenticationFailedContext(Context, Scheme, Options) { Exception = ex }; - await Options.Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.CheckEventResult(out result)) + await Events.AuthenticationFailed(authenticationFailedContext); + if (authenticationFailedContext.IsProcessingComplete(out result)) { return result; } @@ -183,11 +244,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { var authResult = await HandleAuthenticateOnceSafeAsync(); - - var eventContext = new JwtBearerChallengeContext(Context, Options, new AuthenticationProperties(context.Properties)) + var eventContext = new JwtBearerChallengeContext(Context, Scheme, Options, context.Properties) { AuthenticateFailure = authResult?.Failure }; @@ -199,14 +259,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer eventContext.ErrorDescription = CreateErrorDescription(eventContext.AuthenticateFailure); } - await Options.Events.Challenge(eventContext); - if (eventContext.HandledResponse) + await Events.Challenge(eventContext); + if (eventContext.IsProcessingComplete(out var ignored)) { - return true; - } - if (eventContext.Skipped) - { - return false; + return; } Response.StatusCode = 401; @@ -259,8 +315,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Response.Headers.Append(HeaderNames.WWWAuthenticate, builder.ToString()); } - - return false; } private static string CreateErrorDescription(Exception authFailure) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerMiddleware.cs deleted file mode 100644 index bfb38793f3..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerMiddleware.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Net.Http; -using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Microsoft.IdentityModel.Protocols; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; - -namespace Microsoft.AspNetCore.Authentication.JwtBearer -{ - /// - /// Bearer authentication middleware component which is added to an HTTP pipeline. This class is not - /// created by application code directly, instead it is added by calling the the IAppBuilder UseJwtBearerAuthentication - /// extension method. - /// - public class JwtBearerMiddleware : AuthenticationMiddleware - { - /// - /// Bearer authentication component which is added to an HTTP pipeline. This constructor is not - /// called by application code directly, instead it is added by calling the the IAppBuilder UseJwtBearerAuthentication - /// extension method. - /// - public JwtBearerMiddleware( - RequestDelegate next, - ILoggerFactory loggerFactory, - UrlEncoder encoder, - IOptions options) - : base(next, options, loggerFactory, encoder) - { - if (next == null) - { - throw new ArgumentNullException(nameof(next)); - } - - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - if (encoder == null) - { - throw new ArgumentNullException(nameof(encoder)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - if (Options.Events == null) - { - Options.Events = new JwtBearerEvents(); - } - - if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.Audience)) - { - Options.TokenValidationParameters.ValidAudience = Options.Audience; - } - - if (Options.ConfigurationManager == null) - { - if (Options.Configuration != null) - { - Options.ConfigurationManager = new StaticConfigurationManager(Options.Configuration); - } - else if (!(string.IsNullOrEmpty(Options.MetadataAddress) && string.IsNullOrEmpty(Options.Authority))) - { - if (string.IsNullOrEmpty(Options.MetadataAddress) && !string.IsNullOrEmpty(Options.Authority)) - { - Options.MetadataAddress = Options.Authority; - if (!Options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) - { - Options.MetadataAddress += "/"; - } - - Options.MetadataAddress += ".well-known/openid-configuration"; - } - - if (Options.RequireHttpsMetadata && !Options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); - } - - var httpClient = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - httpClient.Timeout = Options.BackchannelTimeout; - httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - - Options.ConfigurationManager = new ConfigurationManager(Options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), - new HttpDocumentRetriever(httpClient) { RequireHttps = Options.RequireHttpsMetadata }); - } - } - } - - /// - /// Called by the AuthenticationMiddleware base class to create a per-request handler. - /// - /// A new instance of the request handler - protected override AuthenticationHandler CreateHandler() - { - return new JwtBearerHandler(); - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs index 2aedf30d52..9a480763d4 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -3,32 +3,19 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.IdentityModel.Tokens.Jwt; using System.Net.Http; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Authentication.JwtBearer { /// - /// Options class provides information needed to control Bearer Authentication middleware behavior + /// Options class provides information needed to control Bearer Authentication handler behavior /// - public class JwtBearerOptions : AuthenticationOptions + public class JwtBearerOptions : AuthenticationSchemeOptions { - /// - /// Creates an instance of bearer authentication options with default values. - /// - public JwtBearerOptions() : base() - { - AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme; - AutomaticAuthenticate = true; - AutomaticChallenge = true; - } - /// /// Gets or sets if HTTPS is required for the metadata address or authority. /// The default is true. This should be disabled only in development environments. @@ -59,11 +46,15 @@ namespace Microsoft.AspNetCore.Builder public string Challenge { get; set; } = JwtBearerDefaults.AuthenticationScheme; /// - /// 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 handler. /// The application may implement the interface fully, or it may create an instance of JwtBearerAuthenticationEvents /// and assign delegates only to the events it wants to process. /// - public IJwtBearerEvents Events { get; set; } = new JwtBearerEvents(); + public new JwtBearerEvents Events + { + get { return (JwtBearerEvents)base.Events; } + set { base.Events = value; } + } /// /// The HttpMessageHandler used to retrieve metadata. @@ -115,7 +106,7 @@ namespace Microsoft.AspNetCore.Builder /// /// Defines whether the token validation errors should be returned to the caller. - /// Enabled by default, this option can be disabled to prevent the JWT middleware + /// Enabled by default, this option can be disabled to prevent the JWT handler /// from returning an error and an error_description in the WWW-Authenticate header. /// public bool IncludeErrorDetails { get; set; } = true; diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 7311aa3aef..89e7ef9c39 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -9,8 +9,9 @@ - + + diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index eecfeb9261..5b8263c9c1 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -13,6 +13,7 @@ + diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs index 660dd2e818..88306efbed 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs @@ -1,9 +1,8 @@ -// 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. using System; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { @@ -13,38 +12,26 @@ namespace Microsoft.AspNetCore.Builder public static class MicrosoftAccountAppBuilderExtensions { /// - /// Adds the middleware to the specified , which enables Microsoft Account authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. + /// The to add the handler to. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - return app.UseMiddleware(); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Adds the middleware to the specified , which enables Microsoft Account authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. - /// A that specifies options for the middleware. + /// The to add the handler to. + /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app, MicrosoftAccountOptions options) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(Options.Create(options)); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs new file mode 100644 index 0000000000..520c3758d5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs @@ -0,0 +1,17 @@ +// 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.Extensions.Configuration; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount +{ + internal class MicrosoftAccountConfigureOptions : ConfigureNamedOptions + { + // Bind to "Microsoft" section by default + public MicrosoftAccountConfigureOptions(IConfiguration config) : + base(MicrosoftAccountDefaults.AuthenticationScheme, + options => config.GetSection(MicrosoftAccountDefaults.AuthenticationScheme).Bind(options)) + { } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs new file mode 100644 index 0000000000..1f8884ab2e --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -0,0 +1,32 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication.MicrosoftAccount; +using Microsoft.Extensions.Options; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class MicrosoftAccountExtensions + { + /// + /// Adds MicrosoftAccount authentication with options bound against the "Microsoft" section + /// from the IConfiguration in the service container. + /// + /// + /// + public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services) + { + services.AddSingleton, MicrosoftAccountConfigureOptions>(); + return services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, o => { }); + } + + public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, Action configureOptions) => + services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); + + public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + { + return services.AddScheme(authenticationScheme, configureOptions); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 2426cafe07..b2b787b97c 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -1,24 +1,24 @@ // 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.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { internal class MicrosoftAccountHandler : OAuthHandler { - public MicrosoftAccountHandler(HttpClient httpClient) - : base(httpClient) - { - } + public MicrosoftAccountHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + : base(sharedOptions, options, logger, encoder, dataProtection, clock) + { } protected override async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) { @@ -33,11 +33,11 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Options.AuthenticationScheme); - var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens, payload); + var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Scheme.Name); + var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens, payload); context.RunClaimActions(); - await Options.Events.CreatingTicket(context); + await Events.CreatingTicket(context); return context.Ticket; } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs deleted file mode 100644 index 3ad1bf5571..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountMiddleware.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount -{ - /// - /// An ASP.NET Core middleware for authenticating users using the Microsoft Account service. - /// - public class MicrosoftAccountMiddleware : OAuthMiddleware - { - /// - /// Initializes a new . - /// - /// The next middleware in the HTTP pipeline to invoke. - /// - /// - /// - /// - /// Configuration options for the middleware. - public MicrosoftAccountMiddleware( - RequestDelegate next, - IDataProtectionProvider dataProtectionProvider, - ILoggerFactory loggerFactory, - UrlEncoder encoder, - IOptions sharedOptions, - IOptions options) - : base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options) - { - if (next == null) - { - throw new ArgumentNullException(nameof(next)); - } - - if (dataProtectionProvider == null) - { - throw new ArgumentNullException(nameof(dataProtectionProvider)); - } - - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - if (encoder == null) - { - throw new ArgumentNullException(nameof(encoder)); - } - - if (sharedOptions == null) - { - throw new ArgumentNullException(nameof(sharedOptions)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - } - - /// - /// Provides the object for processing authentication-related requests. - /// - /// An configured with the supplied to the constructor. - protected override AuthenticationHandler CreateHandler() - { - return new MicrosoftAccountHandler(Backchannel); - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs index 1aa4009a56..dbca3507e9 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs @@ -5,11 +5,12 @@ using System.Security.Claims; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Authentication.OAuth; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { /// - /// Configuration options for . + /// Configuration options for . /// public class MicrosoftAccountOptions : OAuthOptions { @@ -18,8 +19,6 @@ namespace Microsoft.AspNetCore.Builder /// public MicrosoftAccountOptions() { - AuthenticationScheme = MicrosoftAccountDefaults.AuthenticationScheme; - DisplayName = AuthenticationScheme; CallbackPath = new PathString("/signin-microsoft"); AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint; TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs deleted file mode 100644 index 29316732cc..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/IOAuthEvents.cs +++ /dev/null @@ -1,27 +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.Threading.Tasks; - -namespace Microsoft.AspNetCore.Authentication.OAuth -{ - /// - /// Specifies callback methods which the invokes to enable developer control over the authentication process. - /// - public interface IOAuthEvents : IRemoteAuthenticationEvents - { - /// - /// Invoked after the provider successfully authenticates a user. This can be used to retrieve user information. - /// This event may not be invoked by sub-classes of OAuthAuthenticationHandler if they override CreateTicketAsync. - /// - /// Contains information about the login session. - /// A representing the completed operation. - Task CreatingTicket(OAuthCreatingTicketContext context); - - /// - /// Called when a Challenge causes a redirect to the authorize endpoint. - /// - /// Contains redirect URI and of the challenge. - Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context); - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs index b17d23c9bb..f50dff3f55 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -5,7 +5,6 @@ using System; using System.Globalization; using System.Net.Http; using System.Security.Claims; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Newtonsoft.Json.Linq; @@ -14,23 +13,25 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// Contains information about the login session as well as the user . /// - public class OAuthCreatingTicketContext : BaseContext + public class OAuthCreatingTicketContext : BaseAuthenticationContext { /// /// Initializes a new . /// /// The . /// The HTTP environment. + /// The authentication scheme. /// The options used by the authentication middleware. /// The HTTP client used by the authentication middleware /// The tokens returned from the token endpoint. public OAuthCreatingTicketContext( AuthenticationTicket ticket, HttpContext context, + AuthenticationScheme scheme, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens) - : this(ticket, context, options, backchannel, tokens, user: new JObject()) + : this(ticket, context, scheme, options, backchannel, tokens, user: new JObject()) { } @@ -39,6 +40,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// The . /// The HTTP environment. + /// The authentication scheme. /// The options used by the authentication middleware. /// The HTTP client used by the authentication middleware /// The tokens returned from the token endpoint. @@ -46,11 +48,12 @@ namespace Microsoft.AspNetCore.Authentication.OAuth public OAuthCreatingTicketContext( AuthenticationTicket ticket, HttpContext context, + AuthenticationScheme scheme, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens, JObject user) - : base(context) + : base(context, scheme.Name, ticket.Properties) { if (context == null) { @@ -77,15 +80,23 @@ namespace Microsoft.AspNetCore.Authentication.OAuth throw new ArgumentNullException(nameof(user)); } + if (scheme == null) + { + throw new ArgumentNullException(nameof(scheme)); + } + TokenResponse = tokens; Backchannel = backchannel; User = user; Options = options; + Scheme = scheme; Ticket = ticket; } public OAuthOptions Options { get; } + public AuthenticationScheme Scheme { get; } + /// /// Gets the JSON-serialized user or an empty /// if it is not available. diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs index 066b324b75..4e94a15bc6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -8,9 +8,9 @@ using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.OAuth { /// - /// Default implementation. + /// Default implementation. /// - public class OAuthEvents : RemoteAuthenticationEvents, IOAuthEvents + public class OAuthEvents : RemoteAuthenticationEvents { /// /// Gets or sets the function that is invoked when the CreatingTicket method is invoked. @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth public virtual Task CreatingTicket(OAuthCreatingTicketContext context) => OnCreatingTicket(context); /// - /// Called when a Challenge causes a redirect to authorize endpoint in the OAuth middleware. + /// Called when a Challenge causes a redirect to authorize endpoint in the OAuth handler. /// /// Contains redirect URI and of the challenge. public virtual Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context) => OnRedirectToAuthorizationEndpoint(context); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs index 63eaa35376..5d5e0e701a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs @@ -3,12 +3,11 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.OAuth { /// - /// Context passed when a Challenge causes a redirect to authorize endpoint in the middleware. + /// Context passed when a Challenge causes a redirect to authorize endpoint in the handler. /// public class OAuthRedirectToAuthorizationContext : BaseContext { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs index eebeaf7a37..ceec294eca 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs @@ -1,9 +1,8 @@ -// 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. using System; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { @@ -13,38 +12,26 @@ namespace Microsoft.AspNetCore.Builder public static class OAuthAppBuilderExtensions { /// - /// Adds the middleware to the specified , which enables OAuth 2.0 authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. + /// The to add the handler to. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - return app.UseMiddleware>(); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Adds the middleware to the specified , which enables OAuth 2.0 authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. - /// A that specifies options for the middleware. + /// The to add the handler to. + /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app, OAuthOptions options) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware>(Options.Create(options)); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs new file mode 100644 index 0000000000..aa7c59f03f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -0,0 +1,15 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.Extensions.DependencyInjection; + +namespace Microsoft.AspNetCore.Builder +{ + public static class OAuthExtensions + { + public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) => + services.AddScheme>(authenticationScheme, configureOptions); + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index a5c36c1c45..cafc4f0bcf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -8,24 +8,60 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; using System.Text; +using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.OAuth { - public class OAuthHandler : RemoteAuthenticationHandler where TOptions : OAuthOptions + public class OAuthHandler : RemoteAuthenticationHandler where TOptions : OAuthOptions, new() { - public OAuthHandler(HttpClient backchannel) + protected HttpClient Backchannel => Options.Backchannel; + + /// + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// If it is not provided a default instance is supplied which does nothing when the methods are called. + /// + protected new OAuthEvents Events { - Backchannel = backchannel; + get { return (OAuthEvents)base.Events; } + set { base.Events = value; } } - protected HttpClient Backchannel { get; private set; } + public OAuthHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + : base(sharedOptions, options, dataProtection, logger, encoder, clock) + { } + + protected override void InitializeOptions() + { + base.InitializeOptions(); + + if (Options.Backchannel == null) + { + Options.Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); + Options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OAuth handler"); + Options.Backchannel.Timeout = Options.BackchannelTimeout; + Options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + } + + if (Options.StateDataFormat == null) + { + var dataProtector = DataProtection.CreateProtector( + GetType().FullName, Scheme.Name, "v1"); + Options.StateDataFormat = new PropertiesDataFormat(dataProtector); + } + } + + /// + /// Creates a new instance of the events instance. + /// + /// A new instance of the events instance. + protected override Task CreateEventsAsync() => Task.FromResult(new OAuthEvents()); protected override async Task HandleRemoteAuthenticateAsync() { @@ -107,7 +143,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { // https://www.w3.org/TR/xmlschema-2/#dateTime // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx - var expiresAt = Options.SystemClock.UtcNow + TimeSpan.FromSeconds(value); + var expiresAt = Clock.UtcNow + TimeSpan.FromSeconds(value); authTokens.Add(new AuthenticationToken { Name = "expires_at", @@ -170,21 +206,20 @@ namespace Microsoft.AspNetCore.Authentication.OAuth protected virtual async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) { - var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Options.AuthenticationScheme); - var context = new OAuthCreatingTicketContext(ticket, Context, Options, Backchannel, tokens); - await Options.Events.CreatingTicket(context); + var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Scheme.Name); + var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens); + await Events.CreatingTicket(context); return context.Ticket; } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } - var properties = new AuthenticationProperties(context.Properties); - + var properties = context.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; @@ -197,8 +232,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth var redirectContext = new OAuthRedirectToAuthorizationContext( Context, Options, properties, authorizationEndpoint); - await Options.Events.RedirectToAuthorizationEndpoint(redirectContext); - return true; + await Events.RedirectToAuthorizationEndpoint(redirectContext); } protected virtual string BuildChallengeUrl(AuthenticationProperties properties, string redirectUri) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs deleted file mode 100644 index 75139c1c80..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthMiddleware.cs +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Globalization; -using System.Net.Http; -using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.OAuth -{ - /// - /// An ASP.NET Core middleware for authenticating users using OAuth services. - /// - public class OAuthMiddleware : AuthenticationMiddleware where TOptions : OAuthOptions, new() - { - /// - /// Initializes a new . - /// - /// The next middleware in the HTTP pipeline to invoke. - /// - /// - /// The . - /// The configuration options for this middleware. - /// Configuration options for the middleware. - public OAuthMiddleware( - RequestDelegate next, - IDataProtectionProvider dataProtectionProvider, - ILoggerFactory loggerFactory, - UrlEncoder encoder, - IOptions sharedOptions, - IOptions options) - : base(next, options, loggerFactory, encoder) - { - if (next == null) - { - throw new ArgumentNullException(nameof(next)); - } - - if (dataProtectionProvider == null) - { - throw new ArgumentNullException(nameof(dataProtectionProvider)); - } - - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - if (encoder == null) - { - throw new ArgumentNullException(nameof(encoder)); - } - - if (sharedOptions == null) - { - throw new ArgumentNullException(nameof(sharedOptions)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - // todo: review error handling - if (string.IsNullOrEmpty(Options.AuthenticationScheme)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.AuthenticationScheme))); - } - - if (string.IsNullOrEmpty(Options.ClientId)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.ClientId))); - } - - if (string.IsNullOrEmpty(Options.ClientSecret)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.ClientSecret))); - } - - if (string.IsNullOrEmpty(Options.AuthorizationEndpoint)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.AuthorizationEndpoint))); - } - - if (string.IsNullOrEmpty(Options.TokenEndpoint)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.TokenEndpoint))); - } - - if (!Options.CallbackPath.HasValue) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.CallbackPath))); - } - - if (Options.Events == null) - { - Options.Events = new OAuthEvents(); - } - - if (Options.StateDataFormat == null) - { - var dataProtector = dataProtectionProvider.CreateProtector( - GetType().FullName, Options.AuthenticationScheme, "v1"); - Options.StateDataFormat = new PropertiesDataFormat(dataProtector); - } - - Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OAuth middleware"); - Backchannel.Timeout = Options.BackchannelTimeout; - Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - - if (string.IsNullOrEmpty(Options.SignInScheme)) - { - Options.SignInScheme = sharedOptions.Value.SignInScheme; - } - if (string.IsNullOrEmpty(Options.SignInScheme)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.SignInScheme))); - } - } - - protected HttpClient Backchannel { get; private set; } - - /// - /// Provides the object for processing authentication-related requests. - /// - /// An configured with the supplied to the constructor. - protected override AuthenticationHandler CreateHandler() - { - return new OAuthHandler(Backchannel); - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs index 9bd08dfd84..3c71f055f5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -1,16 +1,18 @@ // 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.Collections.Generic; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Http.Authentication; +using System.Globalization; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Authentication.OAuth { /// - /// Configuration options for . + /// Configuration options OAuth. /// public class OAuthOptions : RemoteAuthenticationOptions { @@ -19,6 +21,39 @@ namespace Microsoft.AspNetCore.Builder Events = new OAuthEvents(); } + /// + /// Check that the options are valid. Should throw an exception if things are not ok. + /// + public override void Validate() + { + base.Validate(); + + if (string.IsNullOrEmpty(ClientId)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(ClientId)), nameof(ClientId)); + } + + if (string.IsNullOrEmpty(ClientSecret)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(ClientSecret)), nameof(ClientSecret)); + } + + if (string.IsNullOrEmpty(AuthorizationEndpoint)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(AuthorizationEndpoint)), nameof(AuthorizationEndpoint)); + } + + if (string.IsNullOrEmpty(TokenEndpoint)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(TokenEndpoint)), nameof(TokenEndpoint)); + } + + if (!CallbackPath.HasValue) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(CallbackPath)), nameof(CallbackPath)); + } + } + /// /// Gets or sets the provider-assigned client id. /// @@ -47,11 +82,11 @@ namespace Microsoft.AspNetCore.Builder public string UserInformationEndpoint { get; set; } /// - /// Gets or sets the used to handle authentication events. + /// Gets or sets the used to handle authentication events. /// - public new IOAuthEvents Events + public new OAuthEvents Events { - get { return (IOAuthEvents)base.Events; } + get { return (OAuthEvents)base.Events; } set { base.Events = value; } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs index 776f78d6e7..0c7d968638 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs @@ -9,8 +9,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class AuthenticationFailedContext : BaseOpenIdConnectContext { - public AuthenticationFailedContext(HttpContext context, OpenIdConnectOptions options) - : base(context, options) + public AuthenticationFailedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) + : base(context, scheme, options) { } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs index 49c863e4b8..0ccfc3ab71 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs @@ -18,8 +18,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Creates a /// - public AuthorizationCodeReceivedContext(HttpContext context, OpenIdConnectOptions options) - : base(context, options) + public AuthorizationCodeReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) + : base(context, scheme, options) { } @@ -42,23 +42,23 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// If the developer chooses to redeem the code themselves then they can provide the resulting tokens here. This is the - /// same as calling HandleCodeRedemption. If set then the middleware will not attempt to redeem the code. An IdToken + /// same as calling HandleCodeRedemption. If set then the handler will not attempt to redeem the code. An IdToken /// is required if one had not been previously received in the authorization response. An access token is optional - /// if the middleware is to contact the user-info endpoint. + /// if the handler is to contact the user-info endpoint. /// public OpenIdConnectMessage TokenEndpointResponse { get; set; } /// - /// Indicates if the developer choose to handle (or skip) the code redemption. If true then the middleware will not attempt + /// Indicates if the developer choose to handle (or skip) the code redemption. If true then the handler will not attempt /// to redeem the code. See HandleCodeRedemption and TokenEndpointResponse. /// public bool HandledCodeRedemption => TokenEndpointResponse != null; /// - /// Tells the middleware to skip the code redemption process. The developer may have redeemed the code themselves, or + /// Tells the handler to skip the code redemption process. The developer may have redeemed the code themselves, or /// decided that the redemption was not required. If tokens were retrieved that are needed for further processing then /// call one of the overloads that allows providing tokens. An IdToken is required if one had not been previously received - /// in the authorization response. An access token can optionally be provided for the middleware to contact the + /// in the authorization response. An access token can optionally be provided for the handler to contact the /// user-info endpoint. Calling this is the same as setting TokenEndpointResponse. /// public void HandleCodeRedemption() @@ -67,10 +67,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } /// - /// Tells the middleware to skip the code redemption process. The developer may have redeemed the code themselves, or + /// Tells the handler to skip the code redemption process. The developer may have redeemed the code themselves, or /// decided that the redemption was not required. If tokens were retrieved that are needed for further processing then /// call one of the overloads that allows providing tokens. An IdToken is required if one had not been previously received - /// in the authorization response. An access token can optionally be provided for the middleware to contact the + /// in the authorization response. An access token can optionally be provided for the handler to contact the /// user-info endpoint. Calling this is the same as setting TokenEndpointResponse. /// public void HandleCodeRedemption(string accessToken, string idToken) @@ -79,10 +79,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } /// - /// Tells the middleware to skip the code redemption process. The developer may have redeemed the code themselves, or + /// Tells the handler to skip the code redemption process. The developer may have redeemed the code themselves, or /// decided that the redemption was not required. If tokens were retrieved that are needed for further processing then /// call one of the overloads that allows providing tokens. An IdToken is required if one had not been previously received - /// in the authorization response. An access token can optionally be provided for the middleware to contact the + /// in the authorization response. An access token can optionally be provided for the handler to contact the /// user-info endpoint. Calling this is the same as setting TokenEndpointResponse. /// public void HandleCodeRedemption(OpenIdConnectMessage tokenEndpointResponse) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs index d2f56a4ce2..63f815d9ee 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -10,19 +9,17 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class BaseOpenIdConnectContext : BaseControlContext { - public BaseOpenIdConnectContext(HttpContext context, OpenIdConnectOptions options) + public BaseOpenIdConnectContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) : base(context) { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - Options = options; + Options = options ?? throw new ArgumentNullException(nameof(options)); + Scheme = scheme ?? throw new ArgumentNullException(nameof(scheme)); } public OpenIdConnectOptions Options { get; } + public AuthenticationScheme Scheme { get; } + public OpenIdConnectMessage ProtocolMessage { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs deleted file mode 100644 index 128fa08a3e..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/IOpenIdConnectEvents.cs +++ /dev/null @@ -1,58 +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.Threading.Tasks; - -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect -{ - /// - /// Specifies events which the invokes to enable developer control over the authentication process. - /// - public interface IOpenIdConnectEvents : IRemoteAuthenticationEvents - { - /// - /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. - /// - Task AuthenticationFailed(AuthenticationFailedContext context); - - /// - /// Invoked after security token validation if an authorization code is present in the protocol message. - /// - Task AuthorizationCodeReceived(AuthorizationCodeReceivedContext context); - - /// - /// Invoked when a protocol message is first received. - /// - Task MessageReceived(MessageReceivedContext context); - - /// - /// Invoked before redirecting to the identity provider to authenticate. - /// - Task RedirectToIdentityProvider(RedirectContext context); - - /// - /// Invoked before redirecting to the identity provider to sign out. - /// - Task RedirectToIdentityProviderForSignOut(RedirectContext context); - - /// - /// Invoked when a request is received on the RemoteSignOutPath. - /// - Task RemoteSignOut(RemoteSignOutContext context); - - /// - /// Invoked after "authorization code" is redeemed for tokens at the token endpoint. - /// - Task TokenResponseReceived(TokenResponseReceivedContext context); - - /// - /// Invoked when an IdToken has been validated and produced an AuthenticationTicket. - /// - Task TokenValidated(TokenValidatedContext context); - - /// - /// Invoked when user information is retrieved from the UserInfoEndpoint. - /// - Task UserInformationReceived(UserInformationReceivedContext context); - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs index b2554969c1..f0298ed055 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs @@ -1,16 +1,14 @@ // 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.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class MessageReceivedContext : BaseOpenIdConnectContext { - public MessageReceivedContext(HttpContext context, OpenIdConnectOptions options) - : base(context, options) + public MessageReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) + : base(context, scheme, options) { } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index f39b554ece..f6386aeec8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -8,9 +8,9 @@ using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// - /// 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. /// - public class OpenIdConnectEvents : RemoteAuthenticationEvents, IOpenIdConnectEvents + public class OpenIdConnectEvents : RemoteAuthenticationEvents { /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs index 59b1c0efd1..59b00827a3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs @@ -1,20 +1,18 @@ // 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.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// - /// When a user configures the to be notified prior to redirecting to an IdentityProvider + /// When a user configures the to be notified prior to redirecting to an IdentityProvider /// an instance of is passed to the 'RedirectToAuthenticationEndpoint' or 'RedirectToEndSessionEndpoint' events. /// public class RedirectContext : BaseOpenIdConnectContext { - public RedirectContext(HttpContext context, OpenIdConnectOptions options, AuthenticationProperties properties) - : base(context, options) + public RedirectContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, AuthenticationProperties properties) + : base(context, scheme, options) { Properties = properties; } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs index a76dc9e592..5c0172673c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs @@ -1,7 +1,6 @@ // 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.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -11,9 +10,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public RemoteSignOutContext( HttpContext context, + AuthenticationScheme scheme, OpenIdConnectOptions options, OpenIdConnectMessage message) - : base(context, options) + : base(context, scheme, options) { ProtocolMessage = message; } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs index b4a9ad6d11..7c0d51fbbd 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs @@ -1,9 +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 Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect @@ -16,8 +14,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Creates a /// - public TokenResponseReceivedContext(HttpContext context, OpenIdConnectOptions options, AuthenticationProperties properties) - : base(context, options) + public TokenResponseReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, AuthenticationProperties properties) + : base(context, scheme, options) { Properties = properties; } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs index 130a4d9873..fea89298ce 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs @@ -15,8 +15,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Creates a /// - public TokenValidatedContext(HttpContext context, OpenIdConnectOptions options) - : base(context, options) + public TokenValidatedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) + : base(context, scheme, options) { } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs index c0a53db447..ee80cb71fe 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs @@ -1,7 +1,6 @@ // 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.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Newtonsoft.Json.Linq; @@ -9,8 +8,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { public class UserInformationReceivedContext : BaseOpenIdConnectContext { - public UserInformationReceivedContext(HttpContext context, OpenIdConnectOptions options) - : base(context, options) + public UserInformationReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) + : base(context, scheme, options) { } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 351cb284c5..a5e4c8b0cb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -11,6 +11,7 @@ + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs index dde12494de..db5cfbbcc9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -1,9 +1,8 @@ -// 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. using System; using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { @@ -13,38 +12,26 @@ namespace Microsoft.AspNetCore.Builder public static class OpenIdConnectAppBuilderExtensions { /// - /// Adds the middleware to the specified , which enables OpenID Connect authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. + /// The to add the handler to. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - return app.UseMiddleware(); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Adds the middleware to the specified , which enables OpenID Connect authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. - /// A that specifies options for the middleware. + /// The to add the handler to. + /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app, OpenIdConnectOptions options) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(Options.Create(options)); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs new file mode 100644 index 0000000000..9afae436dd --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs @@ -0,0 +1,17 @@ +// 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.Extensions.Configuration; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect +{ + internal class OpenIdConnectConfigureOptions : ConfigureNamedOptions + { + // Bind to "OpenIdConnect" section by default + public OpenIdConnectConfigureOptions(IConfiguration config) : + base(OpenIdConnectDefaults.AuthenticationScheme, + options => config.GetSection(OpenIdConnectDefaults.AuthenticationScheme).Bind(options)) + { } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs index a099a72769..c5baca4db9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs @@ -4,7 +4,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// - /// Default values related to OpenIdConnect authentication middleware + /// Default values related to OpenIdConnect authentication handler /// public static class OpenIdConnectDefaults { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs new file mode 100644 index 0000000000..89581b201f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -0,0 +1,32 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.Extensions.Options; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class OpenIdConnectExtensions + { + /// + /// Adds OpenIdConnect authentication with options bound against the "OpenIdConnect" section + /// from the IConfiguration in the service container. + /// + /// + /// + public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services) + { + services.AddSingleton, OpenIdConnectConfigureOptions>(); + return services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); + } + + public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, Action configureOptions) + => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); + + public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + { + return services.AddScheme(authenticationScheme, configureOptions); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 6b24996e78..69acbf9a06 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -13,12 +13,12 @@ using System.Security.Cryptography; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; +using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; @@ -53,28 +53,110 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private OpenIdConnectConfiguration _configuration; - protected HttpClient Backchannel { get; private set; } + protected HttpClient Backchannel => Options.Backchannel; - protected HtmlEncoder HtmlEncoder { get; private set; } + protected HtmlEncoder HtmlEncoder { get; } - public OpenIdConnectHandler(HttpClient backchannel, HtmlEncoder htmlEncoder) + public OpenIdConnectHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, HtmlEncoder htmlEncoder, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + : base(sharedOptions, options, dataProtection, logger, encoder, clock) { - Backchannel = backchannel; HtmlEncoder = htmlEncoder; } - public override async Task HandleRequestAsync() + /// + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// If it is not provided a default instance is supplied which does nothing when the methods are called. + /// + protected new OpenIdConnectEvents Events + { + get { return (OpenIdConnectEvents)base.Events; } + set { base.Events = value; } + } + + protected override Task CreateEventsAsync() => Task.FromResult(new OpenIdConnectEvents()); + + protected override void InitializeOptions() + { + base.InitializeOptions(); + + if (string.IsNullOrEmpty(Options.SignOutScheme)) + { + Options.SignOutScheme = SignInScheme; + } + + if (Options.StateDataFormat == null) + { + var dataProtector = DataProtection.CreateProtector( + GetType().FullName, Scheme.Name, "v1"); + Options.StateDataFormat = new PropertiesDataFormat(dataProtector); + } + + if (Options.StringDataFormat == null) + { + var dataProtector = DataProtection.CreateProtector( + GetType().FullName, + typeof(string).FullName, + Scheme.Name, + "v1"); + + Options.StringDataFormat = new SecureDataFormat(new StringSerializer(), dataProtector); + } + + if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.ClientId)) + { + Options.TokenValidationParameters.ValidAudience = Options.ClientId; + } + + if (Options.Backchannel == null) + { + Options.Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); + Options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OpenIdConnect handler"); + Options.Backchannel.Timeout = Options.BackchannelTimeout; + Options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + } + + if (Options.ConfigurationManager == null) + { + if (Options.Configuration != null) + { + Options.ConfigurationManager = new StaticConfigurationManager(Options.Configuration); + } + else if (!(string.IsNullOrEmpty(Options.MetadataAddress) && string.IsNullOrEmpty(Options.Authority))) + { + if (string.IsNullOrEmpty(Options.MetadataAddress) && !string.IsNullOrEmpty(Options.Authority)) + { + Options.MetadataAddress = Options.Authority; + if (!Options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) + { + Options.MetadataAddress += "/"; + } + + Options.MetadataAddress += ".well-known/openid-configuration"; + } + + if (Options.RequireHttpsMetadata && !Options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); + } + + Options.ConfigurationManager = new ConfigurationManager(Options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), + new HttpDocumentRetriever(Backchannel) { RequireHttps = Options.RequireHttpsMetadata }); + } + } + } + + public override Task HandleRequestAsync() { if (Options.RemoteSignOutPath.HasValue && Options.RemoteSignOutPath == Request.Path) { - return await HandleRemoteSignOutAsync(); + return HandleRemoteSignOutAsync(); } else if (Options.SignedOutCallbackPath.HasValue && Options.SignedOutCallbackPath == Request.Path) { - return await HandleSignOutCallbackAsync(); + return HandleSignOutCallbackAsync(); } - return await base.HandleRequestAsync(); + return base.HandleRequestAsync(); } protected virtual async Task HandleRemoteSignOutAsync() @@ -97,8 +179,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect message = new OpenIdConnectMessage(form.Select(pair => new KeyValuePair(pair.Key, pair.Value))); } - var remoteSignOutContext = new RemoteSignOutContext(Context, Options, message); - await Options.Events.RemoteSignOut(remoteSignOutContext); + var remoteSignOutContext = new RemoteSignOutContext(Context, Scheme, Options, message); + await Events.RemoteSignOut(remoteSignOutContext); if (remoteSignOutContext.HandledResponse) { @@ -120,7 +202,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // If the identifier cannot be found, bypass the session identifier checks: this may indicate that the // authentication cookie was already cleared, that the session identifier was lost because of a lossy // external/application cookie conversion or that the identity provider doesn't support sessions. - var sid = (await Context.Authentication.AuthenticateAsync(Options.SignOutScheme)) + var sid = (await Context.AuthenticateAsync(Options.SignOutScheme)) + ?.Principal ?.FindFirst(JwtRegisteredClaimNames.Sid) ?.Value; if (!string.IsNullOrEmpty(sid)) @@ -142,7 +225,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Logger.RemoteSignOut(); // We've received a remote sign-out request - await Context.Authentication.SignOutAsync(Options.SignOutScheme); + await Context.SignOutAsync(Options.SignOutScheme); return true; } @@ -169,7 +252,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect }; // Get the post redirect URI. - var properties = new AuthenticationProperties(signout.Properties); + var properties = signout.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = BuildRedirectUriIfRelative(Options.PostLogoutRedirectUri); @@ -181,14 +264,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Logger.PostSignOutRedirect(properties.RedirectUri); // Attach the identity token to the logout request when possible. - message.IdTokenHint = await Context.Authentication.GetTokenAsync(Options.SignOutScheme, OpenIdConnectParameterNames.IdToken); + message.IdTokenHint = await Context.GetTokenAsync(Options.SignOutScheme, OpenIdConnectParameterNames.IdToken); - var redirectContext = new RedirectContext(Context, Options, properties) + var redirectContext = new RedirectContext(Context, Scheme, Options, properties) { ProtocolMessage = message }; - await Options.Events.RedirectToIdentityProviderForSignOut(redirectContext); + await Events.RedirectToIdentityProviderForSignOut(redirectContext); if (redirectContext.HandledResponse) { Logger.RedirectToIdentityProviderForSignOutHandledResponse(); @@ -271,7 +354,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (!string.IsNullOrEmpty(properties?.RedirectUri)) { Response.Redirect(properties.RedirectUri); - return Task.FromResult(true); } } @@ -282,7 +364,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Responds to a 401 Challenge. Sends an OpenIdConnect message to the 'identity authority' to obtain an identity. /// /// - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { if (context == null) { @@ -294,8 +376,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // order for local RedirectUri // 1. challenge.Properties.RedirectUri // 2. CurrentUri if RedirectUri is not set) - var properties = new AuthenticationProperties(context.Properties); - + var properties = context.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; @@ -335,21 +416,21 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect GenerateCorrelationId(properties); - var redirectContext = new RedirectContext(Context, Options, properties) + var redirectContext = new RedirectContext(Context, Scheme, Options, properties) { ProtocolMessage = message }; - await Options.Events.RedirectToIdentityProvider(redirectContext); + await Events.RedirectToIdentityProvider(redirectContext); if (redirectContext.HandledResponse) { Logger.RedirectToIdentityProviderHandledResponse(); - return true; + return; } else if (redirectContext.Skipped) { Logger.RedirectToIdentityProviderSkipped(); - return false; + return; } message = redirectContext.ProtocolMessage; @@ -379,7 +460,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } Response.Redirect(redirectUri); - return true; + return; } else if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.FormPost) { @@ -407,7 +488,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Response.Headers[HeaderNames.Expires] = "-1"; await Response.Body.WriteAsync(buffer, 0, buffer.Length); - return true; + return; } throw new NotImplementedException($"An unsupported authentication method has been configured: {Options.AuthenticationMethod}"); @@ -435,7 +516,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } return AuthenticateResult.Fail("An OpenID Connect response cannot contain an " + "identity token or an access token when using response_mode=query"); @@ -457,7 +538,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } return AuthenticateResult.Fail("No message."); } @@ -473,7 +554,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } var messageReceivedContext = await RunMessageReceivedEventAsync(authorizationResponse, properties); - if (messageReceivedContext.CheckEventResult(out result)) + if (messageReceivedContext.IsProcessingComplete(out result)) { return result; } @@ -489,7 +570,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Logger.NullOrEmptyAuthorizationResponseState(); if (Options.SkipUnrecognizedRequests) { - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } return AuthenticateResult.Fail(Resources.MessageStateIsNullOrEmpty); } @@ -504,7 +585,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.Skip(); + return AuthenticateResult.None(); } return AuthenticateResult.Fail(Resources.MessageStateIsInvalid); } @@ -550,7 +631,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, null, properties, ticket, jwt, nonce); - if (tokenValidatedContext.CheckEventResult(out result)) + if (tokenValidatedContext.IsProcessingComplete(out result)) { return result; } @@ -575,7 +656,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (!string.IsNullOrEmpty(authorizationResponse.Code)) { var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(authorizationResponse, properties, ticket, jwt); - if (authorizationCodeReceivedContext.CheckEventResult(out result)) + if (authorizationCodeReceivedContext.IsProcessingComplete(out result)) { return result; } @@ -593,7 +674,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } var tokenResponseReceivedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties, ticket); - if (tokenResponseReceivedContext.CheckEventResult(out result)) + if (tokenResponseReceivedContext.IsProcessingComplete(out result)) { return result; } @@ -620,7 +701,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, tokenEndpointResponse, properties, tokenEndpointTicket, tokenEndpointJwt, nonce); - if (tokenValidatedContext.CheckEventResult(out result)) + if (tokenValidatedContext.IsProcessingComplete(out result)) { return result; } @@ -689,7 +770,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } var authenticationFailedContext = await RunAuthenticationFailedEventAsync(authorizationResponse, exception); - if (authenticationFailedContext.CheckEventResult(out result)) + if (authenticationFailedContext.IsProcessingComplete(out result)) { return result; } @@ -804,7 +885,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(ticket, message, user); AuthenticateResult result; - if (userInformationReceivedContext.CheckEventResult(out result)) + if (userInformationReceivedContext.IsProcessingComplete(out result)) { return result; } @@ -861,7 +942,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect int value; if (int.TryParse(message.ExpiresIn, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) { - var expiresAt = Options.SystemClock.UtcNow + TimeSpan.FromSeconds(value); + var expiresAt = Clock.UtcNow + TimeSpan.FromSeconds(value); // https://www.w3.org/TR/xmlschema-2/#dateTime // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx tokens.Add(new AuthenticationToken { Name = "expires_at", Value = expiresAt.ToString("o", CultureInfo.InvariantCulture) }); @@ -891,7 +972,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { HttpOnly = true, Secure = Request.IsHttps, - Expires = Options.SystemClock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) + Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) }); } @@ -971,13 +1052,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private async Task RunMessageReceivedEventAsync(OpenIdConnectMessage message, AuthenticationProperties properties) { Logger.MessageReceived(message.BuildRedirectUrl()); - var messageReceivedContext = new MessageReceivedContext(Context, Options) + var messageReceivedContext = new MessageReceivedContext(Context, Scheme, Options) { ProtocolMessage = message, Properties = properties, }; - await Options.Events.MessageReceived(messageReceivedContext); + await Events.MessageReceived(messageReceivedContext); if (messageReceivedContext.HandledResponse) { Logger.MessageReceivedContextHandledResponse(); @@ -992,7 +1073,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private async Task RunTokenValidatedEventAsync(OpenIdConnectMessage authorizationResponse, OpenIdConnectMessage tokenEndpointResponse, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt, string nonce) { - var tokenValidatedContext = new TokenValidatedContext(Context, Options) + var tokenValidatedContext = new TokenValidatedContext(Context, Scheme, Options) { ProtocolMessage = authorizationResponse, TokenEndpointResponse = tokenEndpointResponse, @@ -1002,7 +1083,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Nonce = nonce, }; - await Options.Events.TokenValidated(tokenValidatedContext); + await Events.TokenValidated(tokenValidatedContext); if (tokenValidatedContext.HandledResponse) { Logger.TokenValidatedHandledResponse(); @@ -1029,7 +1110,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect RedirectUri = properties.Items[OpenIdConnectDefaults.RedirectUriForCodePropertiesKey] }; - var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Options) + var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Scheme, Options) { ProtocolMessage = authorizationResponse, Properties = properties, @@ -1039,7 +1120,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Backchannel = Backchannel, }; - await Options.Events.AuthorizationCodeReceived(authorizationCodeReceivedContext); + await Events.AuthorizationCodeReceived(authorizationCodeReceivedContext); if (authorizationCodeReceivedContext.HandledResponse) { Logger.AuthorizationCodeReceivedContextHandledResponse(); @@ -1059,14 +1140,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect AuthenticationTicket ticket) { Logger.TokenResponseReceived(); - var eventContext = new TokenResponseReceivedContext(Context, Options, properties) + var eventContext = new TokenResponseReceivedContext(Context, Scheme, Options, properties) { ProtocolMessage = message, TokenEndpointResponse = tokenEndpointResponse, Ticket = ticket }; - await Options.Events.TokenResponseReceived(eventContext); + await Events.TokenResponseReceived(eventContext); if (eventContext.HandledResponse) { Logger.TokenResponseReceivedHandledResponse(); @@ -1083,14 +1164,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { Logger.UserInformationReceived(user.ToString()); - var userInformationReceivedContext = new UserInformationReceivedContext(Context, Options) + var userInformationReceivedContext = new UserInformationReceivedContext(Context, Scheme, Options) { Ticket = ticket, ProtocolMessage = message, User = user, }; - await Options.Events.UserInformationReceived(userInformationReceivedContext); + await Events.UserInformationReceived(userInformationReceivedContext); if (userInformationReceivedContext.HandledResponse) { Logger.UserInformationReceivedHandledResponse(); @@ -1105,13 +1186,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private async Task RunAuthenticationFailedEventAsync(OpenIdConnectMessage message, Exception exception) { - var authenticationFailedContext = new AuthenticationFailedContext(Context, Options) + var authenticationFailedContext = new AuthenticationFailedContext(Context, Scheme, Options) { ProtocolMessage = message, Exception = exception }; - await Options.Events.AuthenticationFailed(authenticationFailedContext); + await Events.AuthenticationFailed(authenticationFailedContext); if (authenticationFailedContext.HandledResponse) { Logger.AuthenticationFailedContextHandledResponse(); @@ -1161,7 +1242,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.UnableToValidateToken, idToken)); } - var ticket = new AuthenticationTicket(principal, properties, Options.AuthenticationScheme); + var ticket = new AuthenticationTicket(principal, properties, Scheme.Name); if (Options.UseTokenLifetime) { @@ -1220,5 +1301,18 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect description, errorUri)); } + + private class StringSerializer : IDataSerializer + { + public string Deserialize(byte[] data) + { + return Encoding.UTF8.GetString(data); + } + + public byte[] Serialize(string model) + { + return Encoding.UTF8.GetBytes(model); + } + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs deleted file mode 100644 index 8d880d0d90..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectMiddleware.cs +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Net.Http; -using System.Text; -using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Microsoft.IdentityModel.Protocols; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; - -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect -{ - /// - /// ASP.NET Core middleware for obtaining identities using OpenIdConnect protocol. - /// - public class OpenIdConnectMiddleware : AuthenticationMiddleware - { - /// - /// Initializes a - /// - /// The next middleware in the middleware pipeline to invoke. - /// provider for creating a data protector. - /// factory for creating a . - /// - /// - /// - /// - /// The . - public OpenIdConnectMiddleware( - RequestDelegate next, - IDataProtectionProvider dataProtectionProvider, - ILoggerFactory loggerFactory, - UrlEncoder encoder, - IServiceProvider services, - IOptions sharedOptions, - IOptions options, - HtmlEncoder htmlEncoder) - : base(next, options, loggerFactory, encoder) - { - if (next == null) - { - throw new ArgumentNullException(nameof(next)); - } - - if (dataProtectionProvider == null) - { - throw new ArgumentNullException(nameof(dataProtectionProvider)); - } - - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - if (encoder == null) - { - throw new ArgumentNullException(nameof(encoder)); - } - - if (services == null) - { - throw new ArgumentNullException(nameof(services)); - } - - if (sharedOptions == null) - { - throw new ArgumentNullException(nameof(sharedOptions)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - if (htmlEncoder == null) - { - throw new ArgumentNullException(nameof(htmlEncoder)); - } - - if (string.IsNullOrEmpty(Options.ClientId)) - { - throw new ArgumentException("Options.ClientId must be provided", nameof(Options.ClientId)); - } - - if (!Options.CallbackPath.HasValue) - { - throw new ArgumentException("Options.CallbackPath must be provided."); - } - - if (string.IsNullOrEmpty(Options.SignInScheme)) - { - Options.SignInScheme = sharedOptions.Value.SignInScheme; - } - if (string.IsNullOrEmpty(Options.SignInScheme)) - { - throw new ArgumentException("Options.SignInScheme is required."); - } - if (string.IsNullOrEmpty(Options.SignOutScheme)) - { - Options.SignOutScheme = Options.SignInScheme; - } - - HtmlEncoder = htmlEncoder; - - if (Options.StateDataFormat == null) - { - var dataProtector = dataProtectionProvider.CreateProtector( - typeof(OpenIdConnectMiddleware).FullName, - typeof(string).FullName, - Options.AuthenticationScheme, - "v1"); - - Options.StateDataFormat = new PropertiesDataFormat(dataProtector); - } - - if (Options.StringDataFormat == null) - { - var dataProtector = dataProtectionProvider.CreateProtector( - typeof(OpenIdConnectMiddleware).FullName, - typeof(string).FullName, - Options.AuthenticationScheme, - "v1"); - - Options.StringDataFormat = new SecureDataFormat(new StringSerializer(), dataProtector); - } - - if (Options.Events == null) - { - Options.Events = new OpenIdConnectEvents(); - } - - if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.ClientId)) - { - Options.TokenValidationParameters.ValidAudience = Options.ClientId; - } - - Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OpenIdConnect middleware"); - Backchannel.Timeout = Options.BackchannelTimeout; - Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - - if (Options.ConfigurationManager == null) - { - if (Options.Configuration != null) - { - Options.ConfigurationManager = new StaticConfigurationManager(Options.Configuration); - } - else if (!(string.IsNullOrEmpty(Options.MetadataAddress) && string.IsNullOrEmpty(Options.Authority))) - { - if (string.IsNullOrEmpty(Options.MetadataAddress) && !string.IsNullOrEmpty(Options.Authority)) - { - Options.MetadataAddress = Options.Authority; - if (!Options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) - { - Options.MetadataAddress += "/"; - } - - Options.MetadataAddress += ".well-known/openid-configuration"; - } - - if (Options.RequireHttpsMetadata && !Options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); - } - - Options.ConfigurationManager = new ConfigurationManager(Options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), - new HttpDocumentRetriever(Backchannel) { RequireHttps = Options.RequireHttpsMetadata }); - } - } - - if (Options.ConfigurationManager == null) - { - throw new InvalidOperationException($"Provide {nameof(Options.Authority)}, {nameof(Options.MetadataAddress)}, " - + $"{nameof(Options.Configuration)}, or {nameof(Options.ConfigurationManager)} to {nameof(OpenIdConnectOptions)}"); - } - } - - protected HttpClient Backchannel { get; private set; } - - protected HtmlEncoder HtmlEncoder { get; private set; } - - /// - /// Provides the object for processing authentication-related requests. - /// - /// An configured with the supplied to the constructor. - protected override AuthenticationHandler CreateHandler() - { - return new OpenIdConnectHandler(Backchannel, HtmlEncoder); - } - - private class StringSerializer : IDataSerializer - { - public string Deserialize(byte[] data) - { - return Encoding.UTF8.GetString(data); - } - - public byte[] Serialize(string model) - { - return Encoding.UTF8.GetBytes(model); - } - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 8269acbd8f..5ca270dde8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -8,27 +8,20 @@ using System.Security.Claims; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { /// - /// Configuration options for + /// Configuration options for /// public class OpenIdConnectOptions : RemoteAuthenticationOptions { - /// - /// Initializes a new - /// - public OpenIdConnectOptions() - : this(OpenIdConnectDefaults.AuthenticationScheme) - { - } - /// /// Initializes a new /// @@ -44,11 +37,8 @@ namespace Microsoft.AspNetCore.Builder /// TokenValidationParameters: new with AuthenticationScheme = authenticationScheme. /// UseTokenLifetime: false. /// - /// will be used to when creating the for the AuthenticationScheme property. - public OpenIdConnectOptions(string authenticationScheme) + public OpenIdConnectOptions() { - AuthenticationScheme = authenticationScheme; - AutomaticChallenge = true; DisplayName = OpenIdConnectDefaults.Caption; CallbackPath = new PathString("/signin-oidc"); SignedOutCallbackPath = new PathString("/signout-callback-oidc"); @@ -83,6 +73,30 @@ namespace Microsoft.AspNetCore.Builder ClaimActions.MapUniqueJsonKey("email", "email"); } + /// + /// Check that the options are valid. Should throw an exception if things are not ok. + /// + public override void Validate() + { + base.Validate(); + + if (string.IsNullOrEmpty(ClientId)) + { + throw new ArgumentException("Options.ClientId must be provided", nameof(ClientId)); + } + + if (!CallbackPath.HasValue) + { + throw new ArgumentException("Options.CallbackPath must be provided.", nameof(CallbackPath)); + } + + if (ConfigurationManager == null) + { + throw new InvalidOperationException($"Provide {nameof(Authority)}, {nameof(MetadataAddress)}, " + + $"{nameof(Configuration)}, or {nameof(ConfigurationManager)} to {nameof(OpenIdConnectOptions)}"); + } + } + /// /// Gets or sets the Authority to use when making OpenIdConnect calls. /// @@ -111,7 +125,7 @@ namespace Microsoft.AspNetCore.Builder public IConfigurationManager ConfigurationManager { get; set; } /// - /// Boolean to set whether the middleware should go to user info endpoint to retrieve additional claims or not after creating an identity from id_token received from token endpoint. + /// Boolean to set whether the handler should go to user info endpoint to retrieve additional claims or not after creating an identity from id_token received from token endpoint. /// The default is 'false'. /// public bool GetClaimsFromUserInfoEndpoint { get; set; } @@ -133,11 +147,11 @@ namespace Microsoft.AspNetCore.Builder public string MetadataAddress { get; set; } /// - /// Gets or sets the to notify when processing OpenIdConnect messages. + /// Gets or sets the to notify when processing OpenIdConnect messages. /// - public new IOpenIdConnectEvents Events + public new OpenIdConnectEvents Events { - get { return (IOpenIdConnectEvents)base.Events; } + get { return (OpenIdConnectEvents)base.Events; } set { base.Events = value; } } @@ -196,7 +210,7 @@ namespace Microsoft.AspNetCore.Builder public ICollection Scope { get; } = new HashSet(); /// - /// Requests received on this path will cause the middleware to invoke SignOut using the SignInScheme. + /// Requests received on this path will cause the handler to invoke SignOut using the SignInScheme. /// public PathString RemoteSignOutPath { get; set; } @@ -207,12 +221,12 @@ namespace Microsoft.AspNetCore.Builder public string SignOutScheme { get; set; } /// - /// Gets or sets the type used to secure data handled by the middleware. + /// Gets or sets the type used to secure data handled by the handler. /// public ISecureDataFormat StateDataFormat { get; set; } /// - /// Gets or sets the type used to secure strings used by the middleware. + /// Gets or sets the type used to secure strings used by the handler. /// public ISecureDataFormat StringDataFormat { get; set; } @@ -235,7 +249,7 @@ namespace Microsoft.AspNetCore.Builder public bool UseTokenLifetime { get; set; } /// - /// Indicates if requests to the CallbackPath may also be for other components. If enabled the middleware will pass + /// Indicates if requests to the CallbackPath may also be for other components. If enabled the handler will pass /// requests through that do not contain OpenIdConnect authentication responses. Disabling this and setting the /// CallbackPath to a dedicated endpoint may provide better error handling. /// This is disabled by default. diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs index 5f00cb18bc..b71b8655b7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs @@ -1,7 +1,6 @@ // 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.AspNetCore.Builder; using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -9,19 +8,23 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Base class for other Twitter contexts. /// - public class BaseTwitterContext : BaseContext + public class BaseTwitterContext : BaseAuthenticationContext { /// /// Initializes a /// /// The HTTP environment + /// The scheme data /// The options for Twitter - public BaseTwitterContext(HttpContext context, TwitterOptions options) - : base(context) + /// The AuthenticationProperties + public BaseTwitterContext(HttpContext context, AuthenticationScheme scheme, TwitterOptions options, AuthenticationProperties properties) + : base(context, scheme.Name, properties) { Options = options; } public TwitterOptions Options { get; } + + public AuthenticationScheme Scheme { get; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs deleted file mode 100644 index 006fafc731..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/ITwitterEvents.cs +++ /dev/null @@ -1,26 +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.Threading.Tasks; - -namespace Microsoft.AspNetCore.Authentication.Twitter -{ - /// - /// Specifies callback methods which the invokes to enable developer control over the authentication process. /> - /// - public interface ITwitterEvents : IRemoteAuthenticationEvents - { - /// - /// Invoked whenever Twitter succesfully authenticates a user - /// - /// Contains information about the login session as well as the user . - /// A representing the completed operation. - Task CreatingTicket(TwitterCreatingTicketContext context); - - /// - /// Called when a Challenge causes a redirect to authorize endpoint in the Twitter middleware - /// - /// Contains redirect URI and of the challenge - Task RedirectToAuthorizationEndpoint(TwitterRedirectToAuthorizationEndpointContext context); - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs index 21c6189d71..eaf704bcb9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs @@ -3,9 +3,7 @@ using System; using System.Security.Claims; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -19,21 +17,25 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// Initializes a /// /// The HTTP environment + /// The scheme data /// The options for Twitter /// Twitter user ID /// Twitter screen name /// Twitter access token /// Twitter access token secret /// User details + /// AuthenticationProperties. public TwitterCreatingTicketContext( HttpContext context, + AuthenticationScheme scheme, TwitterOptions options, + AuthenticationProperties properties, string userId, string screenName, string accessToken, string accessTokenSecret, JObject user) - : base(context, options) + : base(context, scheme, options, properties) { UserId = userId; ScreenName = screenName; @@ -72,10 +74,5 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// Gets the representing the user /// public ClaimsPrincipal Principal { get; set; } - - /// - /// Gets or sets a property bag for common authentication properties - /// - public AuthenticationProperties Properties { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs index 033227542a..2c8b30e9fc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -8,9 +8,9 @@ using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.Twitter { /// - /// Default implementation. + /// Default implementation. /// - public class TwitterEvents : RemoteAuthenticationEvents, ITwitterEvents + public class TwitterEvents : RemoteAuthenticationEvents { /// /// Gets or sets the function that is invoked when the Authenticated method is invoked. @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter public virtual Task CreatingTicket(TwitterCreatingTicketContext context) => OnCreatingTicket(context); /// - /// Called when a Challenge causes a redirect to authorize endpoint in the Twitter middleware + /// Called when a Challenge causes a redirect to authorize endpoint in the Twitter handler /// /// Contains redirect URI and of the challenge public virtual Task RedirectToAuthorizationEndpoint(TwitterRedirectToAuthorizationEndpointContext context) => OnRedirectToAuthorizationEndpoint(context); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs index aa1da43edb..fe181fe7b4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs @@ -1,14 +1,12 @@ // 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.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.Twitter { /// - /// The Context passed when a Challenge causes a redirect to authorize endpoint in the Twitter middleware. + /// The Context passed when a Challenge causes a redirect to authorize endpoint in the Twitter handler. /// public class TwitterRedirectToAuthorizationEndpointContext : BaseTwitterContext { @@ -16,12 +14,14 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// Creates a new context object. /// /// The HTTP request context. - /// The Twitter middleware options. + /// The scheme data + /// The Twitter handler options. /// The authentication properties of the challenge. /// The initial redirect URI. - public TwitterRedirectToAuthorizationEndpointContext(HttpContext context, TwitterOptions options, - AuthenticationProperties properties, string redirectUri) - : base(context, options) + public TwitterRedirectToAuthorizationEndpointContext(HttpContext context, AuthenticationScheme scheme, + + TwitterOptions options, AuthenticationProperties properties, string redirectUri) + : base(context, scheme, options, properties) { RedirectUri = redirectUri; Properties = properties; @@ -31,10 +31,5 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// Gets the URI used for the redirect operation. /// public string RedirectUri { get; private set; } - - /// - /// Gets the authentication properties of the challenge. - /// - public AuthenticationProperties Properties { get; private set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index dc4bbf80ae..c0b773345d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -12,6 +12,7 @@ + diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs index df6ca1d024..2896365d69 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs @@ -1,9 +1,8 @@ -// 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. using System; using Microsoft.AspNetCore.Authentication.Twitter; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { @@ -13,38 +12,26 @@ namespace Microsoft.AspNetCore.Builder public static class TwitterAppBuilderExtensions { /// - /// Adds the middleware to the specified , which enables Twitter authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. + /// The to add the handler to. /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - return app.UseMiddleware(); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Adds the middleware to the specified , which enables Twitter authentication capabilities. + /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 /// - /// The to add the middleware to. + /// The to add the handler to. /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. + [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, TwitterOptions options) { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(Options.Create(options)); + throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs new file mode 100644 index 0000000000..b10435f189 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs @@ -0,0 +1,17 @@ +// 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.Extensions.Configuration; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.Twitter +{ + internal class TwitterConfigureOptions : ConfigureNamedOptions + { + // Bind to "Twitter" section by default + public TwitterConfigureOptions(IConfiguration config) : + base(TwitterDefaults.AuthenticationScheme, + options => config.GetSection(TwitterDefaults.AuthenticationScheme).Bind(options)) + { } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs new file mode 100644 index 0000000000..2170be9028 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -0,0 +1,32 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication.Twitter; +using Microsoft.Extensions.Options; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class TwitterExtensions + { + /// + /// Adds Twitter authentication with options bound against the "Twitter" section + /// from the IConfiguration in the service container. + /// + /// + /// + public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services) + { + services.AddSingleton, TwitterConfigureOptions>(); + return services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { }); + } + + public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, Action configureOptions) + => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, configureOptions); + + public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + { + return services.AddScheme(authenticationScheme, configureOptions); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 8481730a8c..c166b175af 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -8,13 +8,13 @@ using System.Net.Http; using System.Security.Claims; using System.Security.Cryptography; using System.Text; +using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; using Newtonsoft.Json.Linq; @@ -28,11 +28,46 @@ namespace Microsoft.AspNetCore.Authentication.Twitter private const string AuthenticationEndpoint = "https://api.twitter.com/oauth/authenticate?oauth_token="; private const string AccessTokenEndpoint = "https://api.twitter.com/oauth/access_token"; - private readonly HttpClient _httpClient; + private HttpClient Backchannel => Options.Backchannel; - public TwitterHandler(HttpClient httpClient) + /// + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// If it is not provided a default instance is supplied which does nothing when the methods are called. + /// + protected new TwitterEvents Events { - _httpClient = httpClient; + get { return (TwitterEvents)base.Events; } + set { base.Events = value; } + } + + public TwitterHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + : base(sharedOptions, options, dataProtection, logger, encoder, clock) + { } + + protected override Task CreateEventsAsync() => Task.FromResult(new TwitterEvents()); + + protected override void InitializeOptions() + { + base.InitializeOptions(); + + if (Options.StateDataFormat == null) + { + var dataProtector = DataProtection.CreateProtector( + GetType().FullName, Scheme.Name, "v1"); + Options.StateDataFormat = new SecureDataFormat( + new RequestTokenSerializer(), + dataProtector); + } + + if (Options.Backchannel == null) + { + Options.Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); + Options.Backchannel.Timeout = Options.BackchannelTimeout; + Options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + Options.Backchannel.DefaultRequestHeaders.Accept.ParseAdd("*/*"); + Options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core Twitter handler"); + Options.Backchannel.DefaultRequestHeaders.ExpectContinue = false; + } } protected override async Task HandleRemoteAuthenticateAsync() @@ -113,30 +148,29 @@ namespace Microsoft.AspNetCore.Authentication.Twitter action.Run(user, identity, Options.ClaimsIssuer); } - var context = new TwitterCreatingTicketContext(Context, Options, token.UserId, token.ScreenName, token.Token, token.TokenSecret, user) + var context = new TwitterCreatingTicketContext(Context, Scheme, Options, properties, token.UserId, token.ScreenName, token.Token, token.TokenSecret, user) { - Principal = new ClaimsPrincipal(identity), - Properties = properties + Principal = new ClaimsPrincipal(identity) }; - await Options.Events.CreatingTicket(context); + await Events.CreatingTicket(context); if (context.Principal?.Identity == null) { return null; } - return new AuthenticationTicket(context.Principal, context.Properties, Options.AuthenticationScheme); + return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleUnauthorizedAsync(ChallengeContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } - var properties = new AuthenticationProperties(context.Properties); + var properties = context.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { @@ -151,16 +185,13 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { HttpOnly = true, Secure = Request.IsHttps, - Expires = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout), + Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions); - var redirectContext = new TwitterRedirectToAuthorizationEndpointContext( - Context, Options, - properties, twitterAuthenticationEndpoint); - await Options.Events.RedirectToAuthorizationEndpoint(redirectContext); - return true; + var redirectContext = new TwitterRedirectToAuthorizationEndpointContext(Context, Scheme, Options, properties, twitterAuthenticationEndpoint); + await Events.RedirectToAuthorizationEndpoint(redirectContext); } private async Task ObtainRequestTokenAsync(string callBackUri, AuthenticationProperties properties) @@ -209,7 +240,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var request = new HttpRequestMessage(HttpMethod.Post, RequestTokenEndpoint); request.Headers.Add("Authorization", authorizationHeaderBuilder.ToString()); - var response = await _httpClient.SendAsync(request, Context.RequestAborted); + var response = await Backchannel.SendAsync(request, Context.RequestAborted); response.EnsureSuccessStatusCode(); var responseText = await response.Content.ReadAsStringAsync(); @@ -279,7 +310,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter request.Content = new FormUrlEncodedContent(formPairs); - var response = await _httpClient.SendAsync(request, Context.RequestAborted); + var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { @@ -350,7 +381,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var request = new HttpRequestMessage(HttpMethod.Get, resource_url + "?include_email=true"); request.Headers.Add("Authorization", authorizationHeaderBuilder.ToString()); - var response = await _httpClient.SendAsync(request, Context.RequestAborted); + var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { Logger.LogError("Email request failed with a status code of " + response.StatusCode); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs deleted file mode 100644 index 67fb903dd1..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterMiddleware.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Globalization; -using System.Net.Http; -using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.Twitter -{ - /// - /// ASP.NET Core middleware for authenticating users using Twitter. - /// - public class TwitterMiddleware : AuthenticationMiddleware - { - private readonly HttpClient _httpClient; - - /// - /// Initializes a - /// - /// The next middleware in the HTTP pipeline to invoke - /// - /// - /// - /// - /// Configuration options for the middleware - public TwitterMiddleware( - RequestDelegate next, - IDataProtectionProvider dataProtectionProvider, - ILoggerFactory loggerFactory, - UrlEncoder encoder, - IOptions sharedOptions, - IOptions options) - : base(next, options, loggerFactory, encoder) - { - if (next == null) - { - throw new ArgumentNullException(nameof(next)); - } - - if (dataProtectionProvider == null) - { - throw new ArgumentNullException(nameof(dataProtectionProvider)); - } - - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - if (encoder == null) - { - throw new ArgumentNullException(nameof(encoder)); - } - - if (sharedOptions == null) - { - throw new ArgumentNullException(nameof(sharedOptions)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - if (string.IsNullOrEmpty(Options.ConsumerSecret)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.ConsumerSecret))); - } - if (string.IsNullOrEmpty(Options.ConsumerKey)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.ConsumerKey))); - } - if (!Options.CallbackPath.HasValue) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(Options.CallbackPath))); - } - - if (Options.Events == null) - { - Options.Events = new TwitterEvents(); - } - if (Options.StateDataFormat == null) - { - var dataProtector = dataProtectionProvider.CreateProtector( - typeof(TwitterMiddleware).FullName, Options.AuthenticationScheme, "v1"); - Options.StateDataFormat = new SecureDataFormat( - new RequestTokenSerializer(), - dataProtector); - } - - if (string.IsNullOrEmpty(Options.SignInScheme)) - { - Options.SignInScheme = sharedOptions.Value.SignInScheme; - } - if (string.IsNullOrEmpty(Options.SignInScheme)) - { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, "SignInScheme")); - } - - _httpClient = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - _httpClient.Timeout = Options.BackchannelTimeout; - _httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - _httpClient.DefaultRequestHeaders.Accept.ParseAdd("*/*"); - _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core Twitter middleware"); - _httpClient.DefaultRequestHeaders.ExpectContinue = false; - } - - /// - /// Provides the object for processing authentication-related requests. - /// - /// An configured with the supplied to the constructor. - protected override AuthenticationHandler CreateHandler() - { - return new TwitterHandler(_httpClient); - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 836dd3c0d5..cf1bf48566 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -6,12 +6,13 @@ using System.Security.Claims; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Authentication.Twitter; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Authentication.Twitter { /// - /// Options for the Twitter authentication middleware. + /// Options for the Twitter authentication handler. /// public class TwitterOptions : RemoteAuthenticationOptions { @@ -20,8 +21,6 @@ namespace Microsoft.AspNetCore.Builder /// public TwitterOptions() { - AuthenticationScheme = TwitterDefaults.AuthenticationScheme; - DisplayName = AuthenticationScheme; CallbackPath = new PathString("/signin-twitter"); BackchannelTimeout = TimeSpan.FromSeconds(60); Events = new TwitterEvents(); @@ -55,16 +54,16 @@ namespace Microsoft.AspNetCore.Builder public ClaimActionCollection ClaimActions { get; } = new ClaimActionCollection(); /// - /// Gets or sets the type used to secure data handled by the middleware. + /// Gets or sets the type used to secure data handled by the handler. /// public ISecureDataFormat StateDataFormat { get; set; } /// - /// Gets or sets the used to handle authentication events. + /// Gets or sets the used to handle authentication events. /// - public new ITwitterEvents Events + public new TwitterEvents Events { - get { return (ITwitterEvents)base.Events; } + get { return (TwitterEvents)base.Events; } set { base.Events = value; } } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthAppBuilderExtensions.cs new file mode 100644 index 0000000000..771601ed1a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/AuthAppBuilderExtensions.cs @@ -0,0 +1,29 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication; + +namespace Microsoft.AspNetCore.Builder +{ + /// + /// Extension methods to add authentication capabilities to an HTTP application pipeline. + /// + public static class AuthAppBuilderExtensions + { + /// + /// Adds the to the specified , which enables authentication capabilities. + /// + /// The to add the middleware to. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseAuthentication(this IApplicationBuilder app) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + + return app.UseMiddleware(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs deleted file mode 100644 index 28f116d3d8..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticateResult.cs +++ /dev/null @@ -1,77 +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.AspNetCore.Authentication -{ - /// - /// Contains the result of an Authenticate call - /// - public class AuthenticateResult - { - private AuthenticateResult() { } - - /// - /// If a ticket was produced, authenticate was successful. - /// - public bool Succeeded - { - get - { - return Ticket != null; - } - } - - /// - /// The authentication ticket. - /// - public AuthenticationTicket Ticket { get; private set; } - - /// - /// Holds failure information from the authentication. - /// - public Exception Failure { get; private set; } - - /// - /// Indicates that stage of authentication was directly handled by user intervention and no - /// further processing should be attempted. - /// - public bool Handled { get; private set; } - - /// - /// Indicates that this stage of authentication was skipped by user intervention. - /// - public bool Skipped { get; private set; } - - public static AuthenticateResult Success(AuthenticationTicket ticket) - { - if (ticket == null) - { - throw new ArgumentNullException(nameof(ticket)); - } - return new AuthenticateResult() { Ticket = ticket }; - } - - public static AuthenticateResult Handle() - { - return new AuthenticateResult() { Handled = true }; - } - - public static AuthenticateResult Skip() - { - return new AuthenticateResult() { Skipped = true }; - } - - public static AuthenticateResult Fail(Exception failure) - { - return new AuthenticateResult() { Failure = failure }; - } - - public static AuthenticateResult Fail(string failureMessage) - { - return new AuthenticateResult() { Failure = new Exception(failureMessage) }; - } - - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 8e7e427659..083884a026 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -4,28 +4,20 @@ using System; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication { - /// - /// Base class for the per-request work performed by most authentication middleware. - /// - /// Specifies which type for of AuthenticationOptions property - public abstract class AuthenticationHandler : IAuthenticationHandler where TOptions : AuthenticationOptions + public abstract class AuthenticationHandler : IAuthenticationHandler where TOptions : AuthenticationSchemeOptions, new() { private Task _authenticateTask; - private bool _finishCalled; - - protected bool SignInAccepted { get; set; } - protected bool SignOutAccepted { get; set; } - protected bool ChallengeCalled { get; set; } + public AuthenticationScheme Scheme { get; private set; } + public TOptions Options { get; private set; } protected HttpContext Context { get; private set; } protected HttpRequest Request @@ -38,15 +30,23 @@ namespace Microsoft.AspNetCore.Authentication get { return Context.Response; } } - protected PathString OriginalPathBase { get; private set; } + protected PathString OriginalPath => Context.Features.Get()?.OriginalPath ?? Request.Path; - protected PathString OriginalPath { get; private set; } + protected PathString OriginalPathBase => Context.Features.Get()?.OriginalPathBase ?? Request.PathBase; - protected ILogger Logger { get; private set; } + protected ILogger Logger { get; } - protected UrlEncoder UrlEncoder { get; private set; } + protected UrlEncoder UrlEncoder { get; } - public IAuthenticationHandler PriorHandler { get; set; } + protected ISystemClock Clock { get; } + + protected IOptionsSnapshot OptionsSnapshot { get; } + + /// + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// If it is not provided a default instance is supplied which does nothing when the methods are called. + /// + protected virtual object Events { get; set; } protected string CurrentUri { @@ -56,71 +56,89 @@ namespace Microsoft.AspNetCore.Authentication } } - protected TOptions Options { get; private set; } - - protected AuthenticateResult InitializeResult { get; private set; } + protected AuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + { + Logger = logger.CreateLogger(this.GetType().FullName); + UrlEncoder = encoder; + Clock = clock; + OptionsSnapshot = options; + } /// - /// Initialize is called once per request to contextualize this instance with appropriate state. + /// Initialize the handler, resolve the options and validate them. /// - /// The original options passed by the application control behavior - /// The utility object to observe the current request and response - /// The logging factory used to create loggers - /// The . - /// async completion - public async Task InitializeAsync(TOptions options, HttpContext context, ILogger logger, UrlEncoder encoder) + /// + /// + /// + public async Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) { - if (options == null) + if (scheme == null) { - throw new ArgumentNullException(nameof(options)); + throw new ArgumentNullException(nameof(scheme)); } - if (context == null) { throw new ArgumentNullException(nameof(context)); } - if (logger == null) - { - throw new ArgumentNullException(nameof(logger)); - } - - if (encoder == null) - { - throw new ArgumentNullException(nameof(encoder)); - } - - Options = options; + Scheme = scheme; Context = context; - OriginalPathBase = Request.PathBase; - OriginalPath = Request.Path; - Logger = logger; - UrlEncoder = encoder; - RegisterAuthenticationHandler(); - - Response.OnStarting(OnStartingCallback, this); - - if (ShouldHandleScheme(AuthenticationManager.AutomaticScheme, Options.AutomaticAuthenticate)) + Options = OptionsSnapshot.Get(Scheme.Name) ?? new TOptions(); + if (!Options.Initialized) { - InitializeResult = await HandleAuthenticateOnceAsync(); - if (InitializeResult?.Skipped == true || InitializeResult?.Handled == true) + lock (Options.InitializeLock) { - return; - } - - if (InitializeResult?.Failure != null) - { - Logger.AuthenticationSchemeNotAuthenticatedWithFailure(Options.AuthenticationScheme, InitializeResult.Failure.Message); - } - - var ticket = InitializeResult?.Ticket; - if (ticket?.Principal != null) - { - Context.User = SecurityHelper.MergeUserPrincipal(Context.User, ticket.Principal); - Logger.UserPrinicpalMerged(Options.AuthenticationScheme); + if (!Options.Initialized) + { + InitializeOptions(); + Options.Initialized = true; + } } } + + Options.Validate(); + + await InitializeEventsAsync(); + await InitializeHandlerAsync(); + } + + /// + /// Initializes the events object, called once per request by . + /// + protected virtual async Task InitializeEventsAsync() + { + Events = Options.Events; + if (Options.EventsType != null) + { + Events = Context.RequestServices.GetRequiredService(Options.EventsType); + } + Events = Events ?? await CreateEventsAsync(); + } + + /// + /// Creates a new instance of the events instance. + /// + /// A new instance of the events instance. + protected virtual Task CreateEventsAsync() => Task.FromResult(new object()); + + /// + /// Initializes the options, will be called only once by . + /// + protected virtual void InitializeOptions() + { + // REVIEW: is there a better place for this default? + Options.DisplayName = Options.DisplayName ?? Scheme.Name; + Options.ClaimsIssuer = Options.ClaimsIssuer ?? Scheme.Name; + } + + /// + /// Called after options/events have been initialized for the handler to finish initializing itself. + /// + /// A task + protected virtual Task InitializeHandlerAsync() + { + return TaskCache.CompletedTask; } protected string BuildRedirectUri(string targetPath) @@ -128,121 +146,23 @@ namespace Microsoft.AspNetCore.Authentication return Request.Scheme + "://" + Request.Host + OriginalPathBase + targetPath; } - private static async Task OnStartingCallback(object state) + public async Task AuthenticateAsync() { - var handler = (AuthenticationHandler)state; - await handler.FinishResponseOnce(); - } - - private async Task FinishResponseOnce() - { - if (!_finishCalled) + // Calling Authenticate more than once should always return the original value. + var result = await HandleAuthenticateOnceAsync(); + if (result?.Failure == null) { - _finishCalled = true; - await FinishResponseAsync(); - await HandleAutomaticChallengeIfNeeded(); - } - } - - /// - /// Hook that is called when the response about to be sent - /// - /// - protected virtual Task FinishResponseAsync() - { - return TaskCache.CompletedTask; - } - - private async Task HandleAutomaticChallengeIfNeeded() - { - if (!ChallengeCalled && Options.AutomaticChallenge && Response.StatusCode == 401) - { - await HandleUnauthorizedAsync(new ChallengeContext(Options.AuthenticationScheme)); - } - } - - /// - /// Called once after Invoke by AuthenticationMiddleware. - /// - /// async completion - internal async Task TeardownAsync() - { - try - { - await FinishResponseOnce(); - } - finally - { - UnregisterAuthenticationHandler(); - } - } - - /// - /// Called once by common code after initialization. If an authentication middleware responds directly to - /// specifically known paths it must override this virtual, compare the request path to it's known paths, - /// provide any response information as appropriate, and true to stop further processing. - /// - /// Returning false will cause the common code to call the next middleware in line. Returning true will - /// cause the common code to begin the async completion journey without calling the rest of the middleware - /// pipeline. - public virtual Task HandleRequestAsync() - { - if (InitializeResult?.Handled == true) - { - return Task.FromResult(true); - } - return Task.FromResult(false); - } - - public void GetDescriptions(DescribeSchemesContext describeContext) - { - describeContext.Accept(Options.Description.Items); - - if (PriorHandler != null) - { - PriorHandler.GetDescriptions(describeContext); - } - } - - public bool ShouldHandleScheme(string authenticationScheme, bool handleAutomatic) - { - return string.Equals(Options.AuthenticationScheme, authenticationScheme, StringComparison.Ordinal) || - (handleAutomatic && string.Equals(authenticationScheme, AuthenticationManager.AutomaticScheme, StringComparison.Ordinal)); - } - - public async Task AuthenticateAsync(AuthenticateContext context) - { - var handled = false; - if (ShouldHandleScheme(context.AuthenticationScheme, Options.AutomaticAuthenticate)) - { - // Calling Authenticate more than once should always return the original value. - var result = await HandleAuthenticateOnceAsync(); - - if (result?.Failure != null) + var ticket = result?.Ticket; + if (ticket?.Principal != null) { - context.Failed(result.Failure); + Logger.AuthenticationSchemeAuthenticated(Scheme.Name); } else { - var ticket = result?.Ticket; - if (ticket?.Principal != null) - { - context.Authenticated(ticket.Principal, ticket.Properties.Items, Options.Description.Items); - Logger.AuthenticationSchemeAuthenticated(Options.AuthenticationScheme); - handled = true; - } - else - { - context.NotAuthenticated(); - Logger.AuthenticationSchemeNotAuthenticated(Options.AuthenticationScheme); - } + Logger.AuthenticationSchemeNotAuthenticated(Scheme.Name); } } - - if (PriorHandler != null && !handled) - { - await PriorHandler.AuthenticateAsync(context); - } + return result; } /// @@ -280,17 +200,13 @@ namespace Microsoft.AspNetCore.Authentication public async Task SignInAsync(SignInContext context) { - if (ShouldHandleScheme(context.AuthenticationScheme, handleAutomatic: false)) + if (context == null) { - SignInAccepted = true; - await HandleSignInAsync(context); - Logger.AuthenticationSchemeSignedIn(Options.AuthenticationScheme); - context.Accept(); - } - else if (PriorHandler != null) - { - await PriorHandler.SignInAsync(context); + throw new ArgumentNullException(nameof(context)); } + + await HandleSignInAsync(context); + Logger.AuthenticationSchemeSignedIn(Scheme.Name); } protected virtual Task HandleSignInAsync(SignInContext context) @@ -305,17 +221,8 @@ namespace Microsoft.AspNetCore.Authentication throw new ArgumentNullException(nameof(context)); } - if (ShouldHandleScheme(context.AuthenticationScheme, handleAutomatic: false)) - { - SignOutAccepted = true; - await HandleSignOutAsync(context); - Logger.AuthenticationSchemeSignedOut(Options.AuthenticationScheme); - context.Accept(); - } - else if (PriorHandler != null) - { - await PriorHandler.SignOutAsync(context); - } + await HandleSignOutAsync(context); + Logger.AuthenticationSchemeSignedOut(Scheme.Name); } protected virtual Task HandleSignOutAsync(SignOutContext context) @@ -327,10 +234,11 @@ namespace Microsoft.AspNetCore.Authentication /// Override this method to deal with a challenge that is forbidden. /// /// - protected virtual Task HandleForbiddenAsync(ChallengeContext context) + /// A Task. + protected virtual Task HandleForbiddenAsync(ChallengeContext context) { Response.StatusCode = 403; - return Task.FromResult(true); + return TaskCache.CompletedTask; } /// @@ -339,58 +247,34 @@ namespace Microsoft.AspNetCore.Authentication /// changing the 401 result to 302 of a login page or external sign-in location.) /// /// - /// True if no other handlers should be called - protected virtual Task HandleUnauthorizedAsync(ChallengeContext context) + /// A Task. + protected virtual Task HandleUnauthorizedAsync(ChallengeContext context) { Response.StatusCode = 401; - return Task.FromResult(false); + return TaskCache.CompletedTask; } public async Task ChallengeAsync(ChallengeContext context) { - ChallengeCalled = true; - var handled = false; - if (ShouldHandleScheme(context.AuthenticationScheme, Options.AutomaticChallenge)) + switch (context.Behavior) { - switch (context.Behavior) - { - case ChallengeBehavior.Automatic: - // If there is a principal already, invoke the forbidden code path - var result = await HandleAuthenticateOnceSafeAsync(); - if (result?.Ticket?.Principal != null) - { - goto case ChallengeBehavior.Forbidden; - } - goto case ChallengeBehavior.Unauthorized; - case ChallengeBehavior.Unauthorized: - handled = await HandleUnauthorizedAsync(context); - Logger.AuthenticationSchemeChallenged(Options.AuthenticationScheme); - break; - case ChallengeBehavior.Forbidden: - handled = await HandleForbiddenAsync(context); - Logger.AuthenticationSchemeForbidden(Options.AuthenticationScheme); - break; - } - context.Accept(); + case ChallengeBehavior.Automatic: + // If there is a principal already, invoke the forbidden code path + var result = await HandleAuthenticateOnceSafeAsync(); + if (result?.Principal != null) + { + goto case ChallengeBehavior.Forbidden; + } + goto case ChallengeBehavior.Unauthorized; + case ChallengeBehavior.Unauthorized: + await HandleUnauthorizedAsync(context); + Logger.AuthenticationSchemeChallenged(Scheme.Name); + break; + case ChallengeBehavior.Forbidden: + await HandleForbiddenAsync(context); + Logger.AuthenticationSchemeForbidden(Scheme.Name); + break; } - - if (!handled && PriorHandler != null) - { - await PriorHandler.ChallengeAsync(context); - } - } - - private void RegisterAuthenticationHandler() - { - var auth = Context.GetAuthentication(); - PriorHandler = auth.Handler; - auth.Handler = this; - } - - private void UnregisterAuthenticationHandler() - { - var auth = Context.GetAuthentication(); - auth.Handler = PriorHandler; } } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs index a01490c3e4..eba561d1da 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs @@ -2,90 +2,65 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Authentication { - public abstract class AuthenticationMiddleware where TOptions : AuthenticationOptions, new() + public class AuthenticationMiddleware { private readonly RequestDelegate _next; - protected AuthenticationMiddleware( - RequestDelegate next, - IOptions options, - ILoggerFactory loggerFactory, - UrlEncoder encoder) + public AuthenticationMiddleware(RequestDelegate next, IAuthenticationSchemeProvider schemes) { if (next == null) { throw new ArgumentNullException(nameof(next)); } - - if (options == null) + if (schemes == null) { - throw new ArgumentNullException(nameof(options)); - } - - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - if (encoder == null) - { - throw new ArgumentNullException(nameof(encoder)); - } - - Options = options.Value; - Logger = loggerFactory.CreateLogger(this.GetType().FullName); - UrlEncoder = encoder; - - if (string.IsNullOrEmpty(Options.ClaimsIssuer)) - { - // Default to something reasonable - Options.ClaimsIssuer = Options.AuthenticationScheme; + throw new ArgumentNullException(nameof(schemes)); } _next = next; + Schemes = schemes; } - public string AuthenticationScheme { get; set; } - - public TOptions Options { get; set; } - - public ILogger Logger { get; set; } - - public UrlEncoder UrlEncoder { get; set; } + public IAuthenticationSchemeProvider Schemes { get; set; } public async Task Invoke(HttpContext context) { - var handler = CreateHandler(); - await handler.InitializeAsync(Options, context, Logger, UrlEncoder); - try + context.Features.Set(new AuthenticationFeature { - if (!await handler.HandleRequestAsync()) - { - await _next(context); - } - } - finally - { - try - { - await handler.TeardownAsync(); - } - catch (Exception) - { - // Don't mask the original exception, if any - } - } - } + OriginalPath = context.Request.Path, + OriginalPathBase = context.Request.PathBase + }); - protected abstract AuthenticationHandler CreateHandler(); + // REVIEW: alternatively could depend on a routing middleware to do this + + // Give any IAuthenticationRequestHandler schemes a chance to handle the request + var handlers = context.RequestServices.GetRequiredService(); + foreach (var scheme in await Schemes.GetRequestHandlerSchemesAsync()) + { + var handler = await handlers.GetHandlerAsync(context, scheme.Name) as IAuthenticationRequestHandler; + if (handler != null && await handler.HandleRequestAsync()) + { + return; + } + } + + var defaultAuthenticate = await Schemes.GetDefaultAuthenticateSchemeAsync(); + if (defaultAuthenticate != null) + { + var result = await context.AuthenticateAsync(defaultAuthenticate.Name); + if (result?.Principal != null) + { + context.User = result.Principal; + } + } + + await _next(context); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs deleted file mode 100644 index 34ec577f18..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationOptions.cs +++ /dev/null @@ -1,59 +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.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http.Authentication; -using System.ComponentModel; - -namespace Microsoft.AspNetCore.Builder -{ - /// - /// Base Options for all authentication middleware. - /// - public abstract class AuthenticationOptions - { - private string _authenticationScheme; - - /// - /// The AuthenticationScheme in the options corresponds to the logical name for a particular authentication scheme. A different - /// value may be assigned in order to use the same authentication middleware type more than once in a pipeline. - /// - public string AuthenticationScheme - { - get { return _authenticationScheme; } - set - { - _authenticationScheme = value; - Description.AuthenticationScheme = value; - } - } - - /// - /// If true the authentication middleware alter the request user coming in. If false the authentication middleware will only provide - /// identity when explicitly indicated by the AuthenticationScheme. - /// - public bool AutomaticAuthenticate { get; set; } - - /// - /// If true the authentication middleware should handle automatic challenge. - /// If false the authentication middleware will only alter responses when explicitly indicated by the AuthenticationScheme. - /// - public bool AutomaticChallenge { get; set; } - - /// - /// Gets or sets the issuer that should be used for any claims that are created - /// - public string ClaimsIssuer { get; set; } - - /// - /// Additional information about the authentication type which is made available to the application. - /// - public AuthenticationDescription Description { get; set; } = new AuthenticationDescription(); - - /// - /// For testing purposes only. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public ISystemClock SystemClock { get; set; } = new SystemClock(); - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs new file mode 100644 index 0000000000..09e7abbd4f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -0,0 +1,50 @@ +// 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.AspNetCore.Authentication +{ + /// + /// Contains the options used by the . + /// + public class AuthenticationSchemeOptions + { + /// + /// Check that the options are valid. Should throw an exception if things are not ok. + /// + public virtual void Validate() + { + } + + /// + /// Gets or sets the display name for the authentication provider. + /// + public string DisplayName { get; set; } + + /// + /// Gets or sets the issuer that should be used for any claims that are created + /// + public string ClaimsIssuer { get; set; } + + /// + /// Instance used for events + /// + public object Events { get; set; } + + /// + /// If set, will be used as the service type to get the Events instance instead of the property. + /// + public Type EventsType { get; set; } + + /// + /// Used to ensure that the options are only initialized once. + /// + public bool Initialized { get; set; } + + /// + /// Used to prevent concurrent access during intialization. + /// + public object InitializeLock { get; } = new object(); + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 2aa320ae21..074f45b5fb 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -2,7 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection { @@ -11,11 +15,6 @@ namespace Microsoft.Extensions.DependencyInjection /// public static class AuthenticationServiceCollectionExtensions { - /// - /// Adds authentication services to the specified . - /// - /// The to add services to. - /// The so that additional calls can be chained. public static IServiceCollection AddAuthentication(this IServiceCollection services) { if (services == null) @@ -23,19 +22,14 @@ namespace Microsoft.Extensions.DependencyInjection throw new ArgumentNullException(nameof(services)); } - services.AddWebEncoders(); + services.AddAuthenticationCore(); services.AddDataProtection(); + services.AddWebEncoders(); + services.TryAddSingleton(); return services; } - /// - /// Adds authentication services to the specified . - /// - /// The to add services to. - /// An action delegate to configure the provided . - /// The so that additional calls can be chained. - public static IServiceCollection AddAuthentication(this IServiceCollection services, Action configureOptions) - { + public static IServiceCollection AddAuthentication(this IServiceCollection services, Action configureOptions) { if (services == null) { throw new ArgumentNullException(nameof(services)); @@ -46,8 +40,33 @@ namespace Microsoft.Extensions.DependencyInjection throw new ArgumentNullException(nameof(configureOptions)); } + services.AddAuthentication(); services.Configure(configureOptions); - return services.AddAuthentication(); + return services; } + + public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, Action configureScheme, Action configureOptions) + where TOptions : AuthenticationSchemeOptions, new() + where THandler : AuthenticationHandler + { + services.AddAuthentication(o => + { + o.AddScheme(authenticationScheme, scheme => { + scheme.HandlerType = typeof(THandler); + configureScheme?.Invoke(scheme); + }); + }); + if (configureOptions != null) + { + services.Configure(authenticationScheme, configureOptions); + } + services.AddTransient(); + return services; + } + + public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, Action configureOptions) + where TOptions : AuthenticationSchemeOptions, new() + where THandler : AuthenticationHandler + => services.AddScheme(authenticationScheme, configureScheme: null, configureOptions: configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationTicket.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationTicket.cs deleted file mode 100644 index 1d56a8fb34..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationTicket.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Security.Claims; -using Microsoft.AspNetCore.Http.Authentication; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Contains user identity information as well as additional authentication state. - /// - public class AuthenticationTicket - { - /// - /// Initializes a new instance of the class - /// - /// the that represents the authenticated user. - /// additional properties that can be consumed by the user or runtime. - /// the authentication middleware that was responsible for this ticket. - public AuthenticationTicket(ClaimsPrincipal principal, AuthenticationProperties properties, string authenticationScheme) - { - if (principal == null) - { - throw new ArgumentNullException(nameof(principal)); - } - AuthenticationScheme = authenticationScheme; - Principal = principal; - Properties = properties ?? new AuthenticationProperties(); - } - - /// - /// Gets the authentication type. - /// - public string AuthenticationScheme { get; private set; } - - /// - /// Gets the claims-principal with authenticated user identities. - /// - public ClaimsPrincipal Principal{ get; private set; } - - /// - /// Additional state values for the authentication session. - /// - public AuthenticationProperties Properties { get; private set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationToken.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationToken.cs deleted file mode 100644 index 6503f0bb85..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationToken.cs +++ /dev/null @@ -1,12 +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.AspNetCore.Authentication -{ - public class AuthenticationToken - { - public string Name { get; set; } - public string Value { get; set; } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs deleted file mode 100644 index 1edb4a0f4b..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationAppBuilderExtensions.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Security.Claims; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Builder -{ - /// - /// Extension methods to add claims transformation capabilities to an HTTP application pipeline. - /// - public static class ClaimsTransformationAppBuilderExtensions - { - /// - /// Adds the middleware to the specified , which enables claims transformation capabilities. - /// - /// The to add the middleware to. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - - return app.UseMiddleware(); - } - - /// - /// Adds the middleware to the specified , which enables claims transformation capabilities. - /// - /// The to add the middleware to. - /// A function that asynchronously transforms one to another. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, Func> transform) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (transform == null) - { - throw new ArgumentNullException(nameof(transform)); - } - - return app.UseClaimsTransformation(new ClaimsTransformationOptions - { - Transformer = new ClaimsTransformer { OnTransform = transform } - }); - } - - /// - /// Adds the middleware to the specified , which enables claims transformation capabilities. - /// - /// The to add the middleware to. - /// The to configure the middleware with. - /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, ClaimsTransformationOptions options) - { - if (app == null) - { - throw new ArgumentNullException(nameof(app)); - } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - return app.UseMiddleware(Options.Create(options)); - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationContext.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationContext.cs deleted file mode 100644 index 3c363ca98f..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationContext.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Microsoft.AspNetCore.Http; -using System.Security.Claims; - -namespace Microsoft.AspNetCore.Authentication -{ - public class ClaimsTransformationContext - { - public ClaimsTransformationContext(HttpContext context) - { - Context = context; - } - public HttpContext Context { get; } - public ClaimsPrincipal Principal { get; set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs deleted file mode 100644 index 27965dbf4e..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationHandler.cs +++ /dev/null @@ -1,92 +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.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.Extensions.Internal; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Handler that applies ClaimsTransformation to authentication - /// - public class ClaimsTransformationHandler : IAuthenticationHandler - { - private readonly IClaimsTransformer _transform; - private readonly HttpContext _httpContext; - - public ClaimsTransformationHandler(IClaimsTransformer transform, HttpContext httpContext) - { - _transform = transform; - _httpContext = httpContext; - } - - public IAuthenticationHandler PriorHandler { get; set; } - - public async Task AuthenticateAsync(AuthenticateContext context) - { - if (PriorHandler != null) - { - await PriorHandler.AuthenticateAsync(context); - if (_transform != null && context?.Principal != null) - { - var transformationContext = new ClaimsTransformationContext(_httpContext) - { - Principal = context.Principal - }; - context.Authenticated( - await _transform.TransformAsync(transformationContext), - context.Properties, - context.Description); - } - } - } - - public Task ChallengeAsync(ChallengeContext context) - { - if (PriorHandler != null) - { - return PriorHandler.ChallengeAsync(context); - } - return TaskCache.CompletedTask; - } - - public void GetDescriptions(DescribeSchemesContext context) - { - if (PriorHandler != null) - { - PriorHandler.GetDescriptions(context); - } - } - - public Task SignInAsync(SignInContext context) - { - if (PriorHandler != null) - { - return PriorHandler.SignInAsync(context); - } - return TaskCache.CompletedTask; - } - - public Task SignOutAsync(SignOutContext context) - { - if (PriorHandler != null) - { - return PriorHandler.SignOutAsync(context); - } - return TaskCache.CompletedTask; - } - - public void RegisterAuthenticationHandler(IHttpAuthenticationFeature auth) - { - PriorHandler = auth.Handler; - auth.Handler = this; - } - - public void UnregisterAuthenticationHandler(IHttpAuthenticationFeature auth) - { - auth.Handler = PriorHandler; - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs deleted file mode 100644 index 53f6a07a87..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationMiddleware.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication -{ - public class ClaimsTransformationMiddleware - { - private readonly RequestDelegate _next; - - public ClaimsTransformationMiddleware( - RequestDelegate next, - IOptions options) - { - if (next == null) - { - throw new ArgumentNullException(nameof(next)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - Options = options.Value; - _next = next; - } - - public ClaimsTransformationOptions Options { get; set; } - - public async Task Invoke(HttpContext context) - { - var handler = new ClaimsTransformationHandler(Options.Transformer, context); - handler.RegisterAuthenticationHandler(context.GetAuthentication()); - try - { - if (Options.Transformer != null) - { - var transformationContext = new ClaimsTransformationContext(context) - { - Principal = context.User - }; - context.User = await Options.Transformer.TransformAsync(transformationContext); - } - await _next(context); - } - finally - { - handler.UnregisterAuthenticationHandler(context.GetAuthentication()); - } - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs deleted file mode 100644 index 70a76f27c6..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformationOptions.cs +++ /dev/null @@ -1,18 +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.AspNetCore.Authentication; - -namespace Microsoft.AspNetCore.Builder -{ - /// - /// Contains the options used by the . - /// - public class ClaimsTransformationOptions - { - /// - /// Responsible for transforming the claims principal. - /// - public IClaimsTransformer Transformer { get; set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs b/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs deleted file mode 100644 index db05db0e5b..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/ClaimsTransformer.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace Microsoft.AspNetCore.Authentication -{ - public class ClaimsTransformer : IClaimsTransformer - { - public Func> OnTransform { get; set; } - - public virtual Task TransformAsync(ClaimsTransformationContext context) - { - return OnTransform?.Invoke(context) ?? Task.FromResult(context.Principal); - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/IDataSerializer.cs b/src/Microsoft.AspNetCore.Authentication/Data/IDataSerializer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/DataHandler/IDataSerializer.cs rename to src/Microsoft.AspNetCore.Authentication/Data/IDataSerializer.cs diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/ISecureDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/Data/ISecureDataFormat.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/DataHandler/ISecureDataFormat.cs rename to src/Microsoft.AspNetCore.Authentication/Data/ISecureDataFormat.cs diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/Data/PropertiesDataFormat.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesDataFormat.cs rename to src/Microsoft.AspNetCore.Authentication/Data/PropertiesDataFormat.cs diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs b/src/Microsoft.AspNetCore.Authentication/Data/PropertiesSerializer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/DataHandler/PropertiesSerializer.cs rename to src/Microsoft.AspNetCore.Authentication/Data/PropertiesSerializer.cs diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/SecureDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/Data/SecureDataFormat.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/DataHandler/SecureDataFormat.cs rename to src/Microsoft.AspNetCore.Authentication/Data/SecureDataFormat.cs diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs b/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/DataHandler/TextEncoder.cs rename to src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketDataFormat.cs b/src/Microsoft.AspNetCore.Authentication/Data/TicketDataFormat.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/DataHandler/TicketDataFormat.cs rename to src/Microsoft.AspNetCore.Authentication/Data/TicketDataFormat.cs diff --git a/src/Microsoft.AspNetCore.Authentication/DataHandler/TicketSerializer.cs b/src/Microsoft.AspNetCore.Authentication/Data/TicketSerializer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/DataHandler/TicketSerializer.cs rename to src/Microsoft.AspNetCore.Authentication/Data/TicketSerializer.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs deleted file mode 100644 index 10b3325d4f..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs +++ /dev/null @@ -1,27 +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.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication -{ - public abstract class BaseContext - { - protected BaseContext(HttpContext context) - { - HttpContext = context; - } - - public HttpContext HttpContext { get; private set; } - - public HttpRequest Request - { - get { return HttpContext.Request; } - } - - public HttpResponse Response - { - get { return HttpContext.Response; } - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs index 4039a05609..fa582a3040 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs @@ -34,10 +34,10 @@ namespace Microsoft.AspNetCore.Authentication } /// - /// Discontinue processing the request in the current middleware and pass control to the next one. + /// Discontinue processing the request in the current handler. /// SignIn will not be called. /// - public void SkipToNextMiddleware() + public void Skip() { State = EventResultState.Skipped; } @@ -47,7 +47,12 @@ namespace Microsoft.AspNetCore.Authentication /// public AuthenticationTicket Ticket { get; set; } - public bool CheckEventResult(out AuthenticateResult result) + /// + /// Returns true if the handler should be done processing. + /// + /// The result. + /// Whether the handler should be done processing. + public bool IsProcessingComplete(out AuthenticateResult result) { if (HandledResponse) { @@ -63,7 +68,7 @@ namespace Microsoft.AspNetCore.Authentication } else if (Skipped) { - result = AuthenticateResult.Skip(); + result = AuthenticateResult.None(); return true; } result = null; diff --git a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs b/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs index b11dec93f1..dad4c40fec 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Authentication Continue, /// - /// Discontinue processing the request in the current middleware and pass control to the next one. + /// Discontinue processing the request. /// Skipped, diff --git a/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs index 35af9cee30..5d2b30f130 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication { /// - /// Provides failure context information to middleware providers. + /// Provides failure context information to handler providers. /// public class FailureContext : BaseControlContext { diff --git a/src/Microsoft.AspNetCore.Authentication/Events/IRemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/IRemoteAuthenticationEvents.cs deleted file mode 100644 index e2109a0651..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/Events/IRemoteAuthenticationEvents.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 System.Threading.Tasks; - -namespace Microsoft.AspNetCore.Authentication -{ - public interface IRemoteAuthenticationEvents - { - /// - /// Invoked when the remote authentication process has an error. - /// - Task RemoteFailure(FailureContext context); - - /// - /// Invoked before sign in. - /// - Task TicketReceived(TicketReceivedContext context); - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs index 6e7d6a35c6..a130c1b14c 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication { - public class RemoteAuthenticationEvents : IRemoteAuthenticationEvents + public class RemoteAuthenticationEvents { public Func OnRemoteFailure { get; set; } = context => TaskCache.CompletedTask; diff --git a/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs index 5d5fd4883c..c0797ea9cc 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs @@ -2,14 +2,13 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication { /// - /// Provides context information to middleware providers. + /// Provides context information to handler providers. /// public class TicketReceivedContext : BaseControlContext { diff --git a/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs b/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.cs deleted file mode 100644 index 0d245cf0a7..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/HttpContextExtensions.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.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features.Authentication; - -namespace Microsoft.AspNetCore.Authentication -{ - internal static class HttpContextExtensions - { - internal static IHttpAuthenticationFeature GetAuthentication(this HttpContext context) - { - var auth = context.Features.Get(); - if (auth == null) - { - auth = new HttpAuthenticationFeature(); - context.Features.Set(auth); - } - return auth; - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs b/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.cs deleted file mode 100644 index cd42915c0a..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/IClaimsTransformer.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.Security.Claims; -using System.Threading.Tasks; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Used for claims transformation. - /// - public interface IClaimsTransformer - { - /// - /// Provides a central transformation point to change the specified principal. - /// - /// containing principal to transform and current HttpContext. - /// The transformed principal. - Task TransformAsync(ClaimsTransformationContext context); - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 316defc436..d4335f6d4a 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -11,6 +11,7 @@ + diff --git a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs index a6cf910462..11e2e45868 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs @@ -1,6 +1,7 @@ // namespace Microsoft.AspNetCore.Authentication { + using System.Globalization; using System.Reflection; using System.Resources; @@ -57,6 +58,22 @@ namespace Microsoft.AspNetCore.Authentication return GetString("Exception_AuthenticationTokenDoesNotProvideSyncMethods"); } + /// + /// The '{0}' option must be provided. + /// + internal static string Exception_OptionMustBeProvided + { + get { return GetString("Exception_OptionMustBeProvided"); } + } + + /// + /// The '{0}' option must be provided. + /// + internal static string FormatException_OptionMustBeProvided(object p0) + { + return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); + } + private static string GetString(string name, params string[] formatterNames) { var value = _resourceManager.GetString(name); diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 1e41fb0b50..fc663317e4 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -3,16 +3,18 @@ using System; using System.Security.Cryptography; +using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication { - public abstract class RemoteAuthenticationHandler : AuthenticationHandler where TOptions : RemoteAuthenticationOptions + public abstract class RemoteAuthenticationHandler : AuthenticationHandler, IAuthenticationRequestHandler + where TOptions : RemoteAuthenticationOptions, new() { private const string CorrelationPrefix = ".AspNetCore.Correlation."; private const string CorrelationProperty = ".xsrf"; @@ -21,21 +23,64 @@ namespace Microsoft.AspNetCore.Authentication private static readonly RandomNumberGenerator CryptoRandom = RandomNumberGenerator.Create(); - public override async Task HandleRequestAsync() - { - if (Options.CallbackPath == Request.Path) - { - return await HandleRemoteCallbackAsync(); - } + protected string SignInScheme => Options.SignInScheme; - return false; + protected IDataProtectionProvider DataProtection { get; set; } + + private readonly AuthenticationOptions _authOptions; + + /// + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// If it is not provided a default instance is supplied which does nothing when the methods are called. + /// + protected new RemoteAuthenticationEvents Events + { + get { return (RemoteAuthenticationEvents)base.Events; } + set { base.Events = value; } } - protected virtual async Task HandleRemoteCallbackAsync() + protected RemoteAuthenticationHandler(IOptions sharedOptions, IOptionsSnapshot options, IDataProtectionProvider dataProtection, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { + _authOptions = sharedOptions.Value; + DataProtection = dataProtection; + } + + protected override Task InitializeHandlerAsync() + { + DataProtection = Options.DataProtectionProvider ?? DataProtection; + return TaskCache.CompletedTask; + } + + protected override Task CreateEventsAsync() + { + return Task.FromResult(new RemoteAuthenticationEvents()); + } + + protected override void InitializeOptions() + { + base.InitializeOptions(); + + if (Options.SignInScheme == null) + { + Options.SignInScheme = _authOptions.DefaultSignInScheme; + } + } + + public virtual Task ShouldHandleRequestAsync() + { + return Task.FromResult(Options.CallbackPath == Request.Path); + } + + public virtual async Task HandleRequestAsync() + { + if (!await ShouldHandleRequestAsync()) + { + return false; + } + AuthenticationTicket ticket = null; Exception exception = null; - try { var authResult = await HandleRemoteAuthenticateAsync(); @@ -47,7 +92,7 @@ namespace Microsoft.AspNetCore.Authentication { return true; } - else if (authResult.Skipped) + else if (authResult.Nothing) { return false; } @@ -68,14 +113,13 @@ namespace Microsoft.AspNetCore.Authentication { Logger.RemoteAuthenticationError(exception.Message); var errorContext = new FailureContext(Context, exception); - await Options.Events.RemoteFailure(errorContext); + await Events.RemoteFailure(errorContext); if (errorContext.HandledResponse) { return true; } - - if (errorContext.Skipped) + else if (errorContext.Skipped) { return false; } @@ -84,7 +128,7 @@ namespace Microsoft.AspNetCore.Authentication } // We have a ticket if we get here - var context = new TicketReceivedContext(Context, Options, ticket) + var ticketContext = new TicketReceivedContext(Context, Options, ticket) { ReturnUri = ticket.Properties.RedirectUri, }; @@ -92,30 +136,30 @@ namespace Microsoft.AspNetCore.Authentication ticket.Properties.RedirectUri = null; // Mark which provider produced this identity so we can cross-check later in HandleAuthenticateAsync - context.Properties.Items[AuthSchemeKey] = Options.AuthenticationScheme; + ticketContext.Properties.Items[AuthSchemeKey] = Scheme.Name; - await Options.Events.TicketReceived(context); + await Events.TicketReceived(ticketContext); - if (context.HandledResponse) + if (ticketContext.HandledResponse) { Logger.SigninHandled(); return true; } - else if (context.Skipped) + else if (ticketContext.Skipped) { Logger.SigninSkipped(); return false; } - await Context.Authentication.SignInAsync(Options.SignInScheme, context.Principal, context.Properties); + await Context.SignInAsync(SignInScheme, ticketContext.Principal, ticketContext.Properties); // Default redirect path is the base path - if (string.IsNullOrEmpty(context.ReturnUri)) + if (string.IsNullOrEmpty(ticketContext.ReturnUri)) { - context.ReturnUri = "/"; + ticketContext.ReturnUri = "/"; } - Response.Redirect(context.ReturnUri); + Response.Redirect(ticketContext.ReturnUri); return true; } @@ -128,34 +172,29 @@ namespace Microsoft.AspNetCore.Authentication protected override async Task HandleAuthenticateAsync() { - // Most RemoteAuthenticationHandlers will have a PriorHandler, but it might not be set up during unit tests. - if (PriorHandler != null) + var result = await Context.AuthenticateAsync(SignInScheme); + if (result != null) { - var authenticateContext = new AuthenticateContext(Options.SignInScheme); - await PriorHandler.AuthenticateAsync(authenticateContext); - if (authenticateContext.Accepted) + if (result.Failure != null) { - if (authenticateContext.Error != null) - { - return AuthenticateResult.Fail(authenticateContext.Error); - } - - // The SignInScheme may be shared with multiple providers, make sure this middleware issued the identity. - string authenticatedScheme; - if (authenticateContext.Principal != null && authenticateContext.Properties != null - && authenticateContext.Properties.TryGetValue(AuthSchemeKey, out authenticatedScheme) - && string.Equals(Options.AuthenticationScheme, authenticatedScheme, StringComparison.Ordinal)) - { - return AuthenticateResult.Success(new AuthenticationTicket(authenticateContext.Principal, - new AuthenticationProperties(authenticateContext.Properties), Options.AuthenticationScheme)); - } - - return AuthenticateResult.Fail("Not authenticated"); + return result; } + // The SignInScheme may be shared with multiple providers, make sure this provider issued the identity. + string authenticatedScheme; + var ticket = result.Ticket; + if (ticket != null && ticket.Principal != null && ticket.Properties != null + && ticket.Properties.Items.TryGetValue(AuthSchemeKey, out authenticatedScheme) + && string.Equals(Scheme.Name, authenticatedScheme, StringComparison.Ordinal)) + { + return AuthenticateResult.Success(new AuthenticationTicket(ticket.Principal, + ticket.Properties, Scheme.Name)); + } + + return AuthenticateResult.Fail("Not authenticated"); } - return AuthenticateResult.Fail("Remote authentication does not directly support authenticate"); + return AuthenticateResult.Fail("Remote authentication does not directly support AuthenticateAsync"); } protected override Task HandleSignOutAsync(SignOutContext context) @@ -168,11 +207,10 @@ namespace Microsoft.AspNetCore.Authentication throw new NotSupportedException(); } - protected override async Task HandleForbiddenAsync(ChallengeContext context) + // REVIEW: This behaviour needs a test (forwarding of forbidden to sign in scheme) + protected override Task HandleForbiddenAsync(ChallengeContext context) { - var challengeContext = new ChallengeContext(Options.SignInScheme, context.Properties, ChallengeBehavior.Forbidden); - await PriorHandler.ChallengeAsync(challengeContext); - return challengeContext.Accepted; + return Context.ForbidAsync(SignInScheme); } protected virtual void GenerateCorrelationId(AuthenticationProperties properties) @@ -190,12 +228,12 @@ namespace Microsoft.AspNetCore.Authentication { HttpOnly = true, Secure = Request.IsHttps, - Expires = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout), + Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; properties.Items[CorrelationProperty] = correlationId; - var cookieName = CorrelationPrefix + Options.AuthenticationScheme + "." + correlationId; + var cookieName = CorrelationPrefix + Scheme.Name + "." + correlationId; Response.Cookies.Append(cookieName, CorrelationMarker, cookieOptions); } @@ -216,7 +254,7 @@ namespace Microsoft.AspNetCore.Authentication properties.Items.Remove(CorrelationProperty); - var cookieName = CorrelationPrefix + Options.AuthenticationScheme + "." + correlationId; + var cookieName = CorrelationPrefix + Scheme.Name + "." + correlationId; var correlationCookie = Request.Cookies[cookieName]; if (string.IsNullOrEmpty(correlationCookie)) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index e990abd05a..65cf6f2ec7 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -3,16 +3,33 @@ using System; using System.Net.Http; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Authentication; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Authentication { /// /// Contains the options used by the . /// - public class RemoteAuthenticationOptions : AuthenticationOptions + public class RemoteAuthenticationOptions : AuthenticationSchemeOptions { + /// + /// Check that the options are valid. Should throw an exception if things are not ok. + /// + public override void Validate() + { + base.Validate(); + if (CallbackPath == null || !CallbackPath.HasValue) + { + throw new ArgumentException(Resources.FormatException_OptionMustBeProvided(nameof(CallbackPath)), nameof(CallbackPath)); + } + + if (string.IsNullOrEmpty(SignInScheme)) + { + throw new ArgumentException(Resources.FormatException_OptionMustBeProvided(nameof(SignInScheme)), nameof(SignInScheme)); + } + } + /// /// Gets or sets timeout value in milliseconds for back channel communications with the remote identity provider. /// @@ -28,6 +45,16 @@ namespace Microsoft.AspNetCore.Builder /// public HttpMessageHandler BackchannelHttpHandler { get; set; } + /// + /// Used to communicate with the remote identity provider. + /// + public HttpClient Backchannel { get; set; } + + /// + /// Gets or sets the type used to secure data. + /// + public IDataProtectionProvider DataProtectionProvider { get; set; } + /// /// The request path within the application's base path where the user-agent will be returned. /// The middleware will process this request when it arrives. @@ -38,25 +65,20 @@ namespace Microsoft.AspNetCore.Builder /// Gets or sets the authentication scheme corresponding to the middleware /// responsible of persisting user's identity after a successful authentication. /// This value typically corresponds to a cookie middleware registered in the Startup class. - /// When omitted, is used as a fallback value. + /// When omitted, is used as a fallback value. /// public string SignInScheme { get; set; } - /// - /// Get or sets the text that the user can display on a sign in user interface. - /// - public string DisplayName - { - get { return Description.DisplayName; } - set { Description.DisplayName = value; } - } - /// /// Gets or sets the time limit for completing the authentication flow (15 minutes by default). /// public TimeSpan RemoteAuthenticationTimeout { get; set; } = TimeSpan.FromMinutes(15); - public IRemoteAuthenticationEvents Events = new RemoteAuthenticationEvents(); + public new RemoteAuthenticationEvents Events + { + get { return (RemoteAuthenticationEvents)base.Events; } + set { base.Events = value; } + } /// /// Defines whether access and refresh tokens should be stored in the diff --git a/src/Microsoft.AspNetCore.Authentication/Resources.resx b/src/Microsoft.AspNetCore.Authentication/Resources.resx index 77060045e0..54d22bcc94 100644 --- a/src/Microsoft.AspNetCore.Authentication/Resources.resx +++ b/src/Microsoft.AspNetCore.Authentication/Resources.resx @@ -126,4 +126,7 @@ The AuthenticationTokenProvider's required synchronous events have not been registered. + + The '{0}' option must be provided. + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.cs deleted file mode 100644 index 8b168c9a0a..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/SharedAuthenticationOptions.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.AspNetCore.Authentication -{ - public class SharedAuthenticationOptions - { - /// - /// Gets or sets the authentication scheme corresponding to the default middleware - /// responsible of persisting user's identity after a successful authentication. - /// This value typically corresponds to a cookie middleware registered in the Startup class. - /// - public string SignInScheme { get; set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/SystemClock.cs b/src/Microsoft.AspNetCore.Authentication/SystemClock.cs index e1c79192aa..2320982ce3 100644 --- a/src/Microsoft.AspNetCore.Authentication/SystemClock.cs +++ b/src/Microsoft.AspNetCore.Authentication/SystemClock.cs @@ -1,7 +1,6 @@ // 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.AspNetCore.Authentication diff --git a/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs b/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs deleted file mode 100644 index 9f5c96cc11..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/TokenExtensions.cs +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; - -namespace Microsoft.AspNetCore.Authentication -{ - public static class AuthenticationTokenExtensions - { - private static string TokenNamesKey = ".TokenNames"; - private static string TokenKeyPrefix = ".Token."; - - public static void StoreTokens(this AuthenticationProperties properties, IEnumerable tokens) - { - if (properties == null) - { - throw new ArgumentNullException(nameof(properties)); - } - if (tokens == null) - { - throw new ArgumentNullException(nameof(tokens)); - } - - // Clear old tokens first - var oldTokens = properties.GetTokens(); - foreach (var t in oldTokens) - { - properties.Items.Remove(TokenKeyPrefix + t.Name); - } - properties.Items.Remove(TokenNamesKey); - - var tokenNames = new List(); - foreach (var token in tokens) - { - // REVIEW: should probably check that there are no ; in the token name and throw or encode - tokenNames.Add(token.Name); - properties.Items[TokenKeyPrefix+token.Name] = token.Value; - } - if (tokenNames.Count > 0) - { - properties.Items[TokenNamesKey] = string.Join(";", tokenNames.ToArray()); - } - } - - public static string GetTokenValue(this AuthenticationProperties properties, string tokenName) - { - if (properties == null) - { - throw new ArgumentNullException(nameof(properties)); - } - if (tokenName == null) - { - throw new ArgumentNullException(nameof(tokenName)); - } - - var tokenKey = TokenKeyPrefix + tokenName; - return properties.Items.ContainsKey(tokenKey) - ? properties.Items[tokenKey] - : null; - } - - public static bool UpdateTokenValue(this AuthenticationProperties properties, string tokenName, string tokenValue) - { - if (properties == null) - { - throw new ArgumentNullException(nameof(properties)); - } - if (tokenName == null) - { - throw new ArgumentNullException(nameof(tokenName)); - } - - var tokenKey = TokenKeyPrefix + tokenName; - if (!properties.Items.ContainsKey(tokenKey)) - { - return false; - } - properties.Items[tokenKey] = tokenValue; - return true; - } - - public static IEnumerable GetTokens(this AuthenticationProperties properties) - { - if (properties == null) - { - throw new ArgumentNullException(nameof(properties)); - } - - var tokens = new List(); - if (properties.Items.ContainsKey(TokenNamesKey)) - { - var tokenNames = properties.Items[TokenNamesKey].Split(';'); - foreach (var name in tokenNames) - { - var token = properties.GetTokenValue(name); - if (token != null) - { - tokens.Add(new AuthenticationToken { Name = name, Value = token }); - } - } - } - - return tokens; - } - - public static Task GetTokenAsync(this AuthenticationManager manager, string tokenName) - { - return manager.GetTokenAsync(AuthenticationManager.AutomaticScheme, tokenName); - } - - public static async Task GetTokenAsync(this AuthenticationManager manager, string signInScheme, string tokenName) - { - if (manager == null) - { - throw new ArgumentNullException(nameof(manager)); - } - if (signInScheme == null) - { - throw new ArgumentNullException(nameof(signInScheme)); - } - if (tokenName == null) - { - throw new ArgumentNullException(nameof(tokenName)); - } - - var authContext = new AuthenticateContext(signInScheme); - await manager.AuthenticateAsync(authContext); - return new AuthenticationProperties(authContext.Properties).GetTokenValue(tokenName); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs index bb5700fc62..1564193b9e 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs @@ -13,9 +13,9 @@ namespace Microsoft.AspNetCore.Builder public static class CookiePolicyAppBuilderExtensions { /// - /// Adds the middleware to the specified , which enables cookie policy capabilities. + /// Adds the handler to the specified , which enables cookie policy capabilities. /// - /// The to add the middleware to. + /// The to add the handler to. /// A reference to this instance after the operation has completed. public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app) { @@ -28,10 +28,10 @@ namespace Microsoft.AspNetCore.Builder } /// - /// Adds the middleware to the specified , which enables cookie policy capabilities. + /// Adds the handler to the specified , which enables cookie policy capabilities. /// - /// The to add the middleware to. - /// A that specifies options for the middleware. + /// The to add the handler to. + /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app, CookiePolicyOptions options) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs deleted file mode 100644 index fade43716e..0000000000 --- a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationHandlerFacts.cs +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.IO; -using System.Security.Claims; -using System.Text.Encodings.Web; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features; -using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.Extensions.Logging; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication -{ - public class AuthenticationHandlerFacts - { - [Fact] - public async Task ShouldHandleSchemeAreDeterminedOnlyByMatchingAuthenticationScheme() - { - var handler = await TestHandler.Create("Alpha"); - var passiveNoMatch = handler.ShouldHandleScheme("Beta", handleAutomatic: false); - - handler = await TestHandler.Create("Alpha"); - var passiveWithMatch = handler.ShouldHandleScheme("Alpha", handleAutomatic: false); - - Assert.False(passiveNoMatch); - Assert.True(passiveWithMatch); - } - - [Fact] - public async Task AutomaticHandlerInAutomaticModeHandlesEmptyChallenges() - { - var handler = await TestAutoHandler.Create("ignored", true); - Assert.True(handler.ShouldHandleScheme(AuthenticationManager.AutomaticScheme, handleAutomatic: true)); - } - - [Theory] - [InlineData(null)] - [InlineData("")] - [InlineData(" ")] - [InlineData("notmatched")] - public async Task AutomaticHandlerDoesNotHandleSchemes(string scheme) - { - var handler = await TestAutoHandler.Create("ignored", true); - Assert.False(handler.ShouldHandleScheme(scheme, handleAutomatic: true)); - } - - [Fact] - public async Task AutomaticHandlerShouldHandleSchemeWhenSchemeMatches() - { - var handler = await TestAutoHandler.Create("Alpha", true); - Assert.True(handler.ShouldHandleScheme("Alpha", handleAutomatic: true)); - } - - [Fact] - public async Task AutomaticHandlerShouldNotHandleChallengeWhenSchemesNotEmpty() - { - var handler = await TestAutoHandler.Create(null, true); - Assert.False(handler.ShouldHandleScheme("Alpha", handleAutomatic: true)); - } - - [Theory] - [InlineData("Alpha")] - [InlineData("Automatic")] - public async Task AuthHandlerAuthenticateCachesTicket(string scheme) - { - var handler = await CountHandler.Create(scheme); - var context = new AuthenticateContext(scheme); - await handler.AuthenticateAsync(context); - await handler.AuthenticateAsync(context); - Assert.Equal(1, handler.AuthCount); - } - - [Theory] - [InlineData("Alpha", false)] - [InlineData("Bravo", true)] - public async Task AuthHandlerChallengeCallsPriorHandlerIfNotHandled(string challenge, bool passedThrough) - { - var handler = await TestHandler.Create("Alpha"); - var previous = new PreviousHandler(); - - handler.PriorHandler = previous; - await handler.ChallengeAsync(new ChallengeContext(challenge)); - Assert.Equal(passedThrough, previous.ChallengeCalled); - } - - private class PreviousHandler : IAuthenticationHandler - { - public bool ChallengeCalled = false; - - public Task AuthenticateAsync(AuthenticateContext context) - { - throw new NotImplementedException(); - } - - public Task ChallengeAsync(ChallengeContext context) - { - ChallengeCalled = true; - return Task.FromResult(0); - } - - public void GetDescriptions(DescribeSchemesContext context) - { - throw new NotImplementedException(); - } - - public Task SignInAsync(SignInContext context) - { - throw new NotImplementedException(); - } - - public Task SignOutAsync(SignOutContext context) - { - throw new NotImplementedException(); - } - } - - private class CountOptions : AuthenticationOptions { } - - private class CountHandler : AuthenticationHandler - { - public int AuthCount = 0; - - private CountHandler() { } - - public static async Task Create(string scheme) - { - var handler = new CountHandler(); - var context = new DefaultHttpContext(); - context.Features.Set(new TestResponse()); - await handler.InitializeAsync( - new CountOptions(), context, - new LoggerFactory().CreateLogger("CountHandler"), - UrlEncoder.Default); - handler.Options.AuthenticationScheme = scheme; - handler.Options.AutomaticAuthenticate = true; - return handler; - } - - protected override Task HandleAuthenticateAsync() - { - AuthCount++; - return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), new AuthenticationProperties(), "whatever"))); - } - - } - - private class TestHandler : AuthenticationHandler - { - private TestHandler() { } - - public AuthenticateResult Result = AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), new AuthenticationProperties(), "whatever")); - - public static async Task Create(string scheme) - { - var handler = new TestHandler(); - var context = new DefaultHttpContext(); - context.Features.Set(new TestResponse()); - await handler.InitializeAsync( - new TestOptions(), context, - new LoggerFactory().CreateLogger("TestHandler"), - UrlEncoder.Default); - handler.Options.AuthenticationScheme = scheme; - return handler; - } - - protected override Task HandleAuthenticateAsync() - { - return Task.FromResult(Result); - } - } - - private class TestOptions : AuthenticationOptions { } - - private class TestAutoOptions : AuthenticationOptions - { - public TestAutoOptions() - { - AutomaticAuthenticate = true; - } - } - - private class TestAutoHandler : AuthenticationHandler - { - private TestAutoHandler() { } - - public static async Task Create(string scheme, bool auto) - { - var handler = new TestAutoHandler(); - var context = new DefaultHttpContext(); - context.Features.Set(new TestResponse()); - await handler.InitializeAsync( - new TestAutoOptions(), context, - new LoggerFactory().CreateLogger("TestAutoHandler"), - UrlEncoder.Default); - handler.Options.AuthenticationScheme = scheme; - handler.Options.AutomaticAuthenticate = auto; - return handler; - } - - protected override Task HandleAuthenticateAsync() - { - return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), new AuthenticationProperties(), "whatever"))); - } - } - - private class TestResponse : IHttpResponseFeature - { - public Stream Body - { - get - { - throw new NotImplementedException(); - } - - set - { - throw new NotImplementedException(); - } - } - - public bool HasStarted - { - get - { - throw new NotImplementedException(); - } - } - - public IHeaderDictionary Headers - { - get - { - throw new NotImplementedException(); - } - - set - { - throw new NotImplementedException(); - } - } - - public string ReasonPhrase - { - get - { - throw new NotImplementedException(); - } - - set - { - throw new NotImplementedException(); - } - } - - public int StatusCode - { - get - { - throw new NotImplementedException(); - } - - set - { - } - } - - public void OnCompleted(Func callback, object state) - { - throw new NotImplementedException(); - } - - public void OnStarting(Func callback, object state) - { - } - } - } -} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs new file mode 100644 index 0000000000..c4720eb30c --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs @@ -0,0 +1,181 @@ +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. + +using System; +using System.Net; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication +{ + public class AuthenticationMiddlewareTests + { + [Fact] + public async Task OnlyInvokesCanHandleRequestHandlers() + { + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + }) + .ConfigureServices(services => services.AddAuthentication(o => + { + o.AddScheme("Skip", s => + { + s.HandlerType = typeof(SkipHandler); + }); + // Won't get hit since CanHandleRequests is false + o.AddScheme("throws", s => + { + s.HandlerType = typeof(ThrowsHandler); + }); + o.AddScheme("607", s => + { + s.HandlerType = typeof(SixOhSevenHandler); + }); + // Won't get run since 607 will finish + o.AddScheme("305", s => + { + s.HandlerType = typeof(ThreeOhFiveHandler); + }); + })); + var server = new TestServer(builder); + var response = await server.CreateClient().GetAsync("http://example.com/"); + Assert.Equal(607, (int)response.StatusCode); + } + + private class ThreeOhFiveHandler : StatusCodeHandler { + public ThreeOhFiveHandler() : base(305) { } + } + + private class SixOhSevenHandler : StatusCodeHandler + { + public SixOhSevenHandler() : base(607) { } + } + + private class SevenOhSevenHandler : StatusCodeHandler + { + public SevenOhSevenHandler() : base(707) { } + } + + private class StatusCodeHandler : IAuthenticationRequestHandler + { + private HttpContext _context; + private int _code; + + public StatusCodeHandler(int code) + { + _code = code; + } + + public Task AuthenticateAsync() + { + throw new NotImplementedException(); + } + + public Task ChallengeAsync(ChallengeContext context) + { + throw new NotImplementedException(); + } + + public Task HandleRequestAsync() + { + _context.Response.StatusCode = _code; + return Task.FromResult(true); + } + + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + _context = context; + return Task.FromResult(0); + } + + public Task SignInAsync(SignInContext context) + { + throw new NotImplementedException(); + } + + public Task SignOutAsync(SignOutContext context) + { + throw new NotImplementedException(); + } + } + + private class ThrowsHandler : IAuthenticationHandler + { + private HttpContext _context; + + public Task AuthenticateAsync() + { + throw new NotImplementedException(); + } + + public Task ChallengeAsync(ChallengeContext context) + { + throw new NotImplementedException(); + } + + public Task HandleRequestAsync() + { + throw new NotImplementedException(); + } + + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + _context = context; + return Task.FromResult(0); + } + + public Task SignInAsync(SignInContext context) + { + throw new NotImplementedException(); + } + + public Task SignOutAsync(SignOutContext context) + { + throw new NotImplementedException(); + } + } + + private class SkipHandler : IAuthenticationRequestHandler + { + private HttpContext _context; + + public Task AuthenticateAsync() + { + throw new NotImplementedException(); + } + + public Task ChallengeAsync(ChallengeContext context) + { + throw new NotImplementedException(); + } + + public Task HandleRequestAsync() + { + return Task.FromResult(false); + } + + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + _context = context; + return Task.FromResult(0); + } + + public Task SignInAsync(SignInContext context) + { + throw new NotImplementedException(); + } + + public Task SignOutAsync(SignOutContext context) + { + throw new NotImplementedException(); + } + } + + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Base64UrlTextEncoderTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/DataHandler/Base64UrlTextEncoderTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/Base64UrlTextEncoderTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs similarity index 67% rename from test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index e6f881fefc..55dd054269 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -14,20 +14,22 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.TestHost; +using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Xunit; namespace Microsoft.AspNetCore.Authentication.Cookies { - public class CookieMiddlewareTests + public class CookieTests { + private TestClock _clock = new TestClock(); + [Fact] public async Task NormalRequestPassesThrough() { - var server = CreateServer(new CookieAuthenticationOptions()); + var server = CreateServer(s => { }); var response = await server.CreateClient().GetAsync("http://example.com/normal"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } @@ -35,13 +37,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task AjaxLoginRedirectToReturnUrlTurnsInto200WithLocationHeader() { - var server = CreateServer(new CookieAuthenticationOptions - { - AutomaticChallenge = true, - LoginPath = "/login" - }); - - var transaction = await SendAsync(server, "http://example.com/protected?X-Requested-With=XMLHttpRequest"); + var server = CreateServer(o => o.LoginPath = "/login"); + var transaction = await SendAsync(server, "http://example.com/challenge?X-Requested-With=XMLHttpRequest"); Assert.Equal(HttpStatusCode.Unauthorized, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); Assert.Equal(1, responded.Count()); @@ -51,11 +48,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task AjaxForbidTurnsInto403WithLocationHeader() { - var server = CreateServer(new CookieAuthenticationOptions - { - AccessDeniedPath = "/denied" - }); - + var server = CreateServer(o => o.AccessDeniedPath = "/denied"); var transaction = await SendAsync(server, "http://example.com/forbid?X-Requested-With=XMLHttpRequest"); Assert.Equal(HttpStatusCode.Forbidden, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); @@ -66,11 +59,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task AjaxLogoutRedirectToReturnUrlTurnsInto200WithLocationHeader() { - var server = CreateServer(new CookieAuthenticationOptions - { - LogoutPath = "/signout" - }); - + var server = CreateServer(o => o.LogoutPath = "/signout"); var transaction = await SendAsync(server, "http://example.com/signout?X-Requested-With=XMLHttpRequest&ReturnUrl=/"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); @@ -81,8 +70,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task AjaxChallengeRedirectTurnsInto200WithLocationHeader() { - var server = CreateServer(new CookieAuthenticationOptions()); - + var server = CreateServer(s => { }); var transaction = await SendAsync(server, "http://example.com/challenge?X-Requested-With=XMLHttpRequest&ReturnUrl=/"); Assert.Equal(HttpStatusCode.Unauthorized, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); @@ -90,35 +78,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.True(responded.Single().StartsWith("http://example.com/Account/Login")); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task ProtectedRequestShouldRedirectToLoginOnlyWhenAutomatic(bool auto) - { - var server = CreateServer(new CookieAuthenticationOptions - { - LoginPath = new PathString("/login"), - AutomaticChallenge = auto - }); - - var transaction = await SendAsync(server, "http://example.com/protected"); - - Assert.Equal(auto ? HttpStatusCode.Redirect : HttpStatusCode.Unauthorized, transaction.Response.StatusCode); - if (auto) - { - var location = transaction.Response.Headers.Location; - Assert.Equal("/login", location.LocalPath); - Assert.Equal("?ReturnUrl=%2Fprotected", location.Query); - } - } - [Fact] public async Task ProtectedCustomRequestShouldRedirectToCustomRedirectUri() { - var server = CreateServer(new CookieAuthenticationOptions - { - AutomaticChallenge = true - }); + var server = CreateServer(s => { }); var transaction = await SendAsync(server, "http://example.com/protected/CustomRedirect"); @@ -129,31 +92,31 @@ namespace Microsoft.AspNetCore.Authentication.Cookies private Task SignInAsAlice(HttpContext context) { - return context.Authentication.SignInAsync("Cookies", + return context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), new AuthenticationProperties()); } private Task SignInAsWrong(HttpContext context) { - return context.Authentication.SignInAsync("Oops", + return context.SignInAsync("Oops", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), new AuthenticationProperties()); } private Task SignOutAsWrong(HttpContext context) { - return context.Authentication.SignOutAsync("Oops"); + return context.SignOutAsync("Oops"); } [Fact] public async Task SignInCausesDefaultCookieToBeCreated() { - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServerWithServices(s => s.AddCookieAuthentication(o => { - LoginPath = new PathString("/login"), - CookieName = "TestCookie" - }, SignInAsAlice); + o.LoginPath = new PathString("/login"); + o.CookieName = "TestCookie"; + }), SignInAsAlice); var transaction = await SendAsync(server, "http://example.com/testpath"); @@ -169,10 +132,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task SignInWrongAuthTypeThrows() { - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - LoginPath = new PathString("/login"), - CookieName = "TestCookie" + o.LoginPath = new PathString("/login"); + o.CookieName = "TestCookie"; }, SignInAsWrong); await Assert.ThrowsAsync(async () => await SendAsync(server, "http://example.com/testpath")); @@ -181,10 +144,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task SignOutWrongAuthTypeThrows() { - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - LoginPath = new PathString("/login"), - CookieName = "TestCookie" + o.LoginPath = new PathString("/login"); + o.CookieName = "TestCookie"; }, SignOutAsWrong); await Assert.ThrowsAsync(async () => await SendAsync(server, "http://example.com/testpath")); @@ -202,11 +165,11 @@ namespace Microsoft.AspNetCore.Authentication.Cookies string requestUri, bool shouldBeSecureOnly) { - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - LoginPath = new PathString("/login"), - CookieName = "TestCookie", - CookieSecure = cookieSecurePolicy + o.LoginPath = new PathString("/login"); + o.CookieName = "TestCookie"; + o.CookieSecure = cookieSecurePolicy; }, SignInAsAlice); var transaction = await SendAsync(server, requestUri); @@ -225,14 +188,14 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieOptionsAlterSetCookieHeader() { - TestServer server1 = CreateServer(new CookieAuthenticationOptions + var server1 = CreateServer(o => { - CookieName = "TestCookie", - CookiePath = "/foo", - CookieDomain = "another.com", - CookieSecure = CookieSecurePolicy.Always, - CookieHttpOnly = true - }, SignInAsAlice, new Uri("http://example.com/base")); + o.CookieName = "TestCookie"; + o.CookiePath = "/foo"; + o.CookieDomain = "another.com"; + o.CookieSecure = CookieSecurePolicy.Always; + o.CookieHttpOnly = true; + }, SignInAsAlice, baseAddress: new Uri("http://example.com/base")); var transaction1 = await SendAsync(server1, "http://example.com/base/testpath"); @@ -244,12 +207,12 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Contains(" secure", setCookie1); Assert.Contains(" httponly", setCookie1); - var server2 = CreateServer(new CookieAuthenticationOptions + var server2 = CreateServer(o => { - CookieName = "SecondCookie", - CookieSecure = CookieSecurePolicy.None, - CookieHttpOnly = false - }, SignInAsAlice, new Uri("http://example.com/base")); + o.CookieName = "SecondCookie"; + o.CookieSecure = CookieSecurePolicy.None; + o.CookieHttpOnly = false; + }, SignInAsAlice, baseAddress: new Uri("http://example.com/base")); var transaction2 = await SendAsync(server2, "http://example.com/base/testpath"); @@ -265,11 +228,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieContainsIdentity() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions - { - SystemClock = clock - }, SignInAsAlice); + var server = CreateServer(o => { }, SignInAsAlice); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -281,30 +240,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieAppliesClaimsTransform() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions - { - SystemClock = clock - }, + var server = CreateServer(o => { }, SignInAsAlice, baseAddress: null, - claimsTransform: new ClaimsTransformationOptions - { - Transformer = new ClaimsTransformer - { - OnTransform = context => - { - if (!context.Principal.Identities.Any(i => i.AuthenticationType == "xform")) - { - // REVIEW: Xform runs twice, once on Authenticate, and then once from the middleware - var id = new ClaimsIdentity("xform"); - id.AddClaim(new Claim("xform", "yup")); - context.Principal.AddIdentity(id); - } - return Task.FromResult(context.Principal); - } - } - }); + claimsTransform: true); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -318,23 +257,21 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieStopsWorkingAfterExpiration() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - ExpireTimeSpan = TimeSpan.FromMinutes(10), - SlidingExpiration = false + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = false; }, SignInAsAlice); var transaction1 = await SendAsync(server, "http://example.com/testpath"); var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); - clock.Add(TimeSpan.FromMinutes(7)); + _clock.Add(TimeSpan.FromMinutes(7)); var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); - clock.Add(TimeSpan.FromMinutes(7)); + _clock.Add(TimeSpan.FromMinutes(7)); var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); @@ -349,27 +286,25 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieExpirationCanBeOverridenInSignin() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - ExpireTimeSpan = TimeSpan.FromMinutes(10), - SlidingExpiration = false + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = false; }, context => - context.Authentication.SignInAsync("Cookies", + context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), - new AuthenticationProperties() { ExpiresUtc = clock.UtcNow.Add(TimeSpan.FromMinutes(5)) })); + new AuthenticationProperties() { ExpiresUtc = _clock.UtcNow.Add(TimeSpan.FromMinutes(5)) })); var transaction1 = await SendAsync(server, "http://example.com/testpath"); var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); - clock.Add(TimeSpan.FromMinutes(3)); + _clock.Add(TimeSpan.FromMinutes(3)); var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); - clock.Add(TimeSpan.FromMinutes(3)); + _clock.Add(TimeSpan.FromMinutes(3)); var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); @@ -384,27 +319,25 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task ExpiredCookieWithValidatorStillExpired() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - ExpireTimeSpan = TimeSpan.FromMinutes(10), - Events = new CookieAuthenticationEvents + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { ctx.ShouldRenew = true; return Task.FromResult(0); } - } + }; }, context => - context.Authentication.SignInAsync("Cookies", + context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); var transaction1 = await SendAsync(server, "http://example.com/testpath"); - clock.Add(TimeSpan.FromMinutes(11)); + _clock.Add(TimeSpan.FromMinutes(11)); var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); Assert.Null(transaction2.SetCookie); @@ -414,24 +347,22 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieCanBeRejectedAndSignedOutByValidator() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - ExpireTimeSpan = TimeSpan.FromMinutes(10), - SlidingExpiration = false, - Events = new CookieAuthenticationEvents + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = false; + o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { ctx.RejectPrincipal(); - ctx.HttpContext.Authentication.SignOutAsync("Cookies"); + ctx.HttpContext.SignOutAsync("Cookies"); return Task.FromResult(0); } - } + }; }, context => - context.Authentication.SignInAsync("Cookies", + context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -442,25 +373,59 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } [Fact] - public async Task CookieCanBeRenewedByValidator() + public async Task CookieNotRenewedAfterSignOut() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - ExpireTimeSpan = TimeSpan.FromMinutes(10), - SlidingExpiration = false, - Events = new CookieAuthenticationEvents + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = false; + o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { ctx.ShouldRenew = true; return Task.FromResult(0); } - } + }; }, context => - context.Authentication.SignInAsync("Cookies", + context.SignInAsync("Cookies", + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + // renews on every request + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction2.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + + var transaction3 = await server.SendAsync("http://example.com/normal", transaction1.CookieNameValue); + Assert.NotNull(transaction3.SetCookie[0]); + + // signout wins over renew + var transaction4 = await server.SendAsync("http://example.com/signout", transaction3.SetCookie[0]); + Assert.Equal(1, transaction4.SetCookie.Count()); + Assert.Contains(".AspNetCore.Cookies=; expires=", transaction4.SetCookie[0]); + } + + [Fact] + public async Task CookieCanBeRenewedByValidator() + { + var server = CreateServer(o => + { + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = false; + o.Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = ctx => + { + ctx.ShouldRenew = true; + return Task.FromResult(0); + } + }; + }, + context => + context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -469,19 +434,19 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.NotNull(transaction2.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(5)); + _clock.Add(TimeSpan.FromMinutes(5)); var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); Assert.NotNull(transaction3.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(6)); + _clock.Add(TimeSpan.FromMinutes(6)); var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); Assert.Null(transaction4.SetCookie); Assert.Null(FindClaimValue(transaction4, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(5)); + _clock.Add(TimeSpan.FromMinutes(5)); var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); Assert.Null(transaction5.SetCookie); @@ -491,22 +456,20 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - ExpireTimeSpan = TimeSpan.FromMinutes(10), - Events = new CookieAuthenticationEvents + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { ctx.ShouldRenew = true; return Task.FromResult(0); } - } + }; }, context => - context.Authentication.SignInAsync("Cookies", + context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -515,19 +478,19 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.NotNull(transaction2.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(5)); + _clock.Add(TimeSpan.FromMinutes(5)); var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); Assert.NotNull(transaction3.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(6)); + _clock.Add(TimeSpan.FromMinutes(6)); var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction3.CookieNameValue); Assert.NotNull(transaction4.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(11)); + _clock.Add(TimeSpan.FromMinutes(11)); var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction4.CookieNameValue); Assert.Null(transaction5.SetCookie); @@ -537,23 +500,21 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieValidatorOnlyCalledOnce() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - ExpireTimeSpan = TimeSpan.FromMinutes(10), - SlidingExpiration = false, - Events = new CookieAuthenticationEvents + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = false; + o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { ctx.ShouldRenew = true; return Task.FromResult(0); } - } + }; }, context => - context.Authentication.SignInAsync("Cookies", + context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -562,19 +523,19 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.NotNull(transaction2.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(5)); + _clock.Add(TimeSpan.FromMinutes(5)); var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); Assert.NotNull(transaction3.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(6)); + _clock.Add(TimeSpan.FromMinutes(6)); var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); Assert.Null(transaction4.SetCookie); Assert.Null(FindClaimValue(transaction4, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(5)); + _clock.Add(TimeSpan.FromMinutes(5)); var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); Assert.Null(transaction5.SetCookie); @@ -586,15 +547,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [InlineData(false)] public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) { - var clock = new TestClock(); DateTimeOffset? lastValidateIssuedDate = null; DateTimeOffset? lastExpiresDate = null; - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - ExpireTimeSpan = TimeSpan.FromMinutes(10), - SlidingExpiration = sliding, - Events = new CookieAuthenticationEvents + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = sliding; + o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => { @@ -603,10 +562,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies ctx.ShouldRenew = true; return Task.FromResult(0); } - } + }; }, context => - context.Authentication.SignInAsync("Cookies", + context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -621,13 +580,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var firstIssueDate = lastValidateIssuedDate; var firstExpiresDate = lastExpiresDate; - clock.Add(TimeSpan.FromMinutes(1)); + _clock.Add(TimeSpan.FromMinutes(1)); var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); Assert.NotNull(transaction3.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(2)); + _clock.Add(TimeSpan.FromMinutes(2)); var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction3.CookieNameValue); Assert.NotNull(transaction4.SetCookie); @@ -640,21 +599,20 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieExpirationCanBeOverridenInEvent() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - ExpireTimeSpan = TimeSpan.FromMinutes(10), - SlidingExpiration = false, - Events = new CookieAuthenticationEvents() + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = false; + o.Events = new CookieAuthenticationEvents() { OnSigningIn = context => { - context.Properties.ExpiresUtc = clock.UtcNow.Add(TimeSpan.FromMinutes(5)); + context.Properties.ExpiresUtc = _clock.UtcNow.Add(TimeSpan.FromMinutes(5)); return Task.FromResult(0); } - } - }, SignInAsAlice); + }; + }, + SignInAsAlice); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -662,13 +620,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Null(transaction2.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(3)); + _clock.Add(TimeSpan.FromMinutes(3)); var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); Assert.Null(transaction3.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(3)); + _clock.Add(TimeSpan.FromMinutes(3)); var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); Assert.Null(transaction4.SetCookie); @@ -678,13 +636,12 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieIsRenewedWithSlidingExpiration() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - ExpireTimeSpan = TimeSpan.FromMinutes(10), - SlidingExpiration = true - }, SignInAsAlice); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = true; + }, + SignInAsAlice); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -692,20 +649,20 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Null(transaction2.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(4)); + _clock.Add(TimeSpan.FromMinutes(4)); var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); Assert.Null(transaction3.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(4)); + _clock.Add(TimeSpan.FromMinutes(4)); // transaction4 should arrive with a new SetCookie value var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); Assert.NotNull(transaction4.SetCookie); Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); - clock.Add(TimeSpan.FromMinutes(4)); + _clock.Add(TimeSpan.FromMinutes(4)); var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction4.CookieNameValue); Assert.Null(transaction5.SetCookie); @@ -715,12 +672,11 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieUsesPathBaseByDefault() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions(), + var server = CreateServer(o => { }, context => { Assert.Equal(new PathString("/base"), context.Request.PathBase); - return context.Authentication.SignInAsync("Cookies", + return context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))); }, new Uri("http://example.com/base")); @@ -729,18 +685,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.True(transaction1.SetCookie.Contains("path=/base")); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task CookieTurnsChallengeIntoForbidWithCookie(bool automatic) + [Fact] + public async Task CookieTurnsChallengeIntoForbidWithCookie() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions - { - AutomaticAuthenticate = automatic, - SystemClock = clock - }, - SignInAsAlice); + var server = CreateServer(o => { }, SignInAsAlice); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -753,18 +701,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal("?ReturnUrl=%2Fchallenge", location.Query); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task CookieChallengeRedirectsToLoginWithoutCookie(bool automatic) + [Fact] + public async Task CookieChallengeRedirectsToLoginWithoutCookie() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions - { - AutomaticAuthenticate = automatic, - SystemClock = clock - }, - SignInAsAlice); + var server = CreateServer(o => { }, SignInAsAlice); var url = "http://example.com/challenge"; var transaction = await SendAsync(server, url); @@ -774,18 +714,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal("/Account/Login", location.LocalPath); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task CookieForbidRedirectsWithoutCookie(bool automatic) + [Fact] + public async Task CookieForbidRedirectsWithoutCookie() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions - { - AutomaticAuthenticate = automatic, - SystemClock = clock - }, - SignInAsAlice); + var server = CreateServer(o => { }, SignInAsAlice); var url = "http://example.com/forbid"; var transaction = await SendAsync(server, url); @@ -798,11 +730,9 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieTurns401ToAccessDeniedWhenSetWithCookie() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - AccessDeniedPath = new PathString("/accessdenied") + o.AccessDeniedPath = new PathString("/accessdenied"); }, SignInAsAlice); @@ -819,11 +749,9 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieChallengeRedirectsWithLoginPath() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - LoginPath = new PathString("/page") + o.LoginPath = new PathString("/page"); }); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -836,11 +764,9 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task CookieChallengeWithUnauthorizedRedirectsToLoginIfNotAuthenticated() { - var clock = new TestClock(); - var server = CreateServer(new CookieAuthenticationOptions + var server = CreateServer(o => { - SystemClock = clock, - LoginPath = new PathString("/page") + o.LoginPath = new PathString("/page"); }); var transaction1 = await SendAsync(server, "http://example.com/testpath"); @@ -850,19 +776,20 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal(HttpStatusCode.Redirect, transaction2.Response.StatusCode); } - [Fact] - public async Task MapWillNotAffectChallenge() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task MapWillAffectChallengeOnlyWithUseAuth(bool useAuth) { var builder = new WebHostBuilder() - .Configure(app => - { - app.UseCookieAuthentication(new CookieAuthenticationOptions + .Configure(app => { + if (useAuth) { - LoginPath = new PathString("/page") - }); - app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); + app.UseAuthentication(); + } + app.Map("/login", signoutApp => signoutApp.Run(context => context.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(s => s.AddCookieAuthentication(o => o.LoginPath = new PathString("/page"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/login"); @@ -870,23 +797,30 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location; - Assert.Equal("/page", location.LocalPath); + if (useAuth) + { + Assert.Equal("/page", location.LocalPath); + } + else + { + Assert.Equal("/login/page", location.LocalPath); + } Assert.Equal("?ReturnUrl=%2F", location.Query); } - [Fact] + [ConditionalFact(Skip = "Revisit, exception no longer thrown")] public async Task ChallengeDoesNotSet401OnUnauthorized() { var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(); + app.UseAuthentication(); app.Run(async context => { - await Assert.ThrowsAsync(() => context.Authentication.ChallengeAsync()); + await Assert.ThrowsAsync(() => context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme)); }); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication()); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com"); @@ -894,25 +828,49 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } [Fact] - public async Task UseCookieWithInstanceDoesntUseSharedOptions() + public async Task CanConfigureDefaultCookieInstance() { var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - CookieName = "One" - }); - app.UseCookieAuthentication(); - app.Run(context => context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity()))); + app.UseAuthentication(); + app.Run(context => context.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity()))); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => + { + services.AddCookieAuthentication(); + services.Configure(CookieAuthenticationDefaults.AuthenticationScheme, + o => o.CookieName = "One"); + }); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.True(transaction.SetCookie[0].StartsWith(".AspNetCore.Cookies=")); + Assert.True(transaction.SetCookie[0].StartsWith("One=")); + } + + [Fact] + public async Task CanConfigureNamedCookieInstance() + { + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Run(context => context.SignInAsync("Cookie1", new ClaimsPrincipal(new ClaimsIdentity()))); + }) + .ConfigureServices(services => + { + services.AddCookieAuthentication("Cookie1"); + services.Configure("Cookie1", + o => o.CookieName = "One"); + }); + var server = new TestServer(builder); + + var transaction = await server.SendAsync("http://example.com"); + + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + Assert.True(transaction.SetCookie[0].StartsWith("One=")); } [Fact] @@ -921,14 +879,11 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - LoginPath = new PathString("/login") - }); - app.Map("/notlogin", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies", + app.UseAuthentication(); + app.Map("/notlogin", signoutApp => signoutApp.Run(context => context.SignInAsync("Cookies", new ClaimsPrincipal()))); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.LoginPath = new PathString("/login"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/notlogin?ReturnUrl=%2Fpage"); @@ -942,14 +897,11 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - LoginPath = new PathString("/login") - }); - app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies", - new ClaimsPrincipal()))); + app.UseAuthentication(); + app.Map("/login", signoutApp => signoutApp.Run(context => context.SignInAsync("Cookies", new ClaimsPrincipal()))); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.LoginPath = new PathString("/login"))); + var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/login?ReturnUrl=%2Fpage"); @@ -967,13 +919,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - LogoutPath = new PathString("/logout") - }); - app.Map("/notlogout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies"))); + app.UseAuthentication(); + app.Map("/notlogout", signoutApp => signoutApp.Run(context => context.SignOutAsync("Cookies"))); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.LogoutPath = new PathString("/logout"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/notlogout?ReturnUrl=%2Fpage"); @@ -987,13 +936,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - LogoutPath = new PathString("/logout") - }); - app.Map("/logout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies"))); + app.UseAuthentication(); + app.Map("/logout", signoutApp => signoutApp.Run(context => context.SignOutAsync("Cookies"))); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.LogoutPath = new PathString("/logout"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/logout?ReturnUrl=%2Fpage"); @@ -1011,13 +957,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AccessDeniedPath = new PathString("/denied") - }); - app.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies"))); + app.UseAuthentication(); + app.Map("/forbid", signoutApp => signoutApp.Run(context => context.ForbidAsync("Cookies"))); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.AccessDeniedPath = new PathString("/denied"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/forbid"); @@ -1034,13 +977,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies .Configure(app => app.Map("/base", map => { - map.UseCookieAuthentication(new CookieAuthenticationOptions - { - LoginPath = new PathString("/page") - }); - map.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); + map.UseAuthentication(); + map.Map("/login", signoutApp => signoutApp.Run(context => context.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); })) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.LoginPath = new PathString("/page"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/base/login"); @@ -1056,19 +996,17 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [InlineData("http://example.com/redirect_to")] public async Task RedirectUriIsHoneredAfterSignin(string redirectUrl) { - var options = new CookieAuthenticationOptions + var server = CreateServer(o => { - LoginPath = "/testpath", - CookieName = "TestCookie" - }; - - var server = CreateServer(options, async context => - { - await context.Authentication.SignInAsync( + o.LoginPath = "/testpath"; + o.CookieName = "TestCookie"; + }, + async context => + await context.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme))), - new AuthenticationProperties { RedirectUri = redirectUrl }); - }); + new AuthenticationProperties { RedirectUri = redirectUrl }) + ); var transaction = await SendAsync(server, "http://example.com/testpath"); Assert.NotEmpty(transaction.SetCookie); @@ -1079,16 +1017,15 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task RedirectUriInQueryIsHoneredAfterSignin() { - var options = new CookieAuthenticationOptions + var server = CreateServer(o => { - LoginPath = "/testpath", - ReturnUrlParameter = "return", - CookieName = "TestCookie" - }; - - var server = CreateServer(options, async context => + o.LoginPath = "/testpath"; + o.ReturnUrlParameter = "return"; + o.CookieName = "TestCookie"; + }, + async context => { - await context.Authentication.SignInAsync( + await context.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme)))); }); @@ -1102,16 +1039,15 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task AbsoluteRedirectUriInQueryStringIsRejected() { - var options = new CookieAuthenticationOptions + var server = CreateServer(o => { - LoginPath = "/testpath", - ReturnUrlParameter = "return", - CookieName = "TestCookie" - }; - - var server = CreateServer(options, async context => + o.LoginPath = "/testpath"; + o.ReturnUrlParameter = "return"; + o.CookieName = "TestCookie"; + }, + async context => { - await context.Authentication.SignInAsync( + await context.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme)))); }); @@ -1124,16 +1060,15 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task EnsurePrecedenceOfRedirectUriAfterSignin() { - var options = new CookieAuthenticationOptions + var server = CreateServer(o => { - LoginPath = "/testpath", - ReturnUrlParameter = "return", - CookieName = "TestCookie" - }; - - var server = CreateServer(options, async context => + o.LoginPath = "/testpath"; + o.ReturnUrlParameter = "return"; + o.CookieName = "TestCookie"; + }, + async context => { - await context.Authentication.SignInAsync( + await context.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", CookieAuthenticationDefaults.AuthenticationScheme))), new AuthenticationProperties { RedirectUri = "/redirect_test" }); @@ -1152,13 +1087,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies .Configure(app => app.Map("/base", map => { - map.UseCookieAuthentication(new CookieAuthenticationOptions - { - AccessDeniedPath = new PathString("/denied") - }); - map.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies"))); + map.UseAuthentication(); + map.Map("/forbid", signoutApp => signoutApp.Run(context => context.ForbidAsync("Cookies"))); })) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.AccessDeniedPath = new PathString("/denied"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/base/forbid"); @@ -1176,17 +1108,17 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var builder1 = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - TicketDataFormat = new TicketDataFormat(dp), - CookieName = "Cookie" - }); + app.UseAuthentication(); app.Use((context, next) => - context.Authentication.SignInAsync("Cookies", + context.SignInAsync("Cookies", new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), new AuthenticationProperties())); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => + { + o.TicketDataFormat = new TicketDataFormat(dp); + o.CookieName = "Cookie"; + })); var server1 = new TestServer(builder1); var transaction = await SendAsync(server1, "http://example.com/stuff"); @@ -1195,20 +1127,18 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var builder2 = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AuthenticationScheme = "Cookies", - CookieName = "Cookie", - TicketDataFormat = new TicketDataFormat(dp) - }); + app.UseAuthentication(); app.Use(async (context, next) => { - var authContext = new AuthenticateContext("Cookies"); - await context.Authentication.AuthenticateAsync(authContext); - Describe(context.Response, authContext); + var result = await context.AuthenticateAsync("Cookies"); + Describe(context.Response, result); }); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication("Cookies", o => + { + o.CookieName = "Cookie"; + o.TicketDataFormat = new TicketDataFormat(dp); + })); var server2 = new TestServer(builder2); var transaction2 = await SendAsync(server2, "http://example.com/stuff", transaction.CookieNameValue); Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); @@ -1219,27 +1149,27 @@ namespace Microsoft.AspNetCore.Authentication.Cookies public async Task NullExpiresUtcPropertyIsGuarded() { var builder = new WebHostBuilder() - .ConfigureServices(services => services.AddAuthentication()) + .ConfigureServices(services => services.AddCookieAuthentication(o => + { + o.Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = context => + { + context.Properties.ExpiresUtc = null; + context.ShouldRenew = true; + return Task.FromResult(0); + } + }; + })) .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - Events = new CookieAuthenticationEvents - { - OnValidatePrincipal = context => - { - context.Properties.ExpiresUtc = null; - context.ShouldRenew = true; - return Task.FromResult(0); - } - } - }); + app.UseAuthentication(); app.Run(async context => { if (context.Request.Path == "/signin") { - await context.Authentication.SignInAsync( + await context.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")))); } @@ -1298,18 +1228,34 @@ namespace Microsoft.AspNetCore.Authentication.Cookies return me; } - private static TestServer CreateServer(CookieAuthenticationOptions options, Func testpath = null, Uri baseAddress = null, ClaimsTransformationOptions claimsTransform = null) + private class ClaimsTransformer : IClaimsTransformation + { + public Task TransformAsync(ClaimsPrincipal p) + { + if (!p.Identities.Any(i => i.AuthenticationType == "xform")) + { + var id = new ClaimsIdentity("xform"); + id.AddClaim(new Claim("xform", "yup")); + p.AddIdentity(id); + } + return Task.FromResult(p); + } + } + + private TestServer CreateServer(Action configureOptions, Func testpath = null, Uri baseAddress = null, bool claimsTransform = false) + => CreateServerWithServices(s => + { + s.AddSingleton(_clock); + s.AddCookieAuthentication(configureOptions); + s.AddSingleton(); + }, testpath, baseAddress); + + private static TestServer CreateServerWithServices(Action configureServices, Func testpath = null, Uri baseAddress = null) { var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(options); - // app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "Cookie2" }); - - if (claimsTransform != null) - { - app.UseClaimsTransformation(claimsTransform); - } + app.UseAuthentication(); app.Use(async (context, next) => { var req = context.Request; @@ -1319,41 +1265,34 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { res.StatusCode = 200; } - else if (req.Path == new PathString("/protected")) - { - res.StatusCode = 401; - } else if (req.Path == new PathString("/forbid")) // Simulate forbidden { - await context.Authentication.ForbidAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.ForbidAsync(CookieAuthenticationDefaults.AuthenticationScheme); } else if (req.Path == new PathString("/challenge")) { - await context.Authentication.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme); } else if (req.Path == new PathString("/signout")) { - await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); } else if (req.Path == new PathString("/unauthorized")) { - await context.Authentication.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme, new AuthenticationProperties(), ChallengeBehavior.Unauthorized); + await context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme, new AuthenticationProperties(), ChallengeBehavior.Unauthorized); } else if (req.Path == new PathString("/protected/CustomRedirect")) { - await context.Authentication.ChallengeAsync(new AuthenticationProperties() { RedirectUri = "/CustomRedirect" }); + await context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme, new AuthenticationProperties() { RedirectUri = "/CustomRedirect" }); } else if (req.Path == new PathString("/me")) { - var authContext = new AuthenticateContext(CookieAuthenticationDefaults.AuthenticationScheme); - authContext.Authenticated(context.User, properties: null, description: null); - Describe(res, authContext); + Describe(res, AuthenticateResult.Success(new AuthenticationTicket(context.User, new AuthenticationProperties(), CookieAuthenticationDefaults.AuthenticationScheme))); } else if (req.Path.StartsWithSegments(new PathString("/me"), out remainder)) { - var authContext = new AuthenticateContext(remainder.Value.Substring(1)); - await context.Authentication.AuthenticateAsync(authContext); - Describe(res, authContext); + var ticket = await context.AuthenticateAsync(remainder.Value.Substring(1)); + Describe(res, ticket); } else if (req.Path == new PathString("/testpath") && testpath != null) { @@ -1365,24 +1304,24 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } }); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(configureServices); var server = new TestServer(builder); server.BaseAddress = baseAddress; return server; } - private static void Describe(HttpResponse res, AuthenticateContext result) + private static void Describe(HttpResponse res, AuthenticateResult result) { res.StatusCode = 200; res.ContentType = "text/xml"; var xml = new XElement("xml"); - if (result != null && result.Principal != null) + if (result != null && result?.Ticket?.Principal != null) { - xml.Add(result.Principal.Claims.Select(claim => new XElement("claim", new XAttribute("type", claim.Type), new XAttribute("value", claim.Value)))); + xml.Add(result.Ticket.Principal.Claims.Select(claim => new XElement("claim", new XAttribute("type", claim.Type), new XAttribute("value", claim.Value)))); } - if (result != null && result.Properties != null) + if (result != null && result?.Ticket?.Properties != null) { - xml.Add(result.Properties.Select(extra => new XElement("extra", new XAttribute("type", extra.Key), new XAttribute("value", extra.Value)))); + xml.Add(result.Ticket.Properties.Items.Select(extra => new XElement("extra", new XAttribute("type", extra.Key), new XAttribute("value", extra.Value)))); } var xmlBytes = Encoding.UTF8.GetBytes(xml.ToString()); res.Body.Write(xmlBytes, 0, xmlBytes.Length); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs new file mode 100644 index 0000000000..a152c735bb --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs @@ -0,0 +1,134 @@ +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. + +using System; +using System.Net; +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication +{ + public class DynamicSchemeTests + { + [Fact] + public async Task CanAddAndRemoveSchemes() + { + var server = CreateServer(); + await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/One")); + + // Add One scheme + var response = await server.CreateClient().GetAsync("http://example.com/add/One"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + var transaction = await server.SendAsync("http://example.com/auth/One"); + Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); + + // Add Two scheme + response = await server.CreateClient().GetAsync("http://example.com/add/Two"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + transaction = await server.SendAsync("http://example.com/auth/Two"); + Assert.Equal("Two", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "Two")); + + // Remove Two + response = await server.CreateClient().GetAsync("http://example.com/remove/Two"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/Two")); + transaction = await server.SendAsync("http://example.com/auth/One"); + Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); + + // Remove One + response = await server.CreateClient().GetAsync("http://example.com/remove/One"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/Two")); + await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/One")); + + } + + [Fact] + public async Task VerifyDefaultBehavior() + { + var server = CreateServer(); + + await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth")); + + var response = await server.CreateClient().GetAsync("http://example.com/add/One"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + var transaction = await server.SendAsync("http://example.com/auth"); + Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); + response = await server.CreateClient().GetAsync("http://example.com/add/Two"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + + // Default will blow up since now there's two + await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth")); + } + + private class TestHandler : AuthenticationHandler + { + public TestHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { + } + + protected override Task HandleAuthenticateAsync() + { + var principal = new ClaimsPrincipal(); + var id = new ClaimsIdentity(); + id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + principal.AddIdentity(id); + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); + } + } + + private static TestServer CreateServer(Action configureAuth = null) + { + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Use(async (context, next) => + { + var req = context.Request; + var res = context.Response; + if (req.Path.StartsWithSegments(new PathString("/add"), out var remainder)) + { + var name = remainder.Value.Substring(1); + var auth = context.RequestServices.GetRequiredService(); + var scheme = new AuthenticationScheme(name, typeof(TestHandler)); + auth.AddScheme(scheme); + } + else if (req.Path.StartsWithSegments(new PathString("/auth"), out remainder)) + { + var name = (remainder.Value.Length > 0) ? remainder.Value.Substring(1) : null; + var result = await context.AuthenticateAsync(name); + res.Describe(result?.Ticket?.Principal); + } + else if (req.Path.StartsWithSegments(new PathString("/remove"), out remainder)) + { + var name = remainder.Value.Substring(1); + var auth = context.RequestServices.GetRequiredService(); + auth.RemoveScheme(name); + } + else + { + await next(); + } + }); + }) + .ConfigureServices(services => + { + if (configureAuth == null) + { + configureAuth = o => { }; + } + services.AddAuthentication(configureAuth); + }); + return new TestServer(builder); + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs similarity index 53% rename from test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 4d6cabaf1b..79066e48b5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; @@ -14,53 +15,145 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using Newtonsoft.Json; using Xunit; namespace Microsoft.AspNetCore.Authentication.Facebook { - public class FacebookMiddlewareTests + public class FacebookTests { + [Fact] + public void AddCanBindAgainstDefaultConfig() + { + var dic = new Dictionary + { + {"Facebook:AppId", ""}, + {"Facebook:AppSecret", ""}, + {"Facebook:AuthorizationEndpoint", ""}, + {"Facebook:BackchannelTimeout", "0.0:0:30"}, + //{"Facebook:CallbackPath", "/callbackpath"}, // PathString doesn't convert + {"Facebook:ClaimsIssuer", ""}, + {"Facebook:DisplayName", ""}, + {"Facebook:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Facebook:SaveTokens", "true"}, + {"Facebook:SendAppSecretProof", "true"}, + {"Facebook:SignInScheme", ""}, + {"Facebook:TokenEndpoint", ""}, + {"Facebook:UserInformationEndpoint", ""}, + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddFacebookAuthentication().AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(FacebookDefaults.AuthenticationScheme); + Assert.Equal("", options.AppId); + Assert.Equal("", options.AppSecret); + Assert.Equal("", options.AuthorizationEndpoint); + Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); + //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert + Assert.Equal("", options.ClaimsIssuer); + Assert.Equal("", options.ClientId); + Assert.Equal("", options.ClientSecret); + Assert.Equal("", options.DisplayName); + Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); + Assert.True(options.SaveTokens); + Assert.True(options.SendAppSecretProof); + Assert.Equal("", options.SignInScheme); + Assert.Equal("", options.TokenEndpoint); + Assert.Equal("", options.UserInformationEndpoint); + } + + [Fact] + public void AddWithDelegateIgnoresConfig() + { + var dic = new Dictionary + { + {"Facebook:AppId", ""}, + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddFacebookAuthentication(o => o.SaveTokens = false).AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(FacebookDefaults.AuthenticationScheme); + Assert.Null(options.AppId); + Assert.False(options.SaveTokens); + } + + [Fact] + public async Task ThrowsIfAppIdMissing() + { + var server = CreateServer( + app => { }, + services => services.AddFacebookAuthentication(o => o.SignInScheme = "Whatever"), + context => + { + // REVIEW: Gross. + Assert.Throws("AppId", () => context.ChallengeAsync("Facebook").GetAwaiter().GetResult()); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + [Fact] + public async Task ThrowsIfAppSecretMissing() + { + var server = CreateServer( + app => { }, + services => services.AddFacebookAuthentication(o => o.AppId = "Whatever"), + context => + { + // REVIEW: Gross. + Assert.Throws("AppSecret", () => context.ChallengeAsync("Facebook").GetAwaiter().GetResult()); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + [Fact] public async Task ChallengeWillTriggerApplyRedirectEvent() { var server = CreateServer( app => { - app.UseFacebookAuthentication(new FacebookOptions + app.UseAuthentication(); + }, + services => + { + services.AddAuthentication(options => { - AppId = "Test App Id", - AppSecret = "Test App Secret", - Events = new OAuthEvents + options.DefaultSignInScheme = "External"; + options.DefaultAuthenticateScheme = "External"; + }); + services.AddCookieAuthentication("External", o => { }); + services.AddFacebookAuthentication(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.Events = new OAuthEvents { OnRedirectToAuthorizationEndpoint = context => { context.Response.Redirect(context.RedirectUri + "&custom=test"); return Task.FromResult(0); } - } - }); - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AuthenticationScheme = "External", - AutomaticAuthenticate = true - }); - }, - services => - { - services.AddAuthentication(options => - { - options.SignInScheme = "External"; + }; }); }, context => { // REVIEW: Gross. - context.Authentication.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -72,18 +165,23 @@ namespace Microsoft.AspNetCore.Authentication.Facebook [Fact] public async Task NestedMapWillNotAffectRedirect() { - var server = CreateServer(app => - app.Map("/base", map => { - map.UseFacebookAuthentication(new FacebookOptions - { - AppId = "Test App Id", - AppSecret = "Test App Secret", - SignInScheme = "External" - }); - map.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Facebook", new AuthenticationProperties() { RedirectUri = "/" }))); - }), - services => services.AddAuthentication(), - handler: null); + var server = CreateServer(app => app.Map("/base", map => + { + map.UseAuthentication(); + map.Map("/login", signoutApp => signoutApp.Run(context => context.ChallengeAsync("Facebook", new AuthenticationProperties() { RedirectUri = "/" }))); + }), + services => + { + services.AddCookieAuthentication("External", o => { }); + services.AddFacebookAuthentication(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.SignInScheme = "External"; + }); + }, + handler: null); + var transaction = await server.SendAsync("http://example.com/base/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; @@ -101,15 +199,19 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var server = CreateServer( app => { - app.UseFacebookAuthentication(new FacebookOptions - { - AppId = "Test App Id", - AppSecret = "Test App Secret", - SignInScheme = "External" - }); - app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Facebook", new AuthenticationProperties() { RedirectUri = "/" }))); + app.UseAuthentication(); + app.Map("/login", signoutApp => signoutApp.Run(context => context.ChallengeAsync("Facebook", new AuthenticationProperties() { RedirectUri = "/" }))); + }, + services => + { + services.AddCookieAuthentication("External", o => { }); + services.AddFacebookAuthentication(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.SignInScheme = "External"; + }); }, - services => services.AddAuthentication(), handler: null); var transaction = await server.SendAsync("http://example.com/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -126,26 +228,24 @@ namespace Microsoft.AspNetCore.Authentication.Facebook public async Task ChallengeWillTriggerRedirection() { var server = CreateServer( - app => - { - app.UseFacebookAuthentication(new FacebookOptions - { - AppId = "Test App Id", - AppSecret = "Test App Secret" - }); - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AuthenticationScheme = "External" - }); - }, + app => app.UseAuthentication(), services => { - services.AddAuthentication(options => options.SignInScheme = "External"); + services.AddAuthentication(options => + { + options.DefaultSignInScheme = "External"; + }); + services.AddCookieAuthentication(); + services.AddFacebookAuthentication(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + }); }, context => { // REVIEW: gross - context.Authentication.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -168,14 +268,23 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var server = CreateServer( app => { - app.UseCookieAuthentication(); - app.UseFacebookAuthentication(new FacebookOptions + app.UseAuthentication(); + }, + services => + { + services.AddAuthentication(options => { - AppId = "Test App Id", - AppSecret = "Test App Secret", - StateDataFormat = stateFormat, - UserInformationEndpoint = customUserInfoEndpoint, - BackchannelHttpHandler = new TestHttpMessageHandler + options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + services.AddCookieAuthentication(); + services.AddFacebookAuthentication(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.StateDataFormat = stateFormat; + o.UserInformationEndpoint = customUserInfoEndpoint; + o.BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -204,13 +313,10 @@ namespace Microsoft.AspNetCore.Authentication.Facebook } return null; } - } + }; }); }, - services => - { - services.AddAuthentication(options => options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); - }, handler: null); + handler: null); var properties = new AuthenticationProperties(); var correlationKey = ".xsrf"; @@ -233,10 +339,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var builder = new WebHostBuilder() .Configure(app => { - if (configure != null) - { - configure(app); - } + configure?.Invoke(app); app.Use(async (context, next) => { if (handler == null || !handler(context)) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs similarity index 79% rename from test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 090f9f1210..77ddcc7efc 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -14,25 +14,83 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using Newtonsoft.Json; using Xunit; namespace Microsoft.AspNetCore.Authentication.Google { - public class GoogleMiddlewareTests + public class GoogleTests { + [Fact] + public void AddCanBindAgainstDefaultConfig() + { + var dic = new Dictionary + { + {"Google:ClientId", ""}, + {"Google:ClientSecret", ""}, + {"Google:AuthorizationEndpoint", ""}, + {"Google:BackchannelTimeout", "0.0:0:30"}, + //{"Google:CallbackPath", "/callbackpath"}, // PathString doesn't convert + {"Google:ClaimsIssuer", ""}, + {"Google:DisplayName", ""}, + {"Google:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Google:SaveTokens", "true"}, + {"Google:SendAppSecretProof", "true"}, + {"Google:SignInScheme", ""}, + {"Google:TokenEndpoint", ""}, + {"Google:UserInformationEndpoint", ""}, + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddGoogleAuthentication().AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(GoogleDefaults.AuthenticationScheme); + Assert.Equal("", options.AuthorizationEndpoint); + Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); + //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert + Assert.Equal("", options.ClaimsIssuer); + Assert.Equal("", options.ClientId); + Assert.Equal("", options.ClientSecret); + Assert.Equal("", options.DisplayName); + Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); + Assert.True(options.SaveTokens); + Assert.Equal("", options.SignInScheme); + Assert.Equal("", options.TokenEndpoint); + Assert.Equal("", options.UserInformationEndpoint); + } + + [Fact] + public void AddWithDelegateIgnoresConfig() + { + var dic = new Dictionary + { + {"Google:ClientId", ""}, + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddGoogleAuthentication(o => o.SaveTokens = false).AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(GoogleDefaults.AuthenticationScheme); + Assert.Null(options.ClientId); + Assert.False(options.SaveTokens); + } + [Fact] public async Task ChallengeWillTriggerRedirection() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret" + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; }); var transaction = await server.SendAsync("https://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -53,10 +111,10 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task SignInThrows() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret" + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; }); var transaction = await server.SendAsync("https://example.com/signIn"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -65,10 +123,10 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task SignOutThrows() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret" + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; }); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); @@ -77,66 +135,46 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task ForbidThrows() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret" + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; }); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } [Fact] - public async Task Challenge401WillTriggerRedirection() + public async Task Challenge401WillNotTriggerRedirection() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - AutomaticChallenge = true + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; }); var transaction = await server.SendAsync("https://example.com/401"); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - var location = transaction.Response.Headers.Location.ToString(); - Assert.Contains("https://accounts.google.com/o/oauth2/auth?response_type=code", location); - Assert.Contains("&client_id=", location); - Assert.Contains("&redirect_uri=", location); - Assert.Contains("&scope=", location); - Assert.Contains("&state=", location); + Assert.Equal(HttpStatusCode.Unauthorized, transaction.Response.StatusCode); } [Fact] public async Task ChallengeWillSetCorrelationCookie() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret" + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; }); var transaction = await server.SendAsync("https://example.com/challenge"); Assert.Contains(transaction.SetCookie, cookie => cookie.StartsWith(".AspNetCore.Correlation.Google.")); } - [Fact] - public async Task Challenge401WillSetCorrelationCookie() - { - var server = CreateServer(new GoogleOptions - { - ClientId = "Test Id", - ClientSecret = "Test Secret", - AutomaticChallenge = true - }); - var transaction = await server.SendAsync("https://example.com/401"); - Assert.Contains(transaction.SetCookie, cookie => cookie.StartsWith(".AspNetCore.Correlation.Google.")); - } - [Fact] public async Task ChallengeWillSetDefaultScope() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret" + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; }); var transaction = await server.SendAsync("https://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -144,29 +182,14 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Contains("&scope=" + UrlEncoder.Default.Encode("openid profile email"), query); } - [Fact] - public async Task Challenge401WillSetDefaultScope() - { - var server = CreateServer(new GoogleOptions - { - ClientId = "Test Id", - ClientSecret = "Test Secret", - AutomaticChallenge = true - }); - var transaction = await server.SendAsync("https://example.com/401"); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - var query = transaction.Response.Headers.Location.Query; - Assert.Contains("&scope=" + UrlEncoder.Default.Encode("openid profile email"), query); - } - [Fact] public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - AutomaticChallenge = true + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + //AutomaticChallenge = true }, context => { @@ -174,7 +197,7 @@ namespace Microsoft.AspNetCore.Authentication.Google var res = context.Response; if (req.Path == new PathString("/challenge2")) { - return context.Authentication.ChallengeAsync("Google", new AuthenticationProperties( + return context.ChallengeAsync("Google", new AuthenticationProperties( new Dictionary() { { "scope", "https://www.googleapis.com/auth/plus.login" }, @@ -202,18 +225,18 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task ChallengeWillTriggerApplyRedirectEvent() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - Events = new OAuthEvents + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.Events = new OAuthEvents { OnRedirectToAuthorizationEndpoint = context => { context.Response.Redirect(context.RedirectUri + "&custom=test"); return Task.FromResult(0); } - } + }; }); var transaction = await server.SendAsync("https://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -224,10 +247,10 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task AuthenticateWithoutCookieWillFail() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret" + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; }, async context => { @@ -235,9 +258,8 @@ namespace Microsoft.AspNetCore.Authentication.Google var res = context.Response; if (req.Path == new PathString("/auth")) { - var auth = new AuthenticateContext("Google"); - await context.Authentication.AuthenticateAsync(auth); - Assert.NotNull(auth.Error); + var result = await context.AuthenticateAsync("Google"); + Assert.NotNull(result.Failure); } }); var transaction = await server.SendAsync("https://example.com/auth"); @@ -247,10 +269,10 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task ReplyPathWithoutStateQueryStringWillBeRejected() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret" + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; }); var error = await Assert.ThrowsAnyAsync(() => server.SendAsync("https://example.com/signin-google?code=TestCode")); Assert.Equal("The oauth state was missing or invalid.", error.GetBaseException().Message); @@ -261,11 +283,11 @@ namespace Microsoft.AspNetCore.Authentication.Google [InlineData(false)] public async Task ReplyPathWithErrorFails(bool redirect) { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - Events = redirect ? new OAuthEvents() + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.Events = redirect ? new OAuthEvents() { OnRemoteFailure = ctx => { @@ -273,7 +295,7 @@ namespace Microsoft.AspNetCore.Authentication.Google ctx.HandleResponse(); return Task.FromResult(0); } - } : new OAuthEvents() + } : new OAuthEvents(); }); var sendTask = server.SendAsync("https://example.com/signin-google?error=OMG&error_description=SoBad&error_uri=foobar"); if (redirect) @@ -295,14 +317,17 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string claimsIssuer) { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - SaveTokens = true, - StateDataFormat = stateFormat, - ClaimsIssuer = claimsIssuer, - BackchannelHttpHandler = new TestHttpMessageHandler + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.SaveTokens = true; + o.StateDataFormat = stateFormat; + if (claimsIssuer != null) + { + o.ClaimsIssuer = claimsIssuer; + } + o.BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -340,7 +365,7 @@ namespace Microsoft.AspNetCore.Authentication.Google throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - } + }; }); var properties = new AuthenticationProperties(); @@ -385,20 +410,20 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - StateDataFormat = stateFormat, - BackchannelHttpHandler = new TestHttpMessageHandler + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + o.BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { return ReturnJsonResponse(new { Error = "Error" }, HttpStatusCode.BadRequest); } - }, - Events = redirect ? new OAuthEvents() + }; + o.Events = redirect ? new OAuthEvents() { OnRemoteFailure = ctx => { @@ -406,7 +431,7 @@ namespace Microsoft.AspNetCore.Authentication.Google ctx.HandleResponse(); return Task.FromResult(0); } - } : new OAuthEvents() + } : new OAuthEvents(); }); var properties = new AuthenticationProperties(); var correlationKey = ".xsrf"; @@ -438,19 +463,19 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - StateDataFormat = stateFormat, - BackchannelHttpHandler = new TestHttpMessageHandler + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + o.BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { return ReturnJsonResponse(new object()); } - }, - Events = redirect ? new OAuthEvents() + }; + o.Events = redirect ? new OAuthEvents() { OnRemoteFailure = ctx => { @@ -458,7 +483,7 @@ namespace Microsoft.AspNetCore.Authentication.Google ctx.HandleResponse(); return Task.FromResult(0); } - } : new OAuthEvents() + } : new OAuthEvents(); }); var properties = new AuthenticationProperties(); var correlationKey = ".xsrf"; @@ -487,12 +512,12 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task AuthenticatedEventCanGetRefreshToken() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - StateDataFormat = stateFormat, - BackchannelHttpHandler = new TestHttpMessageHandler + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + o.BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -531,8 +556,8 @@ namespace Microsoft.AspNetCore.Authentication.Google throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - }, - Events = new OAuthEvents + }; + o.Events = new OAuthEvents { OnCreatingTicket = context => { @@ -540,7 +565,7 @@ namespace Microsoft.AspNetCore.Authentication.Google context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Google") }, "Google")); return Task.FromResult(0); } - } + }; }); var properties = new AuthenticationProperties(); var correlationKey = ".xsrf"; @@ -567,12 +592,12 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task NullRedirectUriWillRedirectToSlash() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - StateDataFormat = stateFormat, - BackchannelHttpHandler = new TestHttpMessageHandler + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + o.BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -611,15 +636,15 @@ namespace Microsoft.AspNetCore.Authentication.Google throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - }, - Events = new OAuthEvents + }; + o.Events = new OAuthEvents { OnTicketReceived = context => { context.Ticket.Properties.RedirectUri = null; return Task.FromResult(0); } - } + }; }); var properties = new AuthenticationProperties(); var correlationKey = ".xsrf"; @@ -640,13 +665,13 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task ValidateAuthenticatedContext() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - StateDataFormat = stateFormat, - AccessType = "offline", - Events = new OAuthEvents() + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + o.AccessType = "offline"; + o.Events = new OAuthEvents() { OnCreatingTicket = context => { @@ -661,8 +686,8 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal(context.Identity.FindFirst(ClaimTypes.GivenName)?.Value, "Test Given Name"); return Task.FromResult(0); } - }, - BackchannelHttpHandler = new TestHttpMessageHandler + }; + o.BackchannelHttpHandler = new TestHttpMessageHandler { Sender = req => { @@ -701,7 +726,7 @@ namespace Microsoft.AspNetCore.Authentication.Google throw new NotImplementedException(req.RequestUri.AbsoluteUri); } - } + }; }); var properties = new AuthenticationProperties(); @@ -723,10 +748,10 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task NoStateCausesException() { - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret" + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; }); //Post a message to the Google middleware @@ -738,11 +763,11 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task CanRedirectOnError() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - Events = new OAuthEvents() + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.Events = new OAuthEvents() { OnRemoteFailure = ctx => { @@ -750,7 +775,7 @@ namespace Microsoft.AspNetCore.Authentication.Google ctx.HandleResponse(); return Task.FromResult(0); } - } + }; }); //Post a message to the Google middleware @@ -766,13 +791,13 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task AuthenticateAutomaticWhenAlreadySignedInSucceeds() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - SaveTokens = true, - StateDataFormat = stateFormat, - BackchannelHttpHandler = CreateBackchannel() + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + o.SaveTokens = true; + o.BackchannelHttpHandler = CreateBackchannel(); }); // Skip the challenge step, go directly to the callback path @@ -809,13 +834,13 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task AuthenticateGoogleWhenAlreadySignedInSucceeds() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - SaveTokens = true, - StateDataFormat = stateFormat, - BackchannelHttpHandler = CreateBackchannel() + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + o.SaveTokens = true; + o.BackchannelHttpHandler = CreateBackchannel(); }); // Skip the challenge step, go directly to the callback path @@ -852,13 +877,13 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task ChallengeGoogleWhenAlreadySignedInReturnsForbidden() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - SaveTokens = true, - StateDataFormat = stateFormat, - BackchannelHttpHandler = CreateBackchannel() + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + o.SaveTokens = true; + o.BackchannelHttpHandler = CreateBackchannel(); }); // Skip the challenge step, go directly to the callback path @@ -888,13 +913,13 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - SaveTokens = true, - StateDataFormat = stateFormat, - BackchannelHttpHandler = CreateBackchannel() + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + o.SaveTokens = true; + o.BackchannelHttpHandler = CreateBackchannel(); }); // Skip the challenge step, go directly to the callback path @@ -924,13 +949,13 @@ namespace Microsoft.AspNetCore.Authentication.Google public async Task ChallengeFacebookWhenAlreadySignedWithGoogleSucceeds() { var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(new GoogleOptions + var server = CreateServer(o => { - ClientId = "Test Id", - ClientSecret = "Test Secret", - SaveTokens = true, - StateDataFormat = stateFormat, - BackchannelHttpHandler = CreateBackchannel() + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + o.SaveTokens = true; + o.BackchannelHttpHandler = CreateBackchannel(); }); // Skip the challenge step, go directly to the callback path @@ -1007,46 +1032,42 @@ namespace Microsoft.AspNetCore.Authentication.Google return res; } - private static TestServer CreateServer(GoogleOptions options, Func testpath = null) + private class ClaimsTransformer : IClaimsTransformation + { + public Task TransformAsync(ClaimsPrincipal p) + { + if (!p.Identities.Any(i => i.AuthenticationType == "xform")) + { + var id = new ClaimsIdentity("xform"); + id.AddClaim(new Claim("xform", "yup")); + p.AddIdentity(id); + } + return Task.FromResult(p); + } + } + + private static TestServer CreateServer(Action configureOptions, Func testpath = null) { var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AuthenticationScheme = TestExtensions.CookieAuthenticationScheme, - AutomaticAuthenticate = true - }); - app.UseGoogleAuthentication(options); - app.UseFacebookAuthentication(new FacebookOptions() - { - AppId = "Test AppId", - AppSecret = "Test AppSecrent", - }); - app.UseClaimsTransformation(context => - { - var id = new ClaimsIdentity("xform"); - id.AddClaim(new Claim("xform", "yup")); - context.Principal.AddIdentity(id); - return Task.FromResult(context.Principal); - }); + app.UseAuthentication(); app.Use(async (context, next) => { var req = context.Request; var res = context.Response; if (req.Path == new PathString("/challenge")) { - await context.Authentication.ChallengeAsync("Google"); + await context.ChallengeAsync("Google"); } else if (req.Path == new PathString("/challengeFacebook")) { - await context.Authentication.ChallengeAsync("Facebook"); + await context.ChallengeAsync("Facebook"); } else if (req.Path == new PathString("/tokens")) { - var authContext = new AuthenticateContext(TestExtensions.CookieAuthenticationScheme); - await context.Authentication.AuthenticateAsync(authContext); - var tokens = new AuthenticationProperties(authContext.Properties).GetTokens(); + var result = await context.AuthenticateAsync(TestExtensions.CookieAuthenticationScheme); + var tokens = result.Ticket.Properties.GetTokens(); res.Describe(tokens); } else if (req.Path == new PathString("/me")) @@ -1055,29 +1076,29 @@ namespace Microsoft.AspNetCore.Authentication.Google } else if (req.Path == new PathString("/authenticate")) { - var user = await context.Authentication.AuthenticateAsync(Http.Authentication.AuthenticationManager.AutomaticScheme); - res.Describe(user); + var result = await context.AuthenticateAsync(TestExtensions.CookieAuthenticationScheme); + res.Describe(result.Ticket.Principal); } else if (req.Path == new PathString("/authenticateGoogle")) { - var user = await context.Authentication.AuthenticateAsync("Google"); - res.Describe(user); + var result = await context.AuthenticateAsync("Google"); + res.Describe(result?.Ticket?.Principal); } else if (req.Path == new PathString("/authenticateFacebook")) { - var user = await context.Authentication.AuthenticateAsync("Facebook"); - res.Describe(user); + var result = await context.AuthenticateAsync("Facebook"); + res.Describe(result?.Ticket?.Principal); } else if (req.Path == new PathString("/unauthorized")) { // Simulate Authorization failure - var result = await context.Authentication.AuthenticateAsync("Google"); - await context.Authentication.ChallengeAsync("Google"); + var result = await context.AuthenticateAsync("Google"); + await context.ChallengeAsync("Google"); } else if (req.Path == new PathString("/unauthorizedAuto")) { - var result = await context.Authentication.AuthenticateAsync("Google"); - await context.Authentication.ChallengeAsync(); + var result = await context.AuthenticateAsync("Google"); + await context.ChallengeAsync("Google"); } else if (req.Path == new PathString("/401")) { @@ -1085,15 +1106,15 @@ namespace Microsoft.AspNetCore.Authentication.Google } else if (req.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.Authentication.SignInAsync("Google", new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.SignInAsync("Google", new ClaimsPrincipal())); } else if (req.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync("Google")); + await Assert.ThrowsAsync(() => context.SignOutAsync("Google")); } else if (req.Path == new PathString("/forbid")) { - await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Google")); + await Assert.ThrowsAsync(() => context.ForbidAsync("Google")); } else if (testpath != null) { @@ -1107,7 +1128,20 @@ namespace Microsoft.AspNetCore.Authentication.Google }) .ConfigureServices(services => { - services.AddAuthentication(authOptions => authOptions.SignInScheme = TestExtensions.CookieAuthenticationScheme); + services.AddTransient(); + services.AddAuthentication(o => + { + o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme; + o.DefaultSignInScheme = TestExtensions.CookieAuthenticationScheme; + o.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme; + }); + services.AddCookieAuthentication(TestExtensions.CookieAuthenticationScheme); + services.AddGoogleAuthentication(configureOptions); + services.AddFacebookAuthentication(o => + { + o.AppId = "Test AppId"; + o.AppSecret = "Test AppSecrent"; + }); }); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs similarity index 75% rename from test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index c0d2ddba5b..08098622ca 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearer/JwtBearerMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; @@ -13,30 +14,84 @@ using System.Xml.Linq; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; using Xunit; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class JwtBearerMiddlewareTests + public class JwtBearerTests { + [Fact] + public void AddCanBindAgainstDefaultConfig() + { + var dic = new Dictionary + { + {"Bearer:Audience", ""}, + {"Bearer:Authority", ""}, + {"Bearer:BackchannelTimeout", "0.0:0:30"}, + {"Bearer:Challenge", ""}, + {"Bearer:ClaimsIssuer", ""}, + {"Bearer:DisplayName", ""}, + {"Bearer:IncludeErrorDetails", "true"}, + {"Bearer:MetadataAddress", ""}, + {"Bearer:RefreshOnIssuerKeyNotFound", "true"}, + {"Bearer:RequireHttpsMetadata", "true"}, + {"Bearer:SaveToken", "true"}, + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddJwtBearerAuthentication().AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(JwtBearerDefaults.AuthenticationScheme); + Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); + Assert.Equal("", options.Audience); + Assert.Equal("", options.Authority); + Assert.Equal("", options.Challenge); + Assert.Equal("", options.ClaimsIssuer); + Assert.Equal("", options.DisplayName); + Assert.True(options.IncludeErrorDetails); + Assert.Equal("", options.MetadataAddress); + Assert.True(options.RefreshOnIssuerKeyNotFound); + Assert.True(options.RequireHttpsMetadata); + Assert.True(options.SaveToken); + } + + [Fact] + public void AddWithDelegateIgnoresConfig() + { + var dic = new Dictionary + { + {"Bearer:Audience", ""}, + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddJwtBearerAuthentication(o => o.IncludeErrorDetails = true).AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(JwtBearerDefaults.AuthenticationScheme); + Assert.Null(options.Audience); + Assert.True(options.IncludeErrorDetails); + } + [ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/179 public async Task BearerTokenValidation() { - var options = new JwtBearerOptions + var server = CreateServer(o => { - Authority = "https://login.windows.net/tushartest.onmicrosoft.com", - Audience = "https://TusharTest.onmicrosoft.com/TodoListService-ManualJwt" - }; - options.TokenValidationParameters.ValidateLifetime = false; - var server = CreateServer(options); + o.Authority = "https://login.windows.net/tushartest.onmicrosoft.com"; + o.Audience = "https://TusharTest.onmicrosoft.com/TodoListService-ManualJwt"; + o.TokenValidationParameters.ValidateLifetime = false; + }); var newBearerToken = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtyaU1QZG1Cdng2OHNrVDgtbVBBQjNCc2VlQSJ9.eyJhdWQiOiJodHRwczovL1R1c2hhclRlc3Qub25taWNyb3NvZnQuY29tL1RvZG9MaXN0U2VydmljZS1NYW51YWxKd3QiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9hZmJlY2UwMy1hZWFhLTRmM2YtODVlNy1jZTA4ZGQyMGNlNTAvIiwiaWF0IjoxNDE4MzMwNjE0LCJuYmYiOjE0MTgzMzA2MTQsImV4cCI6MTQxODMzNDUxNCwidmVyIjoiMS4wIiwidGlkIjoiYWZiZWNlMDMtYWVhYS00ZjNmLTg1ZTctY2UwOGRkMjBjZTUwIiwiYW1yIjpbInB3ZCJdLCJvaWQiOiI1Mzk3OTdjMi00MDE5LTQ2NTktOWRiNS03MmM0Yzc3NzhhMzMiLCJ1cG4iOiJWaWN0b3JAVHVzaGFyVGVzdC5vbm1pY3Jvc29mdC5jb20iLCJ1bmlxdWVfbmFtZSI6IlZpY3RvckBUdXNoYXJUZXN0Lm9ubWljcm9zb2Z0LmNvbSIsInN1YiI6IkQyMm9aMW9VTzEzTUFiQXZrdnFyd2REVE80WXZJdjlzMV9GNWlVOVUwYnciLCJmYW1pbHlfbmFtZSI6Ikd1cHRhIiwiZ2l2ZW5fbmFtZSI6IlZpY3RvciIsImFwcGlkIjoiNjEzYjVhZjgtZjJjMy00MWI2LWExZGMtNDE2Yzk3ODAzMGI3IiwiYXBwaWRhY3IiOiIwIiwic2NwIjoidXNlcl9pbXBlcnNvbmF0aW9uIiwiYWNyIjoiMSJ9.N_Kw1EhoVGrHbE6hOcm7ERdZ7paBQiNdObvp2c6T6n5CE8p0fZqmUd-ya_EqwElcD6SiKSiP7gj0gpNUnOJcBl_H2X8GseaeeMxBrZdsnDL8qecc6_ygHruwlPltnLTdka67s1Ow4fDSHaqhVTEk6lzGmNEcbNAyb0CxQxU6o7Fh0yHRiWoLsT8yqYk8nKzsHXfZBNby4aRo3_hXaa4i0SZLYfDGGYPdttG4vT_u54QGGd4Wzbonv2gjDlllOVGOwoJS6kfl1h8mk0qxdiIaT_ChbDWgkWvTB7bTvBE-EgHgV0XmAo0WtJeSxgjsG3KhhEPsONmqrSjhIUV4IVnF2w"; var response = await SendAsync(server, "http://example.com/oauth", newBearerToken); @@ -46,7 +101,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task SignInThrows() { - var server = CreateServer(new JwtBearerOptions()); + var server = CreateServer(); var transaction = await server.SendAsync("https://example.com/signIn"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } @@ -54,7 +109,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task SignOutThrows() { - var server = CreateServer(new JwtBearerOptions()); + var server = CreateServer(); var transaction = await server.SendAsync("https://example.com/signOut"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } @@ -62,9 +117,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task ThrowAtAuthenticationFailedEvent() { - var options = new JwtBearerOptions + var server = CreateServer(o => { - Events = new JwtBearerEvents + o.Events = new JwtBearerEvents { OnAuthenticationFailed = context => { @@ -76,12 +131,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer context.Token = "something"; return Task.FromResult(0); } - } - }; - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Insert(0, new InvalidTokenValidator()); - - var server = CreateServer(options, async (context, next) => + }; + o.SecurityTokenValidators.Clear(); + o.SecurityTokenValidators.Insert(0, new InvalidTokenValidator()); + }, + async (context, next) => { try { @@ -103,9 +157,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task CustomHeaderReceived() { - var server = CreateServer(new JwtBearerOptions + var server = CreateServer(o => { - Events = new JwtBearerEvents() + o.Events = new JwtBearerEvents() { OnMessageReceived = context => { @@ -117,14 +171,14 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer }; context.Ticket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), - new AuthenticationProperties(), context.Options.AuthenticationScheme); + new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)), + new AuthenticationProperties(), context.Scheme.Name); context.HandleResponse(); return Task.FromResult(null); } - } + }; }); var response = await SendAsync(server, "http://example.com/oauth", "someHeader someblob"); @@ -135,7 +189,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task NoHeaderReceived() { - var server = CreateServer(new JwtBearerOptions()); + var server = CreateServer(); var response = await SendAsync(server, "http://example.com/oauth"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); } @@ -143,7 +197,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task HeaderWithoutBearerReceived() { - var server = CreateServer(new JwtBearerOptions()); + var server = CreateServer(); var response = await SendAsync(server, "http://example.com/oauth", "Token"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); } @@ -151,8 +205,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task UnrecognizedTokenReceived() { - var server = CreateServer(new JwtBearerOptions()); - + var server = CreateServer(); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); Assert.Equal("", response.ResponseText); @@ -161,10 +214,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task InvalidTokenReceived() { - var options = new JwtBearerOptions(); - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new InvalidTokenValidator()); - var server = CreateServer(options); + var server = CreateServer(options => + { + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new InvalidTokenValidator()); + }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); @@ -183,10 +237,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [InlineData(typeof(SecurityTokenSignatureKeyNotFoundException), "The signature key was not found")] public async Task ExceptionReportedInHeaderForAuthenticationFailures(Type errorType, string message) { - var options = new JwtBearerOptions(); - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new InvalidTokenValidator(errorType)); - var server = CreateServer(options); + var server = CreateServer(options => + { + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new InvalidTokenValidator(errorType)); + }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); @@ -198,10 +253,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [InlineData(typeof(ArgumentException))] public async Task ExceptionNotReportedInHeaderForOtherFailures(Type errorType) { - var options = new JwtBearerOptions(); - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new InvalidTokenValidator(errorType)); - var server = CreateServer(options); + var server = CreateServer(options => + { + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new InvalidTokenValidator(errorType)); + }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); @@ -212,11 +268,12 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task ExceptionsReportedInHeaderForMultipleAuthenticationFailures() { - var options = new JwtBearerOptions(); - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new InvalidTokenValidator(typeof(SecurityTokenInvalidAudienceException))); - options.SecurityTokenValidators.Add(new InvalidTokenValidator(typeof(SecurityTokenSignatureKeyNotFoundException))); - var server = CreateServer(options); + var server = CreateServer(options => + { + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new InvalidTokenValidator(typeof(SecurityTokenInvalidAudienceException))); + options.SecurityTokenValidators.Add(new InvalidTokenValidator(typeof(SecurityTokenSignatureKeyNotFoundException))); + }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); @@ -234,9 +291,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [InlineData(null, null, "custom_uri")] public async Task ExceptionsReportedInHeaderExposesUserDefinedError(string error, string description, string uri) { - var options = new JwtBearerOptions + var server = CreateServer(options => { - Events = new JwtBearerEvents + options.Events = new JwtBearerEvents { OnChallenge = context => { @@ -246,15 +303,14 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer return Task.FromResult(0); } - } - }; - var server = CreateServer(options); + }; + }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); Assert.Equal("", response.ResponseText); - var builder = new StringBuilder(options.Challenge); + var builder = new StringBuilder(JwtBearerDefaults.AuthenticationScheme); if (!string.IsNullOrEmpty(error)) { @@ -292,9 +348,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task ExceptionNotReportedInHeaderWhenIncludeErrorDetailsIsFalse() { - var server = CreateServer(new JwtBearerOptions + var server = CreateServer(o => { - IncludeErrorDetails = false + o.IncludeErrorDetails = false; }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); @@ -306,7 +362,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task ExceptionNotReportedInHeaderWhenTokenWasMissing() { - var server = CreateServer(new JwtBearerOptions()); + var server = CreateServer(); var response = await SendAsync(server, "http://example.com/oauth"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); @@ -317,9 +373,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task CustomTokenValidated() { - var options = new JwtBearerOptions + var server = CreateServer(options => { - Events = new JwtBearerEvents() + options.Events = new JwtBearerEvents() { OnTokenValidated = context => { @@ -339,11 +395,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer return Task.FromResult(null); } - } - }; - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator(options.AuthenticationScheme)); - var server = CreateServer(options); + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator(JwtBearerDefaults.AuthenticationScheme)); + }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer someblob"); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); @@ -353,23 +408,22 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task RetrievingTokenFromAlternateLocation() { - var options = new JwtBearerOptions() + var server = CreateServer(options => { - Events = new JwtBearerEvents() + options.Events = new JwtBearerEvents() { OnMessageReceived = context => { context.Token = "CustomToken"; return Task.FromResult(null); } - } - }; - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT", token => - { - Assert.Equal("CustomToken", token); - })); - var server = CreateServer(options); + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT", token => + { + Assert.Equal("CustomToken", token); + })); + }); var response = await SendAsync(server, "http://example.com/oauth", "Bearer Token"); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); @@ -379,10 +433,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task BearerTurns401To403IfAuthenticated() { - var options = new JwtBearerOptions(); - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); - var server = CreateServer(options); + var server = CreateServer(options => + { + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + }); var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); Assert.Equal(HttpStatusCode.Forbidden, response.Response.StatusCode); @@ -391,22 +446,21 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task BearerDoesNothingTo401IfNotAuthenticated() { - var server = CreateServer(new JwtBearerOptions()); - + var server = CreateServer(); var response = await SendAsync(server, "http://example.com/unauthorized"); Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); } [Fact] - public async Task EventOnMessageReceivedSkipped_NoMoreEventsExecuted() + public async Task EventOnMessageReceivedSkip_NoMoreEventsExecuted() { - var server = CreateServer(new JwtBearerOptions + var server = CreateServer(options => { - Events = new JwtBearerEvents() + options.Events = new JwtBearerEvents() { OnMessageReceived = context => { - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnTokenValidated = context => @@ -421,7 +475,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { throw new NotImplementedException(); }, - } + }; }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); @@ -432,9 +486,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() { - var server = CreateServer(new JwtBearerOptions + var server = CreateServer(options => { - Events = new JwtBearerEvents() + options.Events = new JwtBearerEvents() { OnMessageReceived = context => { @@ -454,7 +508,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { throw new NotImplementedException(); }, - } + }; }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); @@ -463,15 +517,15 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } [Fact] - public async Task EventOnTokenValidatedSkipped_NoMoreEventsExecuted() + public async Task EventOnTokenValidatedSkip_NoMoreEventsExecuted() { - var options = new JwtBearerOptions + var server = CreateServer(options => { - Events = new JwtBearerEvents() + options.Events = new JwtBearerEvents() { OnTokenValidated = context => { - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnAuthenticationFailed = context => @@ -482,11 +536,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { throw new NotImplementedException(); }, - } - }; - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); - var server = CreateServer(options); + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); @@ -496,9 +549,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() { - var options = new JwtBearerOptions + var server = CreateServer(options => { - Events = new JwtBearerEvents() + options.Events = new JwtBearerEvents() { OnTokenValidated = context => { @@ -514,11 +567,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { throw new NotImplementedException(); }, - } - }; - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); - var server = CreateServer(options); + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); @@ -526,11 +578,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } [Fact] - public async Task EventOnAuthenticationFailedSkipped_NoMoreEventsExecuted() + public async Task EventOnAuthenticationFailedSkip_NoMoreEventsExecuted() { - var options = new JwtBearerOptions + var server = CreateServer(options => { - Events = new JwtBearerEvents() + options.Events = new JwtBearerEvents() { OnTokenValidated = context => { @@ -538,18 +590,17 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer }, OnAuthenticationFailed = context => { - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnChallenge = context => { throw new NotImplementedException(); }, - } - }; - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); - var server = CreateServer(options); + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); @@ -559,9 +610,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() { - var options = new JwtBearerOptions + var server = CreateServer(options => { - Events = new JwtBearerEvents() + options.Events = new JwtBearerEvents() { OnTokenValidated = context => { @@ -577,11 +628,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { throw new NotImplementedException(); }, - } - }; - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); - var server = CreateServer(options); + }; + options.SecurityTokenValidators.Clear(); + options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); + }); var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); @@ -589,18 +639,18 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } [Fact] - public async Task EventOnChallengeSkipped_ResponseNotModified() + public async Task EventOnChallengeSkip_ResponseNotModified() { - var server = CreateServer(new JwtBearerOptions + var server = CreateServer(o => { - Events = new JwtBearerEvents() + o.Events = new JwtBearerEvents() { OnChallenge = context => { - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, - } + }; }); var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); @@ -609,12 +659,13 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal(string.Empty, response.ResponseText); } + [Fact] public async Task EventOnChallengeHandled_ResponseNotModified() { - var server = CreateServer(new JwtBearerOptions + var server = CreateServer(o => { - Events = new JwtBearerEvents() + o.Events = new JwtBearerEvents() { OnChallenge = context => { @@ -622,7 +673,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, - } + }; }); var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); @@ -699,10 +750,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParameters validationParameters, out SecurityToken validatedToken) { validatedToken = null; - if (_tokenValidator != null) - { - _tokenValidator(securityToken); - } + _tokenValidator?.Invoke(securityToken); var claims = new[] { @@ -717,12 +765,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } } - private static TestServer CreateServer(JwtBearerOptions options) - { - return CreateServer(options, handlerBeforeAuth: null); - } - - private static TestServer CreateServer(JwtBearerOptions options, Func, Task> handlerBeforeAuth) + private static TestServer CreateServer(Action options = null, Func, Task> handlerBeforeAuth = null) { var builder = new WebHostBuilder() .Configure(app => @@ -732,20 +775,15 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer app.Use(handlerBeforeAuth); } - if (options != null) - { - app.UseJwtBearerAuthentication(options); - } - + app.UseAuthentication(); app.Use(async (context, next) => { if (context.Request.Path == new PathString("/checkforerrors")) { - var authContext = new AuthenticateContext(Http.Authentication.AuthenticationManager.AutomaticScheme); - await context.Authentication.AuthenticateAsync(authContext); - if (authContext.Error != null) + var result = await context.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme); // this used to be "Automatic" + if (result.Failure != null) { - throw new Exception("Failed to authenticate", authContext.Error); + throw new Exception("Failed to authenticate", result.Failure); } return; } @@ -756,7 +794,8 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer !context.User.Identity.IsAuthenticated) { context.Response.StatusCode = 401; - + // REVIEW: no more automatic challenge + await context.ChallengeAsync(JwtBearerDefaults.AuthenticationScheme); return; } @@ -764,7 +803,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer if (identifier == null) { context.Response.StatusCode = 500; - return; } @@ -773,16 +811,16 @@ namespace Microsoft.AspNetCore.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.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme); + await context.ChallengeAsync(JwtBearerDefaults.AuthenticationScheme); } else if (context.Request.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.Authentication.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); } else if (context.Request.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync(JwtBearerDefaults.AuthenticationScheme)); + await Assert.ThrowsAsync(() => context.SignOutAsync(JwtBearerDefaults.AuthenticationScheme)); } else { @@ -790,7 +828,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } }); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddJwtBearerAuthentication(options)); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index bbf54ec5e7..801567d7e9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -1,14 +1,12 @@  - netcoreapp2.0;net46 netcoreapp2.0 true true - @@ -16,6 +14,8 @@ + + @@ -23,7 +23,6 @@ - diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs deleted file mode 100644 index 0ed164e496..0000000000 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. - -using System; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Security.Claims; -using System.Text; -using System.Text.Encodings.Web; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging.Abstractions; -using Newtonsoft.Json; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount -{ - public class MicrosoftAccountMiddlewareTests - { - [Fact] - public async Task ChallengeWillTriggerApplyRedirectEvent() - { - var server = CreateServer(new MicrosoftAccountOptions - { - ClientId = "Test Client Id", - ClientSecret = "Test Client Secret", - Events = new OAuthEvents - { - OnRedirectToAuthorizationEndpoint = context => - { - context.Response.Redirect(context.RedirectUri + "&custom=test"); - return Task.FromResult(0); - } - } - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - var query = transaction.Response.Headers.Location.Query; - Assert.Contains("custom=test", query); - } - - [Fact] - public async Task SignInThrows() - { - var server = CreateServer(new MicrosoftAccountOptions - { - ClientId = "Test Id", - ClientSecret = "Test Secret" - }); - var transaction = await server.SendAsync("https://example.com/signIn"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - } - - [Fact] - public async Task SignOutThrows() - { - var server = CreateServer(new MicrosoftAccountOptions - { - ClientId = "Test Id", - ClientSecret = "Test Secret" - }); - var transaction = await server.SendAsync("https://example.com/signOut"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - } - - [Fact] - public async Task ForbidThrows() - { - var server = CreateServer(new MicrosoftAccountOptions - { - ClientId = "Test Id", - ClientSecret = "Test Secret" - }); - var transaction = await server.SendAsync("https://example.com/signOut"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - } - - [Fact] - public async Task ChallengeWillTriggerRedirection() - { - var server = CreateServer(new MicrosoftAccountOptions - { - ClientId = "Test Client Id", - ClientSecret = "Test Client Secret" - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://login.microsoftonline.com/common/oauth2/v2.0/authorize", location); - Assert.Contains("response_type=code", location); - Assert.Contains("client_id=", location); - Assert.Contains("redirect_uri=", location); - Assert.Contains("scope=", location); - Assert.Contains("state=", location); - } - - [Fact] - public async Task AuthenticatedEventCanGetRefreshToken() - { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("MsftTest")); - var server = CreateServer(new MicrosoftAccountOptions - { - ClientId = "Test Client Id", - ClientSecret = "Test Client Secret", - StateDataFormat = stateFormat, - BackchannelHttpHandler = new TestHttpMessageHandler - { - Sender = req => - { - if (req.RequestUri.AbsoluteUri == "https://login.microsoftonline.com/common/oauth2/v2.0/token") - { - return ReturnJsonResponse(new - { - access_token = "Test Access Token", - expire_in = 3600, - token_type = "Bearer", - refresh_token = "Test Refresh Token" - }); - } - else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://graph.microsoft.com/v1.0/me") - { - return ReturnJsonResponse(new - { - id = "Test User ID", - displayName = "Test Name", - givenName = "Test Given Name", - surname = "Test Family Name", - mail = "Test email" - }); - } - - return null; - } - }, - Events = new OAuthEvents - { - OnCreatingTicket = context => - { - var refreshToken = context.RefreshToken; - context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Microsoft") }, "Microsoft")); - return Task.FromResult(null); - } - } - }); - var properties = new AuthenticationProperties(); - var correlationKey = ".xsrf"; - var correlationValue = "TestCorrelationId"; - properties.Items.Add(correlationKey, correlationValue); - properties.RedirectUri = "/me"; - var state = stateFormat.Protect(properties); - var transaction = await server.SendAsync( - "https://example.com/signin-microsoft?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - $".AspNetCore.Correlation.Microsoft.{correlationValue}=N"); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); - Assert.Equal(2, transaction.SetCookie.Count); - Assert.Contains($".AspNetCore.Correlation.Microsoft.{correlationValue}", transaction.SetCookie[0]); - Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); - - var authCookie = transaction.AuthenticationCookieValue; - transaction = await server.SendAsync("https://example.com/me", authCookie); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.Equal("Test Refresh Token", transaction.FindClaimValue("RefreshToken")); - } - - private static TestServer CreateServer(MicrosoftAccountOptions options) - { - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AuthenticationScheme = TestExtensions.CookieAuthenticationScheme, - AutomaticAuthenticate = true - }); - app.UseMicrosoftAccountAuthentication(options); - - app.Use(async (context, next) => - { - var req = context.Request; - var res = context.Response; - if (req.Path == new PathString("/challenge")) - { - await context.Authentication.ChallengeAsync("Microsoft"); - } - else if (req.Path == new PathString("/me")) - { - res.Describe(context.User); - } - else if (req.Path == new PathString("/signIn")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignInAsync("Microsoft", new ClaimsPrincipal())); - } - else if (req.Path == new PathString("/signOut")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync("Microsoft")); - } - else if (req.Path == new PathString("/forbid")) - { - await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Microsoft")); - } - else - { - await next(); - } - }); - }) - .ConfigureServices(services => - { - services.AddAuthentication(); - services.Configure(authOptions => - { - authOptions.SignInScheme = TestExtensions.CookieAuthenticationScheme; - }); - }); - return new TestServer(builder); - } - - private static HttpResponseMessage ReturnJsonResponse(object content) - { - var res = new HttpResponseMessage(HttpStatusCode.OK); - var text = JsonConvert.SerializeObject(content); - res.Content = new StringContent(text, Encoding.UTF8, "application/json"); - return res; - } - } -} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs new file mode 100644 index 0000000000..26110e9fee --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -0,0 +1,291 @@ +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Claims; +using System.Text; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.MicrosoftAccount; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount +{ + public class MicrosoftAccountTests + { + [Fact] + public void AddCanBindAgainstDefaultConfig() + { + var dic = new Dictionary + { + {"Microsoft:ClientId", ""}, + {"Microsoft:ClientSecret", ""}, + {"Microsoft:AuthorizationEndpoint", ""}, + {"Microsoft:BackchannelTimeout", "0.0:0:30"}, + //{"Microsoft:CallbackPath", "/callbackpath"}, // PathString doesn't convert + {"Microsoft:ClaimsIssuer", ""}, + {"Microsoft:DisplayName", ""}, + {"Microsoft:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Microsoft:SaveTokens", "true"}, + {"Microsoft:SendAppSecretProof", "true"}, + {"Microsoft:SignInScheme", ""}, + {"Microsoft:TokenEndpoint", ""}, + {"Microsoft:UserInformationEndpoint", ""}, + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddMicrosoftAccountAuthentication().AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(MicrosoftAccountDefaults.AuthenticationScheme); + Assert.Equal("", options.AuthorizationEndpoint); + Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); + //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert + Assert.Equal("", options.ClaimsIssuer); + Assert.Equal("", options.ClientId); + Assert.Equal("", options.ClientSecret); + Assert.Equal("", options.DisplayName); + Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); + Assert.True(options.SaveTokens); + Assert.Equal("", options.SignInScheme); + Assert.Equal("", options.TokenEndpoint); + Assert.Equal("", options.UserInformationEndpoint); + } + + [Fact] + public void AddWithDelegateIgnoresConfig() + { + var dic = new Dictionary + { + {"Microsoft:ClientId", ""}, + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddMicrosoftAccountAuthentication(o => o.SaveTokens = true).AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(MicrosoftAccountDefaults.AuthenticationScheme); + Assert.Null(options.ClientId); + Assert.True(options.SaveTokens); + } + + [Fact] + public async Task ChallengeWillTriggerApplyRedirectEvent() + { + var server = CreateServer(o => + { + o.ClientId = "Test Client Id"; + o.ClientSecret = "Test Client Secret"; + o.Events = new OAuthEvents + { + OnRedirectToAuthorizationEndpoint = context => + { + context.Response.Redirect(context.RedirectUri + "&custom=test"); + return Task.FromResult(0); + } + }; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + var query = transaction.Response.Headers.Location.Query; + Assert.Contains("custom=test", query); + } + + [Fact] + public async Task SignInThrows() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + }); + var transaction = await server.SendAsync("https://example.com/signIn"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + [Fact] + public async Task SignOutThrows() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + }); + var transaction = await server.SendAsync("https://example.com/signOut"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + [Fact] + public async Task ForbidThrows() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + }); + var transaction = await server.SendAsync("https://example.com/signOut"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + [Fact] + public async Task ChallengeWillTriggerRedirection() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + var location = transaction.Response.Headers.Location.AbsoluteUri; + Assert.Contains("https://login.microsoftonline.com/common/oauth2/v2.0/authorize", location); + Assert.Contains("response_type=code", location); + Assert.Contains("client_id=", location); + Assert.Contains("redirect_uri=", location); + Assert.Contains("scope=", location); + Assert.Contains("state=", location); + } + + [Fact] + public async Task AuthenticatedEventCanGetRefreshToken() + { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("MsftTest")); + var server = CreateServer(o => + { + o.ClientId = "Test Client Id"; + o.ClientSecret = "Test Client Secret"; + o.StateDataFormat = stateFormat; + o.BackchannelHttpHandler = new TestHttpMessageHandler + { + Sender = req => + { + if (req.RequestUri.AbsoluteUri == "https://login.microsoftonline.com/common/oauth2/v2.0/token") + { + return ReturnJsonResponse(new + { + access_token = "Test Access Token", + expire_in = 3600, + token_type = "Bearer", + refresh_token = "Test Refresh Token" + }); + } + else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://graph.microsoft.com/v1.0/me") + { + return ReturnJsonResponse(new + { + id = "Test User ID", + displayName = "Test Name", + givenName = "Test Given Name", + surname = "Test Family Name", + mail = "Test email" + }); + } + + return null; + } + }; + o.Events = new OAuthEvents + { + OnCreatingTicket = context => + { + var refreshToken = context.RefreshToken; + context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Microsoft") }, "Microsoft")); + return Task.FromResult(null); + } + }; + }); + var properties = new AuthenticationProperties(); + var correlationKey = ".xsrf"; + var correlationValue = "TestCorrelationId"; + properties.Items.Add(correlationKey, correlationValue); + properties.RedirectUri = "/me"; + var state = stateFormat.Protect(properties); + var transaction = await server.SendAsync( + "https://example.com/signin-microsoft?code=TestCode&state=" + UrlEncoder.Default.Encode(state), + $".AspNetCore.Correlation.Microsoft.{correlationValue}=N"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); + Assert.Equal(2, transaction.SetCookie.Count); + Assert.Contains($".AspNetCore.Correlation.Microsoft.{correlationValue}", transaction.SetCookie[0]); + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + + var authCookie = transaction.AuthenticationCookieValue; + transaction = await server.SendAsync("https://example.com/me", authCookie); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + Assert.Equal("Test Refresh Token", transaction.FindClaimValue("RefreshToken")); + } + + private static TestServer CreateServer(Action configureOptions) + { + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Use(async (context, next) => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/challenge")) + { + await context.ChallengeAsync("Microsoft"); + } + else if (req.Path == new PathString("/me")) + { + res.Describe(context.User); + } + else if (req.Path == new PathString("/signIn")) + { + await Assert.ThrowsAsync(() => context.SignInAsync("Microsoft", new ClaimsPrincipal())); + } + else if (req.Path == new PathString("/signOut")) + { + await Assert.ThrowsAsync(() => context.SignOutAsync("Microsoft")); + } + else if (req.Path == new PathString("/forbid")) + { + await Assert.ThrowsAsync(() => context.ForbidAsync("Microsoft")); + } + else + { + await next(); + } + }); + }) + .ConfigureServices(services => + { + services.AddAuthentication(o => + { + o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme; + o.DefaultSignInScheme = TestExtensions.CookieAuthenticationScheme; + }); + services.AddCookieAuthentication(TestExtensions.CookieAuthenticationScheme, o => { }); + services.AddMicrosoftAccountAuthentication(configureOptions); + }); + return new TestServer(builder); + } + + private static HttpResponseMessage ReturnJsonResponse(object content) + { + var res = new HttpResponseMessage(HttpStatusCode.OK); + var text = JsonConvert.SerializeObject(content); + res.Content = new StringContent(text, Encoding.UTF8, "application/json"); + return res; + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs new file mode 100644 index 0000000000..95c086c805 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -0,0 +1,173 @@ +// 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.Net; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.OAuth +{ + public class OAuthTests + { + [Fact] + public async Task ThrowsIfClientIdMissing() + { + var server = CreateServer( + app => { }, + services => services.AddOAuthAuthentication("weeblie", o => + { + o.SignInScheme = "whatever"; + o.CallbackPath = "/"; + o.ClientSecret = "whatever"; + o.TokenEndpoint = "/"; + o.AuthorizationEndpoint = "/"; + }), + context => + { + // REVIEW: Gross. + Assert.Throws("ClientId", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + [Fact] + public async Task ThrowsIfClientSecretMissing() + { + var server = CreateServer( + app => { }, + services => services.AddOAuthAuthentication("weeblie", o => + { + o.SignInScheme = "whatever"; + o.ClientId = "Whatever;"; + o.CallbackPath = "/"; + o.TokenEndpoint = "/"; + o.AuthorizationEndpoint = "/"; + }), + context => + { + // REVIEW: Gross. + Assert.Throws("ClientSecret", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + public async Task ThrowsIfCallbackPathMissing() + { + var server = CreateServer( + app => { }, + services => services.AddOAuthAuthentication("weeblie", o => + { + o.ClientId = "Whatever;"; + o.ClientSecret = "Whatever;"; + o.TokenEndpoint = "/"; + o.AuthorizationEndpoint = "/"; + o.SignInScheme = "eh"; + }), + context => + { + // REVIEW: Gross. + Assert.Throws("CallbackPath", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + [Fact] + public async Task ThrowsIfTokenEndpointMissing() + { + var server = CreateServer( + app => { }, + services => services.AddOAuthAuthentication("weeblie", o => + { + o.ClientId = "Whatever;"; + o.ClientSecret = "Whatever;"; + o.CallbackPath = "/"; + o.AuthorizationEndpoint = "/"; + o.SignInScheme = "eh"; + }), + context => + { + // REVIEW: Gross. + Assert.Throws("TokenEndpoint", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + public async Task ThrowsIfAuthorizationEndpointMissing() + { + var server = CreateServer( + app => { }, + services => services.AddOAuthAuthentication("weeblie", o => + { + o.ClientId = "Whatever;"; + o.ClientSecret = "Whatever;"; + o.CallbackPath = "/"; + o.TokenEndpoint = "/"; + o.SignInScheme = "eh"; + }), + context => + { + // REVIEW: Gross. + Assert.Throws("AuthorizationEndpoint", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + [Fact] + public async Task ThrowsIfSignInSchemeMissing() + { + var server = CreateServer( + app => { }, + services => services.AddOAuthAuthentication("weeblie", o => + { + o.ClientId = "Whatever;"; + o.ClientSecret = "Whatever;"; + o.CallbackPath = "/"; + o.TokenEndpoint = "/"; + o.AuthorizationEndpoint = "/"; + }), + context => + { + // REVIEW: Gross. + Assert.Throws("SignInScheme", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + + private static TestServer CreateServer(Action configure, Action configureServices, Func handler) + { + var builder = new WebHostBuilder() + .Configure(app => + { + configure?.Invoke(app); + app.Use(async (context, next) => + { + if (handler == null || !handler(context)) + { + await next(); + } + }); + }) + .ConfigureServices(configureServices); + return new TestServer(builder); + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs index 432980f771..5614fe8fea 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs @@ -1,6 +1,6 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { internal class MockOpenIdConnectMessage : OpenIdConnectMessage { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index 1912561b11..3c0146b083 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -5,12 +5,14 @@ using System; using System.Linq; using System.Net; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Logging.Abstractions; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { public class OpenIdConnectChallengeTests { @@ -20,7 +22,12 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public async Task ChallengeIsIssuedCorrectly() { var settings = new TestSettings( - opt => opt.AuthenticationMethod = OpenIdConnectRedirectBehavior.RedirectGet); + opt => + { + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.AuthenticationMethod = OpenIdConnectRedirectBehavior.RedirectGet; + opt.ClientId = "Test Id"; + }); var server = settings.CreateTestServer(); var transaction = await server.SendAsync(ChallengeEndpoint); @@ -43,9 +50,14 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Fact] public async Task AuthorizationRequestDoesNotIncludeTelemetryParametersWhenDisabled() { - var settings = new TestSettings(opt => opt.DisableTelemetry = true); + var setting = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.DisableTelemetry = true; + }); - var server = settings.CreateTestServer(); + var server = setting.CreateTestServer(); var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; @@ -74,10 +86,15 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect */ [Fact] - public async Task ChallengeIssuedCorrectlyForFormPost() + public async Task ChallengeIssueedCorrectlyForFormPost() { var settings = new TestSettings( - opt => opt.AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost); + opt => + { + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost; + opt.ClientId = "Test Id"; + }); var server = settings.CreateTestServer(); var transaction = await server.SendAsync(ChallengeEndpoint); @@ -101,12 +118,18 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [InlineData(null)] public async Task ChallengeCanSetUserStateThroughProperties(string userState) { - var settings = new TestSettings(); + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("OIDCTest")); + var settings = new TestSettings(o => + { + o.ClientId = "Test Id"; + o.Authority = TestServerBuilder.DefaultAuthority; + o.StateDataFormat = stateFormat; + }); var properties = new AuthenticationProperties(); properties.Items.Add(OpenIdConnectDefaults.UserstatePropertiesKey, userState); - var server = TestServerBuilder.CreateServer(settings.Options, handler: null, properties: properties); + var server = settings.CreateTestServer(properties); var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); var res = transaction.Response; @@ -115,7 +138,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var values = settings.ValidateChallengeRedirect(res.Headers.Location); var actualState = values[OpenIdConnectParameterNames.State]; - var actualProperties = settings.Options.StateDataFormat.Unprotect(actualState); + var actualProperties = stateFormat.Unprotect(actualState); Assert.Equal(userState ?? string.Empty, actualProperties.Items[OpenIdConnectDefaults.UserstatePropertiesKey]); } @@ -125,8 +148,12 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [InlineData(null)] public async Task OnRedirectToIdentityProviderEventCanSetState(string userState) { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("OIDCTest")); var settings = new TestSettings(opt => { + opt.StateDataFormat = stateFormat; + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; opt.Events = new OpenIdConnectEvents() { OnRedirectToIdentityProvider = context => @@ -146,7 +173,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var values = settings.ValidateChallengeRedirect(res.Headers.Location); var actualState = values[OpenIdConnectParameterNames.State]; - var actualProperties = settings.Options.StateDataFormat.Unprotect(actualState); + var actualProperties = stateFormat.Unprotect(actualState); if (userState != null) { @@ -165,6 +192,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var settings = new TestSettings( opts => { + opts.ClientId = "Test Id"; + opts.Authority = TestServerBuilder.DefaultAuthority; opts.Events = new OpenIdConnectEvents() { OnRedirectToIdentityProvider = context => @@ -203,12 +232,13 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var settings = new TestSettings( opts => { + opts.ClientId = "Test Id"; + opts.Authority = TestServerBuilder.DefaultAuthority; opts.Events = new OpenIdConnectEvents() { OnRedirectToIdentityProvider = context => { context.ProtocolMessage.ClientId = newClientId; - return Task.FromResult(0); } }; @@ -245,6 +275,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect var settings = new TestSettings( opts => { + opts.ClientId = "Test Id"; + opts.Authority = TestServerBuilder.DefaultAuthority; opts.Events = new OpenIdConnectEvents() { OnRedirectToIdentityProvider = context => @@ -268,12 +300,15 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect // query string is not generated and the authorization endpoint is replaced. Assert.Equal(newMessage.TestAuthorizeEndpoint, res.Headers.Location.AbsoluteUri); } + [Fact] public async Task OnRedirectToIdentityProviderEventHandlesResponse() { var settings = new TestSettings( opts => { + opts.ClientId = "Test Id"; + opts.Authority = TestServerBuilder.DefaultAuthority; opts.Events = new OpenIdConnectEvents() { OnRedirectToIdentityProvider = context => @@ -297,19 +332,21 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect Assert.Null(res.Headers.Location); } - // This test can be further refined. When one auth middleware skips, the authentication responsibility - // will be flowed to the next one. A dummy auth middleware can be added to ensure the correct logic. + // This test can be further refined. When one auth handler skips, the authentication responsibility + // will be flowed to the next one. A dummy auth handler can be added to ensure the correct logic. [Fact] public async Task OnRedirectToIdentityProviderEventSkipResponse() { var settings = new TestSettings( opts => { + opts.ClientId = "Test Id"; + opts.Authority = TestServerBuilder.DefaultAuthority; opts.Events = new OpenIdConnectEvents() { OnRedirectToIdentityProvider = context => { - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); } }; @@ -327,7 +364,11 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Fact] public async Task ChallengeSetsNonceAndStateCookies() { - var settings = new TestSettings(); + var settings = new TestSettings(o => + { + o.ClientId = "Test Id"; + o.Authority = TestServerBuilder.DefaultAuthority; + }); var server = settings.CreateTestServer(); var transaction = await server.SendAsync(ChallengeEndpoint); @@ -344,7 +385,11 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public async Task Challenge_WithEmptyConfig_Fails() { var settings = new TestSettings( - opt => opt.Configuration = new OpenIdConnectConfiguration()); + opt => + { + opt.ClientId = "Test Id"; + opt.Configuration = new OpenIdConnectConfiguration(); + }); var server = settings.CreateTestServer(); var exception = await Assert.ThrowsAsync(() => server.SendAsync(ChallengeEndpoint)); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 0f5338c5c4..3ceb4a5336 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -2,118 +2,137 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Net; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; +using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { public class OpenIdConnectConfigurationTests { [Fact] - public void MetadataAddressIsGeneratedFromAuthorityWhenMissing() + public async Task MetadataAddressIsGeneratedFromAuthorityWhenMissing() { - var options = new OpenIdConnectOptions - { - Authority = TestServerBuilder.DefaultAuthority, - ClientId = Guid.NewGuid().ToString(), - SignInScheme = Guid.NewGuid().ToString() - }; - - BuildTestServer(options); - - Assert.Equal($"{options.Authority}/.well-known/openid-configuration", options.MetadataAddress); + var builder = new WebHostBuilder() + .ConfigureServices(services => + { + services.AddCookieAuthentication(); + services.AddOpenIdConnectAuthentication(o => + { + o.Authority = TestServerBuilder.DefaultAuthority; + o.ClientId = Guid.NewGuid().ToString(); + o.SignInScheme = Guid.NewGuid().ToString(); + }); + }) + .Configure(app => + { + app.UseAuthentication(); + app.Run(async context => + { + var resolver = context.RequestServices.GetRequiredService(); + var handler = await resolver.GetHandlerAsync(context, OpenIdConnectDefaults.AuthenticationScheme) as OpenIdConnectHandler; + Assert.Equal($"{TestServerBuilder.DefaultAuthority}/.well-known/openid-configuration", handler.Options.MetadataAddress); + }); + }); + var server = new TestServer(builder); + var transaction = await server.SendAsync(@"https://example.com"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } - public void ThrowsWhenSignInSchemeIsMissing() + [Fact] + public Task ThrowsWhenSignInSchemeIsMissing() { - TestConfigurationException( - new OpenIdConnectOptions + return TestConfigurationException( + o => { - Authority = TestServerBuilder.DefaultAuthority, - ClientId = Guid.NewGuid().ToString() + o.ClientId = "Test Id"; + o.Authority = TestServerBuilder.DefaultAuthority; + o.CallbackPath = "/"; }, ex => Assert.Equal("SignInScheme", ex.ParamName)); } [Fact] - public void ThrowsWhenClientIdIsMissing() + public Task ThrowsWhenClientIdIsMissing() { - TestConfigurationException( - new OpenIdConnectOptions + return TestConfigurationException( + o => { - SignInScheme = "TestScheme", - Authority = TestServerBuilder.DefaultAuthority, + o.SignInScheme = "TestScheme"; + o.Authority = TestServerBuilder.DefaultAuthority; }, ex => Assert.Equal("ClientId", ex.ParamName)); } [Fact] - public void ThrowsWhenAuthorityIsMissing() + public Task ThrowsWhenAuthorityIsMissing() { - TestConfigurationException( - new OpenIdConnectOptions + return TestConfigurationException( + o => { - SignInScheme = "TestScheme", - ClientId = "Test Id", + o.SignInScheme = "TestScheme"; + o.ClientId = "Test Id"; + o.CallbackPath = "/"; }, ex => Assert.Equal("Provide Authority, MetadataAddress, Configuration, or ConfigurationManager to OpenIdConnectOptions", ex.Message) ); } [Fact] - public void ThrowsWhenAuthorityIsNotHttps() + public Task ThrowsWhenAuthorityIsNotHttps() { - TestConfigurationException( - new OpenIdConnectOptions + return TestConfigurationException( + o => { - SignInScheme = "TestScheme", - ClientId = "Test Id", - Authority = "http://example.com" + o.SignInScheme = "TestScheme"; + o.ClientId = "Test Id"; + o.MetadataAddress = "http://example.com"; + o.CallbackPath = "/"; }, ex => Assert.Equal("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false.", ex.Message) ); } [Fact] - public void ThrowsWhenMetadataAddressIsNotHttps() + public Task ThrowsWhenMetadataAddressIsNotHttps() { - TestConfigurationException( - new OpenIdConnectOptions + return TestConfigurationException( + o => { - SignInScheme = "TestScheme", - ClientId = "Test Id", - MetadataAddress = "http://example.com" + o.SignInScheme = "TestScheme"; + o.ClientId = "Test Id"; + o.MetadataAddress = "http://example.com"; + o.CallbackPath = "/"; }, ex => Assert.Equal("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false.", ex.Message) ); } - private TestServer BuildTestServer(OpenIdConnectOptions options) + private TestServer BuildTestServer(Action options) { var builder = new WebHostBuilder() - .ConfigureServices(services => services.AddAuthentication()) - .Configure(app => app.UseOpenIdConnectAuthentication(options)); + .ConfigureServices(services => + { + services.AddCookieAuthentication(); + services.AddOpenIdConnectAuthentication(options); + }) + .Configure(app => app.UseAuthentication()); return new TestServer(builder); } - private void TestConfigurationException( - OpenIdConnectOptions options, + private async Task TestConfigurationException( + Action options, Action verifyException) where T : Exception { - var builder = new WebHostBuilder() - .ConfigureServices(services => services.AddAuthentication()) - .Configure(app => app.UseOpenIdConnectAuthentication(options)); - - var exception = Assert.Throws(() => - { - new TestServer(builder); - }); - + var exception = await Assert.ThrowsAsync(() => BuildTestServer(options).SendAsync(@"https://example.com")); verifyException(exception); } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index a212af649d..607e9bb623 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect private readonly RequestDelegate AppNotImpl = context => { throw new NotImplementedException("App"); }; [Fact] - public async Task OnMessageReceived_Skipped_NoMoreEventsRun() + public async Task OnMessageReceived_Skip_NoMoreEventsRun() { var messageReceived = false; var server = CreateServer(new OpenIdConnectEvents() @@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnMessageReceived = context => { messageReceived = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnTokenValidated = TokenNotImpl, @@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnTokenValidated_Skipped_NoMoreEventsRun() + public async Task OnTokenValidated_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenValidated = context => { tokenValidated = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnAuthorizationCodeReceived = CodeNotImpl, @@ -242,7 +242,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnAuthorizationCodeReceived_Skipped_NoMoreEventsRun() + public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -262,7 +262,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnAuthorizationCodeReceived = context => { codeReceived = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnTokenResponseReceived = TokenResponseNotImpl, @@ -391,7 +391,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnTokenResponseReceived_Skipped_NoMoreEventsRun() + public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -417,7 +417,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenResponseReceived = context => { tokenResponseReceived = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -558,7 +558,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnTokenValidatedBackchannel_Skipped_NoMoreEventsRun() + public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() { var messageReceived = false; var codeReceived = false; @@ -584,7 +584,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenValidated = context => { tokenValidated = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -725,7 +725,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnUserInformationReceived_Skipped_NoMoreEventsRun() + public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -757,7 +757,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnUserInformationReceived = context => { userInfoReceived = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnAuthenticationFailed = FailedNotImpl, @@ -910,7 +910,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnAuthenticationFailed_Skipped_NoMoreEventsRun() + public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -949,7 +949,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { authFailed = true; Assert.Equal("TestException", context.Exception.Message); - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnRemoteFailure = FailureNotImpl, @@ -1093,8 +1093,8 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect }; context.Ticket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(claims, context.Options.AuthenticationScheme)), - new AuthenticationProperties(), context.Options.AuthenticationScheme); + new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)), + new AuthenticationProperties(), context.Scheme.Name); context.HandleResponse(); return Task.FromResult(0); @@ -1128,7 +1128,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnRemoteFailure_Skipped_NoMoreEventsRun() + public async Task OnRemoteFailure_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -1174,7 +1174,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, OnTicketReceived = TicketNotImpl, @@ -1274,7 +1274,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnTicketReceived_Skipped_NoMoreEventsRun() + public async Task OnTicketReceived_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -1314,7 +1314,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTicketReceived = context => { ticektReceived = true; - context.SkipToNextMiddleware(); + context.Skip(); return Task.FromResult(0); }, @@ -1408,27 +1408,27 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddAuthentication(); - }) - .Configure(app => - { - app.UseCookieAuthentication(); - app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions() + services.AddCookieAuthentication(); + services.AddOpenIdConnectAuthentication(o => { - Events = events, - SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme, - ClientId = "ClientId", - GetClaimsFromUserInfoEndpoint = true, - Configuration = new OpenIdConnectConfiguration() + o.Events = events; + o.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.ClientId = "ClientId"; + o.GetClaimsFromUserInfoEndpoint = true; + o.Configuration = new OpenIdConnectConfiguration() { TokenEndpoint = "http://testhost/tokens", UserInfoEndpoint = "http://testhost/user", - }, - StateDataFormat = new TestStateDataFormat(), - SecurityTokenValidator = new TestTokenValidator(), - ProtocolValidator = new TestProtocolValidator(), - BackchannelHttpHandler = new TestBackchannel(), + }; + o.StateDataFormat = new TestStateDataFormat(); + o.SecurityTokenValidator = new TestTokenValidator(); + o.ProtocolValidator = new TestProtocolValidator(); + o.BackchannelHttpHandler = new TestBackchannel(); }); + }) + .Configure(app => + { + app.UseAuthentication(); app.Run(appCode); }); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs similarity index 69% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index a58d54b650..a3d7f5130f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -2,18 +2,25 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Linq; +using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Net; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { - public class OpenIdConnectMiddlewareTests + public class OpenIdConnectTests { static string noncePrefix = "OpenIdConnect." + "Nonce."; static string nonceDelimiter = "."; @@ -22,6 +29,27 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect const string Signin = "/signin"; const string Signout = "/signout"; + [Fact] + public void AddCanBindAgainstDefaultConfig() + { + var dic = new Dictionary + { + {"OpenIdConnect:ClientId", ""}, + {"OpenIdConnect:ClientSecret", ""}, + {"OpenIdConnect:Authority", ""} + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddOpenIdConnectAuthentication().AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(OpenIdConnectDefaults.AuthenticationScheme); + Assert.Equal("", options.ClientId); + Assert.Equal("", options.ClientSecret); + Assert.Equal("", options.Authority); + } + /// /// Tests RedirectForSignOutContext replaces the OpenIdConnectMesssage correctly. @@ -32,6 +60,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { var setting = new TestSettings(opt => { + opt.ClientId = "Test Id"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; opt.Configuration = new OpenIdConnectConfiguration { EndSessionEndpoint = "https://example.com/signout_test/signout_request" @@ -55,7 +85,14 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect [Fact] public async Task EndSessionRequestDoesNotIncludeTelemetryParametersWhenDisabled() { - var setting = new TestSettings(opt => opt.DisableTelemetry = true); + var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); + var setting = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Configuration = configuration; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.DisableTelemetry = true; + }); var server = setting.CreateTestServer(); @@ -65,19 +102,19 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); Assert.DoesNotContain(OpenIdConnectParameterNames.SkuTelemetry, res.Headers.Location.Query); Assert.DoesNotContain(OpenIdConnectParameterNames.VersionTelemetry, res.Headers.Location.Query); + setting.ValidateSignoutRedirect(transaction.Response.Headers.Location); } [Fact] public async Task SignOutWithDefaultRedirectUri() { var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); - var options = new OpenIdConnectOptions + var server = TestServerBuilder.CreateServer(o => { - Authority = TestServerBuilder.DefaultAuthority, - ClientId = "Test Id", - Configuration = configuration - }; - var server = TestServerBuilder.CreateServer(options); + o.Authority = TestServerBuilder.DefaultAuthority; + o.ClientId = "Test Id"; + o.Configuration = configuration; + }); var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -89,22 +126,23 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect string redirectUri; Assert.True(query.TryGetValue("post_logout_redirect_uri", out redirectUri)); - Assert.Equal(UrlEncoder.Default.Encode("https://example.com" + options.SignedOutCallbackPath), redirectUri, true); + Assert.Equal(UrlEncoder.Default.Encode("https://example.com/signout-callback-oidc"), redirectUri, true); } [Fact] public async Task SignOutWithCustomRedirectUri() { var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); - var options = new OpenIdConnectOptions + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("OIDCTest")); + var server = TestServerBuilder.CreateServer(o => { - Authority = TestServerBuilder.DefaultAuthority, - ClientId = "Test Id", - Configuration = configuration, - SignedOutCallbackPath = "/thelogout", - PostLogoutRedirectUri = "https://example.com/postlogout" - }; - var server = TestServerBuilder.CreateServer(options); + o.Authority = TestServerBuilder.DefaultAuthority; + o.ClientId = "Test Id"; + o.Configuration = configuration; + o.StateDataFormat = stateFormat; + o.SignedOutCallbackPath = "/thelogout"; + o.PostLogoutRedirectUri = "https://example.com/postlogout"; + }); var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -115,11 +153,11 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect string redirectUri; Assert.True(query.TryGetValue("post_logout_redirect_uri", out redirectUri)); - Assert.Equal(UrlEncoder.Default.Encode("https://example.com" + options.SignedOutCallbackPath), redirectUri, true); + Assert.Equal(UrlEncoder.Default.Encode("https://example.com/thelogout"), redirectUri, true); string state; Assert.True(query.TryGetValue("state", out state)); - var properties = options.StateDataFormat.Unprotect(state); + var properties = stateFormat.Unprotect(state); Assert.Equal("https://example.com/postlogout", properties.RedirectUri, true); } @@ -127,14 +165,15 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properites() { var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); - var options = new OpenIdConnectOptions + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("OIDCTest")); + var server = TestServerBuilder.CreateServer(o => { - Authority = TestServerBuilder.DefaultAuthority, - ClientId = "Test Id", - Configuration = configuration, - PostLogoutRedirectUri = "https://example.com/postlogout" - }; - var server = TestServerBuilder.CreateServer(options); + o.Authority = TestServerBuilder.DefaultAuthority; + o.StateDataFormat = stateFormat; + o.ClientId = "Test Id"; + o.Configuration = configuration; + o.PostLogoutRedirectUri = "https://example.com/postlogout"; + }); var transaction = await server.SendAsync("https://example.com/signout_with_specific_redirect_uri"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); @@ -145,19 +184,21 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect string redirectUri; Assert.True(query.TryGetValue("post_logout_redirect_uri", out redirectUri)); - Assert.Equal(UrlEncoder.Default.Encode("https://example.com" + options.SignedOutCallbackPath), redirectUri, true); + Assert.Equal(UrlEncoder.Default.Encode("https://example.com/signout-callback-oidc"), redirectUri, true); string state; Assert.True(query.TryGetValue("state", out state)); - var properties = options.StateDataFormat.Unprotect(state); + var properties = stateFormat.Unprotect(state); Assert.Equal("http://www.example.com/specific_redirect_uri", properties.RedirectUri, true); } [Fact] public async Task SignOut_WithMissingConfig_Throws() { - var setting = new TestSettings(opt => opt.Configuration = new OpenIdConnectConfiguration()); - + var setting = new TestSettings(opt => { + opt.ClientId = "Test Id"; + opt.Configuration = new OpenIdConnectConfiguration(); + }); var server = setting.CreateTestServer(); var exception = await Assert.ThrowsAsync(() => server.SendAsync(DefaultHost + TestServerBuilder.Signout)); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs index 5a672093ea..aa7f6179be 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -9,13 +9,12 @@ using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { internal class TestServerBuilder { @@ -38,12 +37,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public static OpenIdConnectOptions CreateOpenIdConnectOptions(Action update) { var options = CreateOpenIdConnectOptions(); - - if (update != null) - { - update(options); - } - + update?.Invoke(options); return options; } @@ -58,26 +52,20 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public static IConfigurationManager CreateDefaultOpenIdConnectConfigurationManager() => new StaticConfigurationManager(CreateDefaultOpenIdConnectConfiguration()); - public static TestServer CreateServer(OpenIdConnectOptions options) + public static TestServer CreateServer(Action options) { return CreateServer(options, handler: null, properties: null); } public static TestServer CreateServer( - OpenIdConnectOptions options, + Action options, Func handler, AuthenticationProperties properties) { var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme - }); - - app.UseOpenIdConnectAuthentication(options); - + app.UseAuthentication(); app.Use(async (context, next) => { var req = context.Request; @@ -85,11 +73,11 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect if (req.Path == new PathString(Challenge)) { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme); + await context.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme); } else if (req.Path == new PathString(ChallengeWithProperties)) { - await context.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, properties); + await context.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, properties); } else if (req.Path == new PathString(ChallengeWithOutContext)) { @@ -97,16 +85,15 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect } else if (req.Path == new PathString(Signin)) { - // REVIEW: this used to just be res.SignIn() - await context.Authentication.SignInAsync(OpenIdConnectDefaults.AuthenticationScheme, new ClaimsPrincipal()); + await context.SignInAsync(OpenIdConnectDefaults.AuthenticationScheme, new ClaimsPrincipal()); } else if (req.Path == new PathString(Signout)) { - await context.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); + await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); } else if (req.Path == new PathString("/signout_with_specific_redirect_uri")) { - await context.Authentication.SignOutAsync( + await context.SignOutAsync( OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties() { RedirectUri = "http://www.example.com/specific_redirect_uri" }); } @@ -122,8 +109,13 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect }) .ConfigureServices(services => { - services.AddAuthentication(); - services.Configure(authOptions => authOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); + services.AddAuthentication(o => + { + o.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + services.AddCookieAuthentication(); + services.AddOpenIdConnectAuthentication(options); }); return new TestServer(builder); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs index a7085966a4..609aed6f6a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Net.Http; using System.Threading.Tasks; using System.Xml.Linq; -using Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect; using Microsoft.AspNetCore.TestHost; namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index a3bea3ebe7..9d9e5537fe 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -9,19 +9,19 @@ using System.Reflection; using System.Text; using System.Text.Encodings.Web; using System.Xml.Linq; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.TestHost; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { /// /// This helper class is used to check that query string parameters are as expected. /// internal class TestSettings { - private readonly OpenIdConnectOptions _options; + private readonly Action _configureOptions; public TestSettings() : this(configure: null) { @@ -29,21 +29,18 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect public TestSettings(Action configure) { - _options = TestServerBuilder.CreateOpenIdConnectOptions(configure); + _configureOptions = o => + { + configure?.Invoke(o); + _options = o; + }; } - public TestSettings(OpenIdConnectOptions options) - { - _options = options; - } - - public OpenIdConnectOptions Options => _options; - public UrlEncoder Encoder => UrlEncoder.Default; public string ExpectedState { get; set; } - public TestServer CreateTestServer() => TestServerBuilder.CreateServer(Options); + public TestServer CreateTestServer(AuthenticationProperties properties = null) => TestServerBuilder.CreateServer(_configureOptions, handler: null, properties: properties); public IDictionary ValidateChallengeFormPost(string responseBody, params string[] parametersToValidate) { @@ -165,6 +162,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect } } + OpenIdConnectOptions _options = null; + private void ValidateExpectedAuthority(string absoluteUri, ICollection errors, OpenIdConnectRequestType requestType) { string expectedAuthority; @@ -212,8 +211,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect ValidateQueryParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET", actualQuery, errors, htmlEncoded); private void ValidateVersionTelemetry(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.VersionTelemetry, - typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualQuery, errors, htmlEncoded); + ValidateQueryParameter(OpenIdConnectParameterNames.VersionTelemetry, typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualQuery, errors, htmlEncoded); private void ValidateQueryParameter( string parameterName, @@ -241,4 +239,4 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs index 745c41350a..4f924172c6 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Net.Http; using System.Xml.Linq; -namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { internal class TestTransaction { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/SecureDataFormatTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/SecureDataFormatTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/DataHandler/SecureDataFormatTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/SecureDataFormatTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DataHandler/TicketSerializerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/DataHandler/TicketSerializerTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs index 028cf67607..fb7ea34436 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -1,14 +1,8 @@ // 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.Collections.Generic; using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -using Microsoft.AspNetCore.Http.Features.Authentication; using Xunit; namespace Microsoft.AspNetCore.Authentication @@ -126,62 +120,62 @@ namespace Microsoft.AspNetCore.Authentication } - public class TestAuthHandler : IAuthenticationHandler - { - private readonly AuthenticationProperties _props; - public TestAuthHandler(AuthenticationProperties props) - { - _props = props; - } + //public class TestAuthHandler : IAuthenticationHandler + //{ + // private readonly AuthenticationProperties _props; + // public TestAuthHandler(AuthenticationProperties props) + // { + // _props = props; + // } - public Task AuthenticateAsync(AuthenticateContext context) - { - context.Authenticated(new ClaimsPrincipal(), _props.Items, new Dictionary()); - return Task.FromResult(0); - } + // public Task AuthenticateAsync(AuthenticateContext context) + // { + // context.Authenticated(new ClaimsPrincipal(), _props.Items, new Dictionary()); + // return Task.FromResult(0); + // } - public Task ChallengeAsync(ChallengeContext context) - { - throw new NotImplementedException(); - } + // public Task ChallengeAsync(ChallengeContext context) + // { + // throw new NotImplementedException(); + // } - public void GetDescriptions(DescribeSchemesContext context) - { - throw new NotImplementedException(); - } + // public void GetDescriptions(DescribeSchemesContext context) + // { + // throw new NotImplementedException(); + // } - public Task SignInAsync(SignInContext context) - { - throw new NotImplementedException(); - } + // public Task SignInAsync(SignInContext context) + // { + // throw new NotImplementedException(); + // } - public Task SignOutAsync(SignOutContext context) - { - throw new NotImplementedException(); - } - } + // public Task SignOutAsync(SignOutContext context) + // { + // throw new NotImplementedException(); + // } + //} - [Fact] - public async Task CanGetTokenFromContext() - { - var props = new AuthenticationProperties(); - var tokens = new List(); - var tok1 = new AuthenticationToken { Name = "One", Value = "1" }; - var tok2 = new AuthenticationToken { Name = "Two", Value = "2" }; - var tok3 = new AuthenticationToken { Name = "Three", Value = "3" }; - tokens.Add(tok1); - tokens.Add(tok2); - tokens.Add(tok3); - props.StoreTokens(tokens); + //[Fact] + //public async Task CanGetTokenFromContext() + //{ + // var props = new AuthenticationProperties(); + // var tokens = new List(); + // var tok1 = new AuthenticationToken { Name = "One", Value = "1" }; + // var tok2 = new AuthenticationToken { Name = "Two", Value = "2" }; + // var tok3 = new AuthenticationToken { Name = "Three", Value = "3" }; + // tokens.Add(tok1); + // tokens.Add(tok2); + // tokens.Add(tok3); + // props.StoreTokens(tokens); - var context = new DefaultHttpContext(); - var handler = new TestAuthHandler(props); - context.Features.Set(new HttpAuthenticationFeature() { Handler = handler }); + // var context = new DefaultHttpContext(); + // var handler = new TestAuthHandler(props); + // context.Features.Set(new HttpAuthenticationFeature() { Handler = handler }); - Assert.Equal("1", await context.Authentication.GetTokenAsync("One")); - Assert.Equal("2", await context.Authentication.GetTokenAsync("Two")); - Assert.Equal("3", await context.Authentication.GetTokenAsync("Three")); - } + // Assert.Equal("1", await context.GetTokenAsync("One")); + // Assert.Equal("2", await context.GetTokenAsync("Two")); + // Assert.Equal("3", await context.GetTokenAsync("Three")); + //} } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Twitter/TwitterMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Twitter/TwitterMiddlewareTests.cs deleted file mode 100644 index 2ca2223b97..0000000000 --- a/test/Microsoft.AspNetCore.Authentication.Test/Twitter/TwitterMiddlewareTests.cs +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. - -using System; -using System.Net; -using System.Net.Http; -using System.Security.Claims; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.DependencyInjection; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication.Twitter -{ - public class TwitterMiddlewareTests - { - [Fact] - public async Task ChallengeWillTriggerApplyRedirectEvent() - { - var server = CreateServer(new TwitterOptions - { - ConsumerKey = "Test Consumer Key", - ConsumerSecret = "Test Consumer Secret", - Events = new TwitterEvents - { - OnRedirectToAuthorizationEndpoint = context => - { - context.Response.Redirect(context.RedirectUri + "&custom=test"); - return Task.FromResult(0); - } - }, - BackchannelHttpHandler = new TestHttpMessageHandler - { - Sender = req => - { - if (req.RequestUri.AbsoluteUri == "https://api.twitter.com/oauth/request_token") - { - return new HttpResponseMessage(HttpStatusCode.OK) - { - Content = - new StringContent("oauth_callback_confirmed=true&oauth_token=test_oauth_token&oauth_token_secret=test_oauth_token_secret", - Encoding.UTF8, - "application/x-www-form-urlencoded") - }; - } - return null; - } - } - }, - context => - { - // REVIEW: Gross - context.Authentication.ChallengeAsync("Twitter").GetAwaiter().GetResult(); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - var query = transaction.Response.Headers.Location.Query; - Assert.Contains("custom=test", query); - } - - [Fact] - public async Task BadSignInWillThrow() - { - var server = CreateServer(new TwitterOptions - { - ConsumerKey = "Test Consumer Key", - ConsumerSecret = "Test Consumer Secret" - }); - - // Send a bogus sign in - var error = await Assert.ThrowsAnyAsync(() => server.SendAsync("https://example.com/signin-twitter")); - Assert.Equal("Invalid state cookie.", error.GetBaseException().Message); - } - - [Fact] - public async Task SignInThrows() - { - var server = CreateServer(new TwitterOptions - { - ConsumerKey = "Test Consumer Key", - ConsumerSecret = "Test Consumer Secret" - }); - var transaction = await server.SendAsync("https://example.com/signIn"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - } - - [Fact] - public async Task SignOutThrows() - { - var server = CreateServer(new TwitterOptions - { - ConsumerKey = "Test Consumer Key", - ConsumerSecret = "Test Consumer Secret" - }); - var transaction = await server.SendAsync("https://example.com/signOut"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - } - - [Fact] - public async Task ForbidThrows() - { - var server = CreateServer(new TwitterOptions - { - ConsumerKey = "Test Consumer Key", - ConsumerSecret = "Test Consumer Secret" - }); - var transaction = await server.SendAsync("https://example.com/signOut"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - } - - - [Fact] - public async Task ChallengeWillTriggerRedirection() - { - var server = CreateServer(new TwitterOptions - { - ConsumerKey = "Test Consumer Key", - ConsumerSecret = "Test Consumer Secret", - BackchannelHttpHandler = new TestHttpMessageHandler - { - Sender = req => - { - if (req.RequestUri.AbsoluteUri == "https://api.twitter.com/oauth/request_token") - { - return new HttpResponseMessage(HttpStatusCode.OK) - { - Content = - new StringContent("oauth_callback_confirmed=true&oauth_token=test_oauth_token&oauth_token_secret=test_oauth_token_secret", - Encoding.UTF8, - "application/x-www-form-urlencoded") - }; - } - return null; - } - } - }, - context => - { - // REVIEW: gross - context.Authentication.ChallengeAsync("Twitter").GetAwaiter().GetResult(); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); - } - - private static TestServer CreateServer(TwitterOptions options, Func handler = null) - { - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AuthenticationScheme = "External" - }); - app.UseTwitterAuthentication(options); - app.Use(async (context, next) => - { - var req = context.Request; - var res = context.Response; - if (req.Path == new PathString("/signIn")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignInAsync("Twitter", new ClaimsPrincipal())); - } - else if (req.Path == new PathString("/signOut")) - { - await Assert.ThrowsAsync(() => context.Authentication.SignOutAsync("Twitter")); - } - else if (req.Path == new PathString("/forbid")) - { - await Assert.ThrowsAsync(() => context.Authentication.ForbidAsync("Twitter")); - } - else if (handler == null || !handler(context)) - { - await next(); - } - }); - }) - .ConfigureServices(services => - { - services.AddAuthentication(); - services.Configure(authOptions => - { - authOptions.SignInScheme = "External"; - }); - }); - return new TestServer(builder); - } - } -} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs new file mode 100644 index 0000000000..432227aed0 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -0,0 +1,249 @@ +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Http; +using System.Security.Claims; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.Twitter +{ + public class TwitterTests + { + [Fact] + public void AddCanBindAgainstDefaultConfig() + { + var dic = new Dictionary + { + {"Twitter:ConsumerKey", ""}, + {"Twitter:ConsumerSecret", ""}, + {"Twitter:BackchannelTimeout", "0.0:0:30"}, + //{"Twitter:CallbackPath", "/callbackpath"}, // PathString doesn't convert + {"Twitter:ClaimsIssuer", ""}, + {"Twitter:DisplayName", ""}, + {"Twitter:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Twitter:SaveTokens", "true"}, + {"Twitter:SendAppSecretProof", "true"}, + {"Twitter:SignInScheme", ""}, + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddTwitterAuthentication().AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(TwitterDefaults.AuthenticationScheme); + Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); + //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert + Assert.Equal("", options.ClaimsIssuer); + Assert.Equal("", options.ConsumerKey); + Assert.Equal("", options.ConsumerSecret); + Assert.Equal("", options.DisplayName); + Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); + Assert.True(options.SaveTokens); + Assert.Equal("", options.SignInScheme); + } + + [Fact] + public void AddWithDelegateIgnoresConfig() + { + var dic = new Dictionary + { + {"Twitter:ConsumerKey", ""}, + }; + var configurationBuilder = new ConfigurationBuilder(); + configurationBuilder.AddInMemoryCollection(dic); + var config = configurationBuilder.Build(); + var services = new ServiceCollection().AddTwitterAuthentication(o => o.SaveTokens = true).AddSingleton(config); + var sp = services.BuildServiceProvider(); + + var options = sp.GetRequiredService>().Get(TwitterDefaults.AuthenticationScheme); + Assert.Null(options.ConsumerKey); + Assert.True(options.SaveTokens); + } + + [Fact] + public async Task ChallengeWillTriggerApplyRedirectEvent() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + o.Events = new TwitterEvents + { + OnRedirectToAuthorizationEndpoint = context => + { + context.Response.Redirect(context.RedirectUri + "&custom=test"); + return Task.FromResult(0); + } + }; + o.BackchannelHttpHandler = new TestHttpMessageHandler + { + Sender = req => + { + if (req.RequestUri.AbsoluteUri == "https://api.twitter.com/oauth/request_token") + { + return new HttpResponseMessage(HttpStatusCode.OK) + { + Content = + new StringContent("oauth_callback_confirmed=true&oauth_token=test_oauth_token&oauth_token_secret=test_oauth_token_secret", + Encoding.UTF8, + "application/x-www-form-urlencoded") + }; + } + return null; + } + }; + }, + context => + { + // REVIEW: Gross + context.ChallengeAsync("Twitter").GetAwaiter().GetResult(); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + var query = transaction.Response.Headers.Location.Query; + Assert.Contains("custom=test", query); + } + + [Fact] + public async Task BadSignInWillThrow() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + }); + + // Send a bogus sign in + var error = await Assert.ThrowsAnyAsync(() => server.SendAsync("https://example.com/signin-twitter")); + Assert.Equal("Invalid state cookie.", error.GetBaseException().Message); + } + + [Fact] + public async Task SignInThrows() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + }); + var transaction = await server.SendAsync("https://example.com/signIn"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + [Fact] + public async Task SignOutThrows() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + }); + var transaction = await server.SendAsync("https://example.com/signOut"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + [Fact] + public async Task ForbidThrows() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + }); + var transaction = await server.SendAsync("https://example.com/signOut"); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + } + + + [Fact] + public async Task ChallengeWillTriggerRedirection() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + o.BackchannelHttpHandler = new TestHttpMessageHandler + { + Sender = req => + { + if (req.RequestUri.AbsoluteUri == "https://api.twitter.com/oauth/request_token") + { + return new HttpResponseMessage(HttpStatusCode.OK) + { + Content = + new StringContent("oauth_callback_confirmed=true&oauth_token=test_oauth_token&oauth_token_secret=test_oauth_token_secret", + Encoding.UTF8, + "application/x-www-form-urlencoded") + }; + } + return null; + } + }; + }, + context => + { + // REVIEW: gross + context.ChallengeAsync("Twitter").GetAwaiter().GetResult(); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + var location = transaction.Response.Headers.Location.AbsoluteUri; + Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); + } + + private static TestServer CreateServer(Action options, Func handler = null) + { + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Use(async (context, next) => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/signIn")) + { + await Assert.ThrowsAsync(() => context.SignInAsync("Twitter", new ClaimsPrincipal())); + } + else if (req.Path == new PathString("/signOut")) + { + await Assert.ThrowsAsync(() => context.SignOutAsync("Twitter")); + } + else if (req.Path == new PathString("/forbid")) + { + await Assert.ThrowsAsync(() => context.ForbidAsync("Twitter")); + } + else if (handler == null || !handler(context)) + { + await next(); + } + }); + }) + .ConfigureServices(services => + { + services.AddCookieAuthentication("External", _ => { }); + Action wrapOptions = o => + { + o.SignInScheme = "External"; + options(o); + }; + services.AddTwitterAuthentication(wrapOptions); + }); + return new TestServer(builder); + } + } +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index d9065add3a..c964221fbb 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -1,12 +1,10 @@  - netcoreapp2.0;net46 netcoreapp2.0 - @@ -16,9 +14,7 @@ - - diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 729c01630b..d2736ca0d7 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -1,23 +1,19 @@  - netcoreapp2.0;net46 netcoreapp2.0 - - - diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index 34d967617b..e45c7f6909 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -5,6 +5,7 @@ using System; using System.Security.Claims; using System.Security.Principal; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -239,7 +240,12 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddAuthentication(); + services.AddCookieAuthentication(o => + { + o.CookieName = "TestCookie"; + o.CookieHttpOnly = false; + o.CookieSecure = CookieSecurePolicy.None; + }); }) .Configure(app => { @@ -248,15 +254,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test HttpOnly = HttpOnlyPolicy.Always, Secure = CookieSecurePolicy.Always, }); - app.UseCookieAuthentication(new CookieAuthenticationOptions() - { - CookieName = "TestCookie", - CookieHttpOnly = false, - CookieSecure = CookieSecurePolicy.None, - }); + app.UseAuthentication(); app.Run(context => { - return context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, + return context.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("TestUser", "Cookies")))); }); }); @@ -279,7 +280,12 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddAuthentication(); + services.AddCookieAuthentication(o => + { + o.CookieName = "TestCookie"; + o.CookieHttpOnly = false; + o.CookieSecure = CookieSecurePolicy.None; + }); }) .Configure(app => { @@ -288,15 +294,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test HttpOnly = HttpOnlyPolicy.Always, Secure = CookieSecurePolicy.Always, }); - app.UseCookieAuthentication(new CookieAuthenticationOptions() - { - CookieName = "TestCookie", - CookieHttpOnly = false, - CookieSecure = CookieSecurePolicy.None, - }); + app.UseAuthentication(); app.Run(context => { - return context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, + return context.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity(new string('c', 1024 * 5), "Cookies")))); }); }); diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index b9155b4dfe..a972731ea5 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -1,14 +1,12 @@  - netcoreapp2.0;net46 netcoreapp2.0 true true - @@ -19,9 +17,7 @@ - - diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index 79288b026d..a06624facb 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -13,6 +13,8 @@ using System.Xml.Linq; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Net.Http.Headers; @@ -33,8 +35,8 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - CookieAuthenticationDefaults.AuthenticationType, "v2"); + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); var interopServer = TestServer.Create(app => { @@ -59,17 +61,14 @@ namespace Microsoft.Owin.Security.Interop var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions - { - DataProtectionProvider = dataProtection - }); + app.UseAuthentication(); app.Run(async context => { - var result = await context.Authentication.AuthenticateAsync("Cookies"); - await context.Response.WriteAsync(result.Identity.Name); + var result = await context.AuthenticateAsync("Cookies"); + await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); }); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); @@ -90,8 +89,8 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - CookieAuthenticationDefaults.AuthenticationType, "v2"); + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); var interopServer = TestServer.Create(app => { @@ -117,17 +116,14 @@ namespace Microsoft.Owin.Security.Interop var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions - { - DataProtectionProvider = dataProtection - }); + app.UseAuthentication(); app.Run(async context => { - var result = await context.Authentication.AuthenticateAsync("Cookies"); - await context.Response.WriteAsync(result.Identity.Name); + var result = await context.AuthenticateAsync("Cookies"); + await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); }); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); @@ -150,19 +146,16 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - CookieAuthenticationDefaults.AuthenticationType, "v2"); + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions - { - DataProtectionProvider = dataProtection - }); - app.Run(context => context.Authentication.SignInAsync("Cookies", user)); + app.UseAuthentication(); + app.Run(context => context.SignInAsync("Cookies", user)); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); @@ -200,19 +193,16 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - CookieAuthenticationDefaults.AuthenticationType, "v2"); + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions - { - DataProtectionProvider = dataProtection - }); - app.Run(context => context.Authentication.SignInAsync("Cookies", user)); + app.UseAuthentication(); + app.Run(context => context.SignInAsync("Cookies", user)); }) - .ConfigureServices(services => services.AddAuthentication()); + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs index 7b2d261bbf..b14ea0d74e 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -58,7 +58,7 @@ namespace Microsoft.Owin.Security.Interop.Test var expires = DateTime.Today; var issued = new DateTime(1979, 11, 11); - var properties = new AspNetCore.Http.Authentication.AuthenticationProperties(); + var properties = new AspNetCore.Authentication.AuthenticationProperties(); properties.IsPersistent = true; properties.RedirectUri = "/redirect"; properties.Items["key"] = "value"; From da30688fa9d3f1f83b3369fde41e750790457231 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 19 Apr 2017 13:58:38 -0700 Subject: [PATCH 709/900] Disable api checks for now --- .../Microsoft.AspNetCore.Authentication.Cookies.csproj | 1 + .../Microsoft.AspNetCore.Authentication.JwtBearer.csproj | 1 + .../Microsoft.AspNetCore.Authentication.OAuth.csproj | 1 + .../Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj | 1 + .../Microsoft.AspNetCore.Authentication.Twitter.csproj | 1 + 5 files changed, 5 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 3f2f0ee8d3..a7da8e72ce 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -9,6 +9,7 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security + false diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 89e7ef9c39..9d6c494422 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -6,6 +6,7 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security + false diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index c0e7569acb..73b5140edf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -8,6 +8,7 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security + false diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index a5e4c8b0cb..773bc41d64 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -6,6 +6,7 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security + false diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index c0b773345d..3d13a3d07a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -8,6 +8,7 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security + false From bb73898ca23a257a07f23ad56eb57c0f01767603 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 19 Apr 2017 14:14:46 -0700 Subject: [PATCH 710/900] Disable api check --- .../Microsoft.AspNetCore.Authentication.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index d4335f6d4a..07936ed258 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -8,6 +8,7 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security + false From 7fd15a2ae6b664882be44953862cd0e480e06c3b Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 19 Apr 2017 14:32:28 -0700 Subject: [PATCH 711/900] Fix tests --- .../CookieInteropTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index a06624facb..ae5e6f0183 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -35,7 +35,7 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", // full name of the ASP.NET Core type + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); var interopServer = TestServer.Create(app => @@ -89,7 +89,7 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", // full name of the ASP.NET Core type + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); var interopServer = TestServer.Create(app => @@ -146,7 +146,7 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", // full name of the ASP.NET Core type + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); var builder = new WebHostBuilder() @@ -193,7 +193,7 @@ namespace Microsoft.Owin.Security.Interop var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", // full name of the ASP.NET Core type + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); var builder = new WebHostBuilder() From 4f206558505b32c5ec0a686764ec30a8f912860e Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 20 Apr 2017 14:19:32 -0700 Subject: [PATCH 712/900] Set DisplayName for auth --- samples/SocialSample/Startup.cs | 2 +- .../FacebookExtensions.cs | 2 +- .../GoogleExtensions.cs | 2 +- .../MicrosoftAccountExtensions.cs | 2 +- .../OAuthExtensions.cs | 2 +- .../OpenIdConnectExtensions.cs | 2 +- .../TwitterExtensions.cs | 2 +- .../AuthenticationServiceCollectionExtensions.cs | 10 ++++++++-- .../CookieTests.cs | 12 ++++++++++++ .../DynamicSchemeTests.cs | 2 +- .../FacebookTests.cs | 12 ++++++++++++ .../GoogleTests.cs | 12 ++++++++++++ .../JwtBearerTests.cs | 12 ++++++++++++ .../MicrosoftAccountTests.cs | 12 ++++++++++++ .../OAuthTests.cs | 12 ++++++++++++ .../TwitterTests.cs | 12 ++++++++++++ 16 files changed, 100 insertions(+), 10 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 3f64d813da..7c1dd9d8db 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -238,7 +238,7 @@ namespace SocialSample foreach (var provider in await schemeProvider.GetAllSchemesAsync()) { // REVIEW: we lost access to display name (which is buried in the handler options) - await context.Response.WriteAsync("" + (provider.Name ?? "(suppressed)") + "
"); + await context.Response.WriteAsync("" + (provider.DisplayName ?? "(suppressed)") + "
"); } await context.Response.WriteAsync(""); }); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index bcfa95c0ad..79d9ac66ca 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, configureOptions); + return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index d85e3a2d6f..420d14030a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, configureOptions); + return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 1f8884ab2e..509016ff29 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, configureOptions); + return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index aa7c59f03f..6fd0f57f4b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -10,6 +10,6 @@ namespace Microsoft.AspNetCore.Builder public static class OAuthExtensions { public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) => - services.AddScheme>(authenticationScheme, configureOptions); + services.AddScheme>(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index 89581b201f..64737a9ad8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, configureOptions); + return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index 2170be9028..1e126d4c4a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, configureOptions); + return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 074f45b5fb..0315562ffb 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -45,7 +45,7 @@ namespace Microsoft.Extensions.DependencyInjection return services; } - public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, Action configureScheme, Action configureOptions) + public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureScheme, Action configureOptions) where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler { @@ -53,6 +53,7 @@ namespace Microsoft.Extensions.DependencyInjection { o.AddScheme(authenticationScheme, scheme => { scheme.HandlerType = typeof(THandler); + scheme.DisplayName = displayName; configureScheme?.Invoke(scheme); }); }); @@ -67,6 +68,11 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, Action configureOptions) where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler - => services.AddScheme(authenticationScheme, configureScheme: null, configureOptions: configureOptions); + => services.AddScheme(authenticationScheme, displayName: null, configureScheme: null, configureOptions: configureOptions); + + public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureOptions) + where TOptions : AuthenticationSchemeOptions, new() + where THandler : AuthenticationHandler + => services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 55dd054269..419d82493d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -26,6 +26,18 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { private TestClock _clock = new TestClock(); + [Fact] + public async Task VerifySchemeDefaults() + { + var services = new ServiceCollection().AddCookieAuthentication(); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync(CookieAuthenticationDefaults.AuthenticationScheme); + Assert.NotNull(scheme); + Assert.Equal("CookieAuthenticationHandler", scheme.HandlerType.Name); + Assert.Null(scheme.DisplayName); + } + [Fact] public async Task NormalRequestPassesThrough() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs index a152c735bb..d239d85f81 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs @@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.Authentication { var name = remainder.Value.Substring(1); var auth = context.RequestServices.GetRequiredService(); - var scheme = new AuthenticationScheme(name, typeof(TestHandler)); + var scheme = new AuthenticationScheme(name, name, typeof(TestHandler)); auth.AddScheme(scheme); } else if (req.Path.StartsWithSegments(new PathString("/auth"), out remainder)) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 79066e48b5..edd9eb5788 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -27,6 +27,18 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { public class FacebookTests { + [Fact] + public async Task VerifySchemeDefaults() + { + var services = new ServiceCollection().AddFacebookAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync(FacebookDefaults.AuthenticationScheme); + Assert.NotNull(scheme); + Assert.Equal("FacebookHandler", scheme.HandlerType.Name); + Assert.Equal(FacebookDefaults.AuthenticationScheme, scheme.DisplayName); + } + [Fact] public void AddCanBindAgainstDefaultConfig() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 77ddcc7efc..0ab3e44938 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -26,6 +26,18 @@ namespace Microsoft.AspNetCore.Authentication.Google { public class GoogleTests { + [Fact] + public async Task VerifySchemeDefaults() + { + var services = new ServiceCollection().AddGoogleAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync(GoogleDefaults.AuthenticationScheme); + Assert.NotNull(scheme); + Assert.Equal("GoogleHandler", scheme.HandlerType.Name); + Assert.Equal(GoogleDefaults.AuthenticationScheme, scheme.DisplayName); + } + [Fact] public void AddCanBindAgainstDefaultConfig() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 08098622ca..42efe00dd3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -26,6 +26,18 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class JwtBearerTests { + [Fact] + public async Task VerifySchemeDefaults() + { + var services = new ServiceCollection().AddJwtBearerAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync(JwtBearerDefaults.AuthenticationScheme); + Assert.NotNull(scheme); + Assert.Equal("JwtBearerHandler", scheme.HandlerType.Name); + Assert.Null(scheme.DisplayName); + } + [Fact] public void AddCanBindAgainstDefaultConfig() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 26110e9fee..1f0f394f3c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -27,6 +27,18 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { public class MicrosoftAccountTests { + [Fact] + public async Task VerifySchemeDefaults() + { + var services = new ServiceCollection().AddMicrosoftAccountAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync(MicrosoftAccountDefaults.AuthenticationScheme); + Assert.NotNull(scheme); + Assert.Equal("MicrosoftAccountHandler", scheme.HandlerType.Name); + Assert.Equal(MicrosoftAccountDefaults.AuthenticationScheme, scheme.DisplayName); + } + [Fact] public void AddCanBindAgainstDefaultConfig() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 95c086c805..dd48f7c956 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -15,6 +15,18 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { public class OAuthTests { + [Fact] + public async Task VerifySchemeDefaults() + { + var services = new ServiceCollection().AddOAuthAuthentication("oauth", o => { }); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync("oauth"); + Assert.NotNull(scheme); + Assert.Equal("OAuthHandler`1", scheme.HandlerType.Name); + Assert.Equal("oauth", scheme.DisplayName); + } + [Fact] public async Task ThrowsIfClientIdMissing() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 432227aed0..9993559f69 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -20,6 +20,18 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { public class TwitterTests { + [Fact] + public async Task VerifySchemeDefaults() + { + var services = new ServiceCollection().AddTwitterAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync(TwitterDefaults.AuthenticationScheme); + Assert.NotNull(scheme); + Assert.Equal("TwitterHandler", scheme.HandlerType.Name); + Assert.Equal(TwitterDefaults.AuthenticationScheme, scheme.DisplayName); + } + [Fact] public void AddCanBindAgainstDefaultConfig() { From 254eb82ee14f24286598af20a782acab2285029a Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Mon, 24 Apr 2017 18:11:57 -0700 Subject: [PATCH 713/900] Update API Check related files React to aspnet/BuildTools#238 --- .../{baseline.net45.json => baseline.netframework.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Microsoft.Owin.Security.Interop/{baseline.net45.json => baseline.netframework.json} (100%) diff --git a/src/Microsoft.Owin.Security.Interop/baseline.net45.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json similarity index 100% rename from src/Microsoft.Owin.Security.Interop/baseline.net45.json rename to src/Microsoft.Owin.Security.Interop/baseline.netframework.json From 4b9f57b3b372cc1d921188bf3013069da49616d3 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 25 Apr 2017 11:29:03 -0700 Subject: [PATCH 714/900] Temporarily disable DotNetCliToolReference in samples until aspnet/Universe#506 is resolved --- .../OpenIdConnect.AzureAdSample.csproj | 3 ++- samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index a37c3659da..65d0ef7400 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -20,7 +20,8 @@ - +
diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 74661c2f32..41bf8c0efb 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -22,7 +22,9 @@ - + From 0cc0a46b749eb1d74129582ec4d6078e876f3fff Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Apr 2017 11:04:10 -0700 Subject: [PATCH 715/900] Use Bundled NETStandard.Library \ NETCoreApp versions instead of explicitly specifying one --- build/common.props | 2 +- build/dependencies.props | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build/common.props b/build/common.props index 9c5464a54c..3f55ba5b33 100644 --- a/build/common.props +++ b/build/common.props @@ -17,7 +17,7 @@ - + diff --git a/build/dependencies.props b/build/dependencies.props index b9ac0f5f05..2c8cbafc5f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -6,10 +6,8 @@ 2.1.3 2.0.0-* 10.0.1 - 1.6.1 3.0.1 - 2.0.0-* 15.0.0 2.2.0 - \ No newline at end of file + From 98e517de43a30400a0e89fd74914d5929c764f7f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Apr 2017 22:05:23 -0700 Subject: [PATCH 716/900] Branching for 2.0.0-preview1 --- NuGet.config | 4 ++-- build.ps1 | 2 +- build.sh | 2 +- build/dependencies.props | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NuGet.config b/NuGet.config index 93f1ac47df..fa4304af9c 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..225b1fe450 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview1.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..702b25c636 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview1.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi diff --git a/build/dependencies.props b/build/dependencies.props index 2c8cbafc5f..5d7f9bb688 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 2.0.0-* + 2.0.0-preview1-* 4.3.0 3.13.8 2.1.3 From 998767043abf8c94849991031d9013c1b4629159 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 26 Apr 2017 07:13:36 -0700 Subject: [PATCH 717/900] Updating package version to preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 44cb2290b9..0b2b8e0010 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview1 + preview2 \ No newline at end of file From e17b275d92293c46cabd7db8816c5240f3be8736 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 28 Apr 2017 11:51:56 -0700 Subject: [PATCH 718/900] Revert "Temporarily disable DotNetCliToolReference in samples until aspnet/Universe#506 is resolved" This reverts commit 4b9f57b3b372cc1d921188bf3013069da49616d3. --- .../OpenIdConnect.AzureAdSample.csproj | 3 +-- samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 65d0ef7400..a37c3659da 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -20,8 +20,7 @@ - + diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 41bf8c0efb..74661c2f32 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -22,9 +22,7 @@ - + From c0f4a211e46a587c0d26c1a742a65b4a1fcb9fea Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 1 May 2017 12:40:12 -0700 Subject: [PATCH 719/900] Use the bundled NETStandard.Library package in netstandard targeting libraries --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index 5d7f9bb688..77c4b3d710 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -6,6 +6,7 @@ 2.1.3 2.0.0-* 10.0.1 + $(BundledNETStandardPackageVersion) 3.0.1 15.0.0 2.2.0 From d84abf1fe6c39729df4cd485a7ccd4b72c98e10f Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 4 May 2017 19:26:44 -0700 Subject: [PATCH 720/900] Migrate to netcoreapp2.0 (#1202) * Migrate to netcoreapp2.0, remove Microsoft.Owin.Security.Interop & tests. * Remove net45 baselines --- Security.sln | 74 +- build/dependencies.props | 2 +- build/repo.props | 1 - samples/CookieSample/CookieSample.csproj | 4 +- .../CookieSessionSample.csproj | 4 +- .../JwtBearerSample/JwtBearerSample.csproj | 4 +- .../OpenIdConnect.AzureAdSample.csproj | 2 +- .../OpenIdConnectSample.csproj | 2 +- samples/SocialSample/SocialSample.csproj | 2 +- ...t.AspNetCore.Authentication.Cookies.csproj | 2 +- .../baseline.net45.json | 1661 ---------- ....AspNetCore.Authentication.Facebook.csproj | 2 +- .../baseline.net45.json | 453 --- ...ft.AspNetCore.Authentication.Google.csproj | 2 +- .../baseline.net45.json | 291 -- ...AspNetCore.Authentication.JwtBearer.csproj | 2 +- .../baseline.net45.json | 976 ------ ...ore.Authentication.MicrosoftAccount.csproj | 2 +- .../baseline.net45.json | 256 -- ...oft.AspNetCore.Authentication.OAuth.csproj | 2 +- .../baseline.net45.json | 955 ------ ...etCore.Authentication.OpenIdConnect.csproj | 2 +- .../baseline.net45.json | 2005 ------------ ...t.AspNetCore.Authentication.Twitter.csproj | 2 +- .../baseline.net45.json | 848 ----- ...Microsoft.AspNetCore.Authentication.csproj | 2 +- .../baseline.net45.json | 2897 ----------------- .../Microsoft.AspNetCore.Authorization.csproj | 2 +- .../baseline.net45.json | 1593 --------- .../Microsoft.AspNetCore.CookiePolicy.csproj | 2 +- .../baseline.net45.json | 392 --- .../AspNetTicketDataFormat.cs | 17 - .../AspNetTicketSerializer.cs | 220 -- .../ChunkingCookieManager.cs | 281 -- .../Constants.cs | 13 - .../DataProtectorShim.cs | 31 - .../Microsoft.Owin.Security.Interop.csproj | 18 - .../Properties/AssemblyInfo.cs | 8 - .../baseline.netframework.json | 373 --- ...soft.AspNetCore.Authentication.Test.csproj | 3 +- ...osoft.AspNetCore.Authorization.Test.csproj | 3 +- ....ChunkingCookieManager.Sources.Test.csproj | 3 +- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 3 +- .../CookieInteropTests.cs | 332 -- ...icrosoft.Owin.Security.Interop.Test.csproj | 28 - .../TicketInteropTests.cs | 91 - 46 files changed, 43 insertions(+), 13825 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authorization/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json delete mode 100644 src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/Constants.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj delete mode 100644 src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/baseline.netframework.json delete mode 100644 test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs delete mode 100644 test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj delete mode 100644 test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs diff --git a/Security.sln b/Security.sln index 81d0cc4b9c..157849c911 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.0 +VisualStudioVersion = 15.0.26403.7 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -46,10 +46,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtBearerSample", "samples\JwtBearerSample\JwtBearerSample.csproj", "{D399B84F-591B-4E98-92BA-B0F63E7B6957}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Owin.Security.Interop", "src\Microsoft.Owin.Security.Interop\Microsoft.Owin.Security.Interop.csproj", "{A7922DD8-09F1-43E4-938B-CC523EA08898}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Owin.Security.Interop.Test", "test\Microsoft.Owin.Security.Interop.Test\Microsoft.Owin.Security.Interop.Test.csproj", "{A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenIdConnect.AzureAdSample", "samples\OpenIdConnect.AzureAdSample\OpenIdConnect.AzureAdSample.csproj", "{3A7AD414-EBDE-4F92-B307-4E8F19B6117E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test", "test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj", "{51563775-C659-4907-9BAF-9995BAB87D01}" @@ -140,6 +136,22 @@ Global {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|x64.Build.0 = Release|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|x86.ActiveCfg = Release|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|x86.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x64.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x64.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x86.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x86.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Any CPU.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x64.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x64.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x86.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x86.Build.0 = Release|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|Any CPU.Build.0 = Debug|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -348,38 +360,6 @@ Global {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x64.Build.0 = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.ActiveCfg = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.Build.0 = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x64.ActiveCfg = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x64.Build.0 = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.ActiveCfg = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.Build.0 = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.Build.0 = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x64.ActiveCfg = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x64.Build.0 = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.ActiveCfg = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.Build.0 = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x64.ActiveCfg = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x64.Build.0 = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.ActiveCfg = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.Build.0 = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.Build.0 = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x64.ActiveCfg = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x64.Build.0 = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.ActiveCfg = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.Build.0 = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.Build.0 = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -412,22 +392,6 @@ Global {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x64.Build.0 = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.ActiveCfg = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.Build.0 = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x64.ActiveCfg = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x64.Build.0 = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x86.ActiveCfg = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x86.Build.0 = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Any CPU.Build.0 = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x64.ActiveCfg = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x64.Build.0 = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x86.ActiveCfg = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -438,6 +402,7 @@ Global {19711880-46DA-4A26-9E0F-9B2E41D27651} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {FC152CC4-054B-457E-8D91-389C5DE3C561} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {76579C39-B829-490D-B8BE-1BD35FE8412E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} @@ -451,10 +416,7 @@ Global {1790E052-646F-4529-B90E-6FEA95520D69} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {2755BFE5-7421-4A31-A644-F817DF5CAA98} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {D399B84F-591B-4E98-92BA-B0F63E7B6957} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} - {A7922DD8-09F1-43E4-938B-CC523EA08898} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} EndGlobalSection EndGlobal diff --git a/build/dependencies.props b/build/dependencies.props index 77c4b3d710..5203ebced3 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 4.3.0 3.13.8 2.1.3 - 2.0.0-* + 2.1.0-* 10.0.1 $(BundledNETStandardPackageVersion) 3.0.1 diff --git a/build/repo.props b/build/repo.props index d4bab3eebd..396aed1f53 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,5 +1,4 @@ - diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 9fd7e9412c..27fa4ca17b 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,9 +1,9 @@ - + - net46;netcoreapp2.0 + netcoreapp2.0 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index e4a42b8c4d..2a838df7e4 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,9 +1,9 @@ - + - net46;netcoreapp2.0 + netcoreapp2.0 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 1f93103294..86b04d587c 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,9 +1,9 @@ - + - net46;netcoreapp2.0 + netcoreapp2.0 aspnet5-JwtBearerSample-20151210102827 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 65d0ef7400..274fe9afad 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -3,7 +3,7 @@ - net46;netcoreapp2.0 + netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 41bf8c0efb..1520728985 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -3,7 +3,7 @@ - net46;netcoreapp2.0 + netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index fe63ab5ca0..e0336cc0e3 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -3,7 +3,7 @@ - net46;netcoreapp2.0 + netcoreapp2.0 aspnet5-SocialSample-20151210111056 diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index a7da8e72ce..a5728fbabc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to use cookie based authentication. - netstandard1.3 + netcoreapp2.0 $(DefineConstants);SECURITY $(NoWarn);CS1591 true diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json deleted file mode 100644 index 56e48d3fed..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json +++ /dev/null @@ -1,1661 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseCookieAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseCookieAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "ImplementedInterfaces": [ - "Microsoft.Extensions.Options.IOptions" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_CookieName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieDomain", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieDomain", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookiePath", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookiePath", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieHttpOnly", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieHttpOnly", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieSecure", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieSecure", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_DataProtectionProvider", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_DataProtectionProvider", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ExpireTimeSpan", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ExpireTimeSpan", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SlidingExpiration", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SlidingExpiration", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_LoginPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_LoginPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_LogoutPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_LogoutPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessDeniedPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AccessDeniedPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ReturnUrlParameter", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ReturnUrlParameter", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TicketDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TicketDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieManager", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieManager", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SessionStore", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SessionStore", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_ChunkSize", - "Parameters": [], - "ReturnType": "System.Nullable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ChunkSize", - "Parameters": [ - { - "Name": "value", - "Type": "System.Nullable" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ThrowForPartialCookies", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ThrowForPartialCookies", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetRequestCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AppendResponseCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "value", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "DeleteCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "CookiePrefix", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "LoginPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "LogoutPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessDeniedPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "ReturnUrlParameter", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Cookies\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "urlEncoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetRequestCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AppendResponseCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "value", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "DeleteCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "StoreAsync", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RenewAsync", - "Parameters": [ - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RetrieveAsync", - "Parameters": [ - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RemoveAsync", - "Parameters": [ - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnValidatePrincipal", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnValidatePrincipal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnSigningIn", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnSigningIn", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnSignedIn", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnSignedIn", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnSigningOut", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnSigningOut", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToLogin", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToLogin", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToAccessDenied", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToAccessDenied", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToLogout", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToLogout", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToReturnUrl", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToReturnUrl", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ValidatePrincipal", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignedIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogout", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogin", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToReturnUrl", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAccessDenied", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RedirectUri", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "redirectUri", - "Type": "System.String" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" - }, - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieOptions", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieOptions", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" - }, - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "cookieOptions", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_CookieOptions", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieOptions", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "cookieOptions", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ShouldRenew", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ShouldRenew", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ReplacePrincipal", - "Parameters": [ - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RejectPrincipal", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "ValidatePrincipal", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignedIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogout", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogin", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToReturnUrl", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAccessDenied", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index 8f46ff169a..19ec83413c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json deleted file mode 100644 index 1e070fc7ff..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json +++ /dev/null @@ -1,453 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Facebook\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookHelper", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetAgeRangeMin", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetAgeRangeMax", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetBirthday", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetFirstName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetGender", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLastName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLink", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLocation", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLocale", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetMiddleName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTimeZone", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseFacebookAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseFacebookAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.FacebookOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.FacebookOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AppId", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AppId", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AppSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AppSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SendAppSecretProof", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SendAppSecretProof", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Fields", - "Parameters": [], - "ReturnType": "System.Collections.Generic.ICollection", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index 7b6c9ee5df..e403fe4a95 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -4,7 +4,7 @@ ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json deleted file mode 100644 index 647633afa8..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json +++ /dev/null @@ -1,291 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Google\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetGivenName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetFamilyName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetProfile", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.GoogleAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseGoogleAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseGoogleAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.GoogleOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.GoogleOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AccessType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AccessType", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 9d6c494422..05bdd41313 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. - net46;netstandard1.4 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json deleted file mode 100644 index 37e18e53ed..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json +++ /dev/null @@ -1,976 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Bearer\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Exception", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Exception", - "Parameters": [ - { - "Name": "value", - "Type": "System.Exception" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.JwtBearerOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Challenge", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthenticateFailure", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticateFailure", - "Parameters": [ - { - "Name": "value", - "Type": "System.Exception" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Error", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Error", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ErrorDescription", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ErrorDescription", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ErrorUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ErrorUri", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnAuthenticationFailed", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnAuthenticationFailed", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnMessageReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnMessageReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnTokenValidated", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTokenValidated", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnChallenge", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnChallenge", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Challenge", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Token", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Token", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_SecurityToken", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Tokens.SecurityToken", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SecurityToken", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Tokens.SecurityToken" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseJwtBearerAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseJwtBearerAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.JwtBearerOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_RequireHttpsMetadata", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RequireHttpsMetadata", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_MetadataAddress", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_MetadataAddress", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Authority", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Authority", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Audience", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Audience", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Challenge", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Challenge", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_BackchannelHttpHandler", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpMessageHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelHttpHandler", - "Parameters": [ - { - "Name": "value", - "Type": "System.Net.Http.HttpMessageHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_BackchannelTimeout", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelTimeout", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Configuration", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Configuration", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ConfigurationManager", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.IConfigurationManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ConfigurationManager", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.IConfigurationManager" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RefreshOnIssuerKeyNotFound", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RefreshOnIssuerKeyNotFound", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SecurityTokenValidators", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenValidationParameters", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Tokens.TokenValidationParameters", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenValidationParameters", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Tokens.TokenValidationParameters" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SaveToken", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SaveToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_IncludeErrorDetails", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_IncludeErrorDetails", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 5b8263c9c1..4d91e0da1e 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json deleted file mode 100644 index 06b3cd0d53..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json +++ /dev/null @@ -1,256 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Microsoft\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDisplayName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetGivenName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetSurname", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.MicrosoftAccountAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseMicrosoftAccountAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseMicrosoftAccountAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 73b5140edf..5fb75ead95 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json deleted file mode 100644 index d485aedb17..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json +++ /dev/null @@ -1,955 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ExchangeCodeAsync", - "Parameters": [ - { - "Name": "code", - "Type": "System.String" - }, - { - "Name": "redirectUri", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateTicketAsync", - "Parameters": [ - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokens", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleUnauthorizedAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "BuildChallengeUrl", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "redirectUri", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "FormatScope", - "Parameters": [], - "ReturnType": "System.String", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.OAuthOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "New": true, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.OAuthOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "Success", - "Parameters": [ - { - "Name": "response", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Failed", - "Parameters": [ - { - "Name": "error", - "Type": "System.Exception" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Response", - "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Response", - "Parameters": [ - { - "Name": "value", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AccessToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenType", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RefreshToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RefreshToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ExpiresIn", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ExpiresIn", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Error", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Error", - "Parameters": [ - { - "Name": "value", - "Type": "System.Exception" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_User", - "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenResponse", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RefreshToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ExpiresIn", - "Parameters": [], - "ReturnType": "System.Nullable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Ticket", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Ticket", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Identity", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsIdentity", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - }, - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "tokens", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" - } - ], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - }, - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "tokens", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" - }, - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnCreatingTicket", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnCreatingTicket", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToAuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "redirectUri", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseOAuthAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseOAuthAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.OAuthOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_ClientId", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientId", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClientSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthorizationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_UserInformationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Scope", - "Parameters": [], - "ReturnType": "System.Collections.Generic.ICollection", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_StateDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_StateDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 773bc41d64..aab8833d28 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. - net46;netstandard1.4 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json deleted file mode 100644 index 64cb79487d..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json +++ /dev/null @@ -1,2005 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthenticationPropertiesKey", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "Caption", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "CookieNoncePrefix", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "RedirectUriForCodePropertiesKey", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "UserstatePropertiesKey", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"OpenIdConnect\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HtmlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteSignOutAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", - "Parameters": [ - { - "Name": "signout", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleUnauthorizedAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedeemAuthorizationCodeAsync", - "Parameters": [ - { - "Name": "tokenEndpointRequest", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetUserInformationAsync", - "Parameters": [ - { - "Name": "message", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - }, - { - "Name": "jwt", - "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "htmlEncoder", - "Type": "System.Text.Encodings.Web.HtmlEncoder" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HtmlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "services", - "Type": "System.IServiceProvider" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "htmlEncoder", - "Type": "System.Text.Encodings.Web.HtmlEncoder" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", - "Visibility": "Public", - "Kind": "Enumeration", - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "RedirectGet", - "Parameters": [], - "GenericParameter": [], - "Literal": "0" - }, - { - "Kind": "Field", - "Name": "FormPost", - "Parameters": [], - "GenericParameter": [], - "Literal": "1" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Exception", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Exception", - "Parameters": [ - { - "Name": "value", - "Type": "System.Exception" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_JwtSecurityToken", - "Parameters": [], - "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_JwtSecurityToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpointRequest", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpointRequest", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpointResponse", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpointResponse", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HandledCodeRedemption", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleCodeRedemption", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleCodeRedemption", - "Parameters": [ - { - "Name": "accessToken", - "Type": "System.String" - }, - { - "Name": "idToken", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleCodeRedemption", - "Parameters": [ - { - "Name": "tokenEndpointResponse", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ProtocolMessage", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ProtocolMessage", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizationCodeReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToIdentityProvider", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToIdentityProviderForSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RemoteSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenResponseReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UserInformationReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Token", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Token", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnAuthenticationFailed", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnAuthenticationFailed", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnAuthorizationCodeReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnAuthorizationCodeReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnMessageReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnMessageReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToIdentityProvider", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToIdentityProvider", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToIdentityProviderForSignOut", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToIdentityProviderForSignOut", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRemoteSignOut", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRemoteSignOut", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnTokenResponseReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTokenResponseReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnTokenValidated", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTokenValidated", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnUserInformationReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnUserInformationReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizationCodeReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToIdentityProvider", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToIdentityProviderForSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RemoteSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenResponseReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UserInformationReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - }, - { - "Name": "message", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpointResponse", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpointResponse", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SecurityToken", - "Parameters": [], - "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SecurityToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpointResponse", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpointResponse", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Nonce", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Nonce", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_User", - "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_User", - "Parameters": [ - { - "Name": "value", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseOpenIdConnectAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseOpenIdConnectAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Authority", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Authority", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClientId", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientId", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClientSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Configuration", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Configuration", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ConfigurationManager", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.IConfigurationManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ConfigurationManager", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.IConfigurationManager" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_GetClaimsFromUserInfoEndpoint", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_GetClaimsFromUserInfoEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RequireHttpsMetadata", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RequireHttpsMetadata", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_MetadataAddress", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_MetadataAddress", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ProtocolValidator", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolValidator", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ProtocolValidator", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolValidator" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_PostLogoutRedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PostLogoutRedirectUri", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RefreshOnIssuerKeyNotFound", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RefreshOnIssuerKeyNotFound", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthenticationMethod", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticationMethod", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Resource", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Resource", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ResponseMode", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ResponseMode", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ResponseType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ResponseType", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Scope", - "Parameters": [], - "ReturnType": "System.Collections.Generic.ICollection", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RemoteSignOutPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RemoteSignOutPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SignOutScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignOutScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_StateDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_StateDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_StringDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_StringDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SecurityTokenValidator", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Tokens.ISecurityTokenValidator", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SecurityTokenValidator", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Tokens.ISecurityTokenValidator" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenValidationParameters", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Tokens.TokenValidationParameters", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenValidationParameters", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Tokens.TokenValidationParameters" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_UseTokenLifetime", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_UseTokenLifetime", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SkipUnrecognizedRequests", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SkipUnrecognizedRequests", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "authenticationScheme", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 3d13a3d07a..5dd58d680c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json deleted file mode 100644 index c35232a310..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json +++ /dev/null @@ -1,848 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Twitter\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.TwitterOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_UserId", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ScreenName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessTokenSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_User", - "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - }, - { - "Name": "userId", - "Type": "System.String" - }, - { - "Name": "screenName", - "Type": "System.String" - }, - { - "Name": "accessToken", - "Type": "System.String" - }, - { - "Name": "accessTokenSecret", - "Type": "System.String" - }, - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnCreatingTicket", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnCreatingTicket", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToAuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "redirectUri", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.AccessToken", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_UserId", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_UserId", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ScreenName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ScreenName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Token", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Token", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CallbackConfirmed", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CallbackConfirmed", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.RequestTokenSerializer", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "Serialize", - "Parameters": [ - { - "Name": "model", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken" - } - ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "token", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken" - } - ], - "ReturnType": "System.Void", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Read", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseTwitterAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseTwitterAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.TwitterOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_ConsumerKey", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ConsumerKey", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ConsumerSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ConsumerSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RetrieveUserDetails", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RetrieveUserDetails", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_StateDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_StateDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 07936ed258..54b560702a 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -4,7 +4,7 @@ ASP.NET Core common types used by the various authentication middleware components. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication/baseline.net45.json deleted file mode 100644 index 1f69da5a8f..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/baseline.net45.json +++ /dev/null @@ -1,2897 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticationScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AutomaticAuthenticate", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AutomaticAuthenticate", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AutomaticChallenge", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AutomaticChallenge", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClaimsIssuer", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClaimsIssuer", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Description", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Description", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "transform", - "Type": "System.Func>" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Transformer", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Transformer", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_BackchannelTimeout", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelTimeout", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_BackchannelHttpHandler", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpMessageHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelHttpHandler", - "Parameters": [ - { - "Name": "value", - "Type": "System.Net.Http.HttpMessageHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CallbackPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CallbackPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SignInScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignInScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_DisplayName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_DisplayName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RemoteAuthenticationTimeout", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RemoteAuthenticationTimeout", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SaveTokens", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SaveTokens", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Succeeded", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Ticket", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Failure", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Success", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Skip", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Fail", - "Parameters": [ - { - "Name": "failure", - "Type": "System.Exception" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Fail", - "Parameters": [ - { - "Name": "failureMessage", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_SignInAccepted", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignInAccepted", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SignOutAccepted", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignOutAccepted", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ChallengeCalled", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ChallengeCalled", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Context", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Request", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Response", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OriginalPathBase", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OriginalPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Logger", - "Parameters": [], - "ReturnType": "Microsoft.Extensions.Logging.ILogger", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_UrlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.UrlEncoder", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_PriorHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PriorHandler", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CurrentUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "T0", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "InitializeAsync", - "Parameters": [ - { - "Name": "options", - "Type": "T0" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "logger", - "Type": "Microsoft.Extensions.Logging.ILogger" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "BuildRedirectUri", - "Parameters": [ - { - "Name": "targetPath", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "FinishResponseAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDescriptions", - "Parameters": [ - { - "Name": "describeContext", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ShouldHandleScheme", - "Parameters": [ - { - "Name": "authenticationScheme", - "Type": "System.String" - }, - { - "Name": "handleAutomatic", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthenticateAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleAuthenticateOnceAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleForbiddenAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleUnauthorizedAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ChallengeAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.AuthenticationOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticationScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "T0", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "T0" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Logger", - "Parameters": [], - "ReturnType": "Microsoft.Extensions.Logging.ILogger", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Logger", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.Extensions.Logging.ILogger" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_UrlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.UrlEncoder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_UrlEncoder", - "Parameters": [ - { - "Name": "value", - "Type": "System.Text.Encodings.Web.UrlEncoder" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Invoke", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - } - ], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "New": true, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.AuthenticationOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationToken", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Name", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Name", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Value", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Value", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Context", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_PriorHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PriorHandler", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthenticateAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ChallengeAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDescriptions", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RegisterAuthenticationHandler", - "Parameters": [ - { - "Name": "auth", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UnregisterAuthenticationHandler", - "Parameters": [ - { - "Name": "auth", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "transform", - "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - }, - { - "Name": "httpContext", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Invoke", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformer", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnTransform", - "Parameters": [], - "ReturnType": "System.Func>", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTransform", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func>" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TransformAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "TransformAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_UtcNow", - "Parameters": [], - "ReturnType": "System.DateTimeOffset", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteCallbackAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleForbiddenAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GenerateCorrelationId", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ValidateCorrelationId", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Boolean", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_SignInScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignInScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SystemClock", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.ISystemClock" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_UtcNow", - "Parameters": [], - "ReturnType": "System.DateTimeOffset", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "StoreTokens", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokens", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "System.Void", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTokenValue", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTokens", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTokenAsync", - "Parameters": [ - { - "Name": "manager", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTokenAsync", - "Parameters": [ - { - "Name": "manager", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" - }, - { - "Name": "signInScheme", - "Type": "System.String" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "Serialize", - "Parameters": [ - { - "Name": "model", - "Type": "T0" - } - ], - "ReturnType": "System.Byte[]", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "T0", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TModel", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "data", - "Type": "T0" - } - ], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "data", - "Type": "T0" - }, - { - "Name": "purpose", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Unprotect", - "Parameters": [ - { - "Name": "protectedText", - "Type": "System.String" - } - ], - "ReturnType": "T0", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Unprotect", - "Parameters": [ - { - "Name": "protectedText", - "Type": "System.String" - }, - { - "Name": "purpose", - "Type": "System.String" - } - ], - "ReturnType": "T0", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TData", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.PropertiesDataFormat", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Default", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Serialize", - "Parameters": [ - { - "Name": "model", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Read", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SecureDataFormat", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - ], - "Members": [ - { - "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "data", - "Type": "T0" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "data", - "Type": "T0" - }, - { - "Name": "purpose", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Unprotect", - "Parameters": [ - { - "Name": "protectedText", - "Type": "System.String" - } - ], - "ReturnType": "T0", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Unprotect", - "Parameters": [ - { - "Name": "protectedText", - "Type": "System.String" - }, - { - "Name": "purpose", - "Type": "System.String" - } - ], - "ReturnType": "T0", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "serializer", - "Type": "Microsoft.AspNetCore.Authentication.IDataSerializer" - }, - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TData", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "Encode", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Decode", - "Parameters": [ - { - "Name": "text", - "Type": "System.String" - } - ], - "ReturnType": "System.Byte[]", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.TicketDataFormat", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.TicketSerializer", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Default", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.TicketSerializer", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Serialize", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WriteIdentity", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WriteClaim", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "claim", - "Type": "System.Security.Claims.Claim" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Read", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ReadIdentity", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "System.Security.Claims.ClaimsIdentity", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ReadClaim", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - } - ], - "ReturnType": "System.Security.Claims.Claim", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.BaseContext", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_HttpContext", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Request", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Response", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_State", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.EventResultState", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_State", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.EventResultState" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HandledResponse", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleResponse", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SkipToNextMiddleware", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Ticket", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Ticket", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CheckEventResult", - "Parameters": [ - { - "Name": "result", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Direction": "Out" - } - ], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.EventResultState", - "Visibility": "Public", - "Kind": "Enumeration", - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "Continue", - "Parameters": [], - "GenericParameter": [], - "Literal": "0" - }, - { - "Kind": "Field", - "Name": "Skipped", - "Parameters": [], - "GenericParameter": [], - "Literal": "1" - }, - { - "Kind": "Field", - "Name": "HandledResponse", - "Parameters": [], - "GenericParameter": [], - "Literal": "2" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.FailureContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Failure", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Failure", - "Parameters": [ - { - "Name": "value", - "Type": "System.Exception" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "failure", - "Type": "System.Exception" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "RemoteFailure", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.FailureContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TicketReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnRemoteFailure", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRemoteFailure", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnTicketReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTicketReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RemoteFailure", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.FailureContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TicketReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.TicketReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ReturnUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ReturnUri", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AddAuthentication", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - } - ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddAuthentication", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - }, - { - "Name": "configureOptions", - "Type": "System.Action" - } - ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 0382fd2b55..bc5b7be915 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -7,7 +7,7 @@ Commonly used types: Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute Microsoft.AspNetCore.Authorization.AuthorizeAttribute - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authorization diff --git a/src/Microsoft.AspNetCore.Authorization/baseline.net45.json b/src/Microsoft.AspNetCore.Authorization/baseline.net45.json deleted file mode 100644 index 8ae585270c..0000000000 --- a/src/Microsoft.AspNetCore.Authorization/baseline.net45.json +++ /dev/null @@ -1,1593 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.Extensions.DependencyInjection.AuthorizationServiceCollectionExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AddAuthorization", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - } - ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddAuthorization", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - }, - { - "Name": "configure", - "Type": "System.Action" - } - ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "System.Attribute", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAllowAnonymous" - ], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "HandleAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "T0" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TRequirement", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "HandleAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "T0" - }, - { - "Name": "resource", - "Type": "T1" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TRequirement", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ] - }, - { - "ParameterName": "TResource", - "ParameterPosition": 1, - "BaseTypeOrInterfaces": [] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Requirements", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_User", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Resource", - "Parameters": [], - "ReturnType": "System.Object", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_PendingRequirements", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HasFailed", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HasSucceeded", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Fail", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Succeed", - "Parameters": [ - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "requirements", - "Type": "System.Collections.Generic.IEnumerable" - }, - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_DefaultPolicy", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_DefaultPolicy", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddPolicy", - "Parameters": [ - { - "Name": "name", - "Type": "System.String" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddPolicy", - "Parameters": [ - { - "Name": "name", - "Type": "System.String" - }, - { - "Name": "configurePolicy", - "Type": "System.Action" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetPolicy", - "Parameters": [ - { - "Name": "name", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Requirements", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IReadOnlyList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthenticationSchemes", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IReadOnlyList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Combine", - "Parameters": [ - { - "Name": "policies", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Combine", - "Parameters": [ - { - "Name": "policies", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CombineAsync", - "Parameters": [ - { - "Name": "policyProvider", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" - }, - { - "Name": "authorizeData", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "requirements", - "Type": "System.Collections.Generic.IEnumerable" - }, - { - "Name": "authenticationSchemes", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Requirements", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Requirements", - "Parameters": [ - { - "Name": "value", - "Type": "System.Collections.Generic.IList" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthenticationSchemes", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticationSchemes", - "Parameters": [ - { - "Name": "value", - "Type": "System.Collections.Generic.IList" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddAuthenticationSchemes", - "Parameters": [ - { - "Name": "schemes", - "Type": "System.String[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddRequirements", - "Parameters": [ - { - "Name": "requirements", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Combine", - "Parameters": [ - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireClaim", - "Parameters": [ - { - "Name": "claimType", - "Type": "System.String" - }, - { - "Name": "requiredValues", - "Type": "System.String[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireClaim", - "Parameters": [ - { - "Name": "claimType", - "Type": "System.String" - }, - { - "Name": "requiredValues", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireClaim", - "Parameters": [ - { - "Name": "claimType", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireRole", - "Parameters": [ - { - "Name": "roles", - "Type": "System.String[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireRole", - "Parameters": [ - { - "Name": "roles", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireUserName", - "Parameters": [ - { - "Name": "userName", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireAuthenticatedUser", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireAssertion", - "Parameters": [ - { - "Name": "handler", - "Type": "System.Func" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireAssertion", - "Parameters": [ - { - "Name": "handler", - "Type": "System.Func>" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Build", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "authenticationSchemes", - "Type": "System.String[]", - "IsParams": true - } - ], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationServiceExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "service", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" - }, - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "service", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" - }, - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "service", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" - }, - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "service", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" - }, - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizeAttribute", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "System.Attribute", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizeData" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Policy", - "Parameters": [], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Policy", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Roles", - "Parameters": [], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Roles", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ActiveAuthenticationSchemes", - "Parameters": [], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ActiveAuthenticationSchemes", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "policy", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationPolicyProvider", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" - ], - "Members": [ - { - "Kind": "Method", - "Name": "GetDefaultPolicyAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetPolicyAsync", - "Parameters": [ - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationService", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationService" - ], - "Members": [ - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "requirements", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "policyProvider", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" - }, - { - "Name": "handlers", - "Type": "System.Collections.Generic.IEnumerable" - }, - { - "Name": "logger", - "Type": "Microsoft.Extensions.Logging.ILogger" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAllowAnonymous", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "HandleAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetPolicyAsync", - "Parameters": [ - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDefaultPolicyAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationService", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "requirements", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Policy", - "Parameters": [], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Policy", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Roles", - "Parameters": [], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Roles", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ActiveAuthenticationSchemes", - "Parameters": [], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ActiveAuthenticationSchemes", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.AssertionRequirement", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Handler", - "Parameters": [], - "ReturnType": "System.Func>", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "handler", - "Type": "System.Func" - } - ], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "handler", - "Type": "System.Func>" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.ClaimsAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_ClaimType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AllowedValues", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.ClaimsAuthorizationRequirement" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "claimType", - "Type": "System.String" - }, - { - "Name": "allowedValues", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.DenyAnonymousAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.DenyAnonymousAuthorizationRequirement" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.NameAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_RequiredName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.NameAuthorizationRequirement" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "requiredName", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.OperationAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Name", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Name", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.PassThroughAuthorizationHandler", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "HandleAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.RolesAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_AllowedRoles", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.RolesAuthorizationRequirement" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "allowedRoles", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 146917cabe..31ce5b761a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -4,7 +4,7 @@ ASP.NET Core cookie policy classes to control the behavior of cookies. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json deleted file mode 100644 index 8eef347eb6..0000000000 --- a/src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json +++ /dev/null @@ -1,392 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseCookiePolicy", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseCookiePolicy", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookiePolicyOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.CookiePolicyOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_HttpOnly", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_HttpOnly", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Secure", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Secure", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnAppendCookie", - "Parameters": [], - "ReturnType": "System.Action", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnAppendCookie", - "Parameters": [ - { - "Name": "value", - "Type": "System.Action" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnDeleteCookie", - "Parameters": [], - "ReturnType": "System.Action", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnDeleteCookie", - "Parameters": [ - { - "Name": "value", - "Type": "System.Action" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.CookiePolicy.AppendCookieContext", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Context", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieOptions", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieValue", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieValue", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - }, - { - "Name": "name", - "Type": "System.String" - }, - { - "Name": "value", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.CookiePolicy.CookiePolicyMiddleware", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.CookiePolicyOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.CookiePolicyOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Invoke", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.CookiePolicy.DeleteCookieContext", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Context", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieOptions", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - }, - { - "Name": "name", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy", - "Visibility": "Public", - "Kind": "Enumeration", - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "None", - "Parameters": [], - "GenericParameter": [], - "Literal": "0" - }, - { - "Kind": "Field", - "Name": "Always", - "Parameters": [], - "GenericParameter": [], - "Literal": "1" - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs deleted file mode 100644 index f1a07c5bf7..0000000000 --- a/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.Owin.Security.DataHandler; -using Microsoft.Owin.Security.DataHandler.Encoder; -using Microsoft.Owin.Security.DataProtection; - -namespace Microsoft.Owin.Security.Interop -{ - public class AspNetTicketDataFormat : SecureDataFormat - { - public AspNetTicketDataFormat(IDataProtector protector) - : base(AspNetTicketSerializer.Default, protector, TextEncodings.Base64Url) - { - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs deleted file mode 100644 index 6a1019fbc8..0000000000 --- a/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. 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.IO; -using System.Linq; -using System.Security.Claims; -using Microsoft.Owin.Security.DataHandler.Serializer; - -namespace Microsoft.Owin.Security.Interop -{ - // This MUST be kept in sync with Microsoft.AspNetCore.Authentication.DataHandler.TicketSerializer - public class AspNetTicketSerializer : IDataSerializer - { - private const string DefaultStringPlaceholder = "\0"; - private const int FormatVersion = 5; - - public static AspNetTicketSerializer Default { get; } = new AspNetTicketSerializer(); - - public virtual byte[] Serialize(AuthenticationTicket ticket) - { - using (var memory = new MemoryStream()) - { - using (var writer = new BinaryWriter(memory)) - { - Write(writer, ticket); - } - return memory.ToArray(); - } - } - - public virtual AuthenticationTicket Deserialize(byte[] data) - { - using (var memory = new MemoryStream(data)) - { - using (var reader = new BinaryReader(memory)) - { - return Read(reader); - } - } - } - - public virtual void Write(BinaryWriter writer, AuthenticationTicket ticket) - { - writer.Write(FormatVersion); - writer.Write(ticket.Identity.AuthenticationType); - - var identity = ticket.Identity; - if (identity == null) - { - throw new ArgumentNullException("ticket.Identity"); - } - - // There is always a single identity - writer.Write(1); - WriteIdentity(writer, identity); - PropertiesSerializer.Write(writer, ticket.Properties); - } - - protected virtual void WriteIdentity(BinaryWriter writer, ClaimsIdentity identity) - { - var authenticationType = identity.AuthenticationType ?? string.Empty; - - writer.Write(authenticationType); - WriteWithDefault(writer, identity.NameClaimType, ClaimsIdentity.DefaultNameClaimType); - WriteWithDefault(writer, identity.RoleClaimType, ClaimsIdentity.DefaultRoleClaimType); - - // Write the number of claims contained in the identity. - writer.Write(identity.Claims.Count()); - - foreach (var claim in identity.Claims) - { - WriteClaim(writer, claim); - } - - var bootstrap = identity.BootstrapContext as string; - if (!string.IsNullOrEmpty(bootstrap)) - { - writer.Write(true); - writer.Write(bootstrap); - } - else - { - writer.Write(false); - } - - if (identity.Actor != null) - { - writer.Write(true); - WriteIdentity(writer, identity.Actor); - } - else - { - writer.Write(false); - } - } - - protected virtual void WriteClaim(BinaryWriter writer, Claim claim) - { - WriteWithDefault(writer, claim.Type, claim.Subject?.NameClaimType ?? ClaimsIdentity.DefaultNameClaimType); - writer.Write(claim.Value); - WriteWithDefault(writer, claim.ValueType, ClaimValueTypes.String); - WriteWithDefault(writer, claim.Issuer, ClaimsIdentity.DefaultIssuer); - WriteWithDefault(writer, claim.OriginalIssuer, claim.Issuer); - - // Write the number of properties contained in the claim. - writer.Write(claim.Properties.Count); - - foreach (var property in claim.Properties) - { - writer.Write(property.Key ?? string.Empty); - writer.Write(property.Value ?? string.Empty); - } - } - - public virtual AuthenticationTicket Read(BinaryReader reader) - { - if (reader.ReadInt32() != FormatVersion) - { - return null; - } - - var scheme = reader.ReadString(); - - // Any identities after the first will be ignored. - var count = reader.ReadInt32(); - if (count < 0) - { - return null; - } - - var identity = ReadIdentity(reader); - var properties = PropertiesSerializer.Read(reader); - - return new AuthenticationTicket(identity, properties); - } - - protected virtual ClaimsIdentity ReadIdentity(BinaryReader reader) - { - var authenticationType = reader.ReadString(); - var nameClaimType = ReadWithDefault(reader, ClaimsIdentity.DefaultNameClaimType); - var roleClaimType = ReadWithDefault(reader, ClaimsIdentity.DefaultRoleClaimType); - - // Read the number of claims contained - // in the serialized identity. - var count = reader.ReadInt32(); - - var identity = new ClaimsIdentity(authenticationType, nameClaimType, roleClaimType); - - for (int index = 0; index != count; ++index) - { - var claim = ReadClaim(reader, identity); - - identity.AddClaim(claim); - } - - // Determine whether the identity - // has a bootstrap context attached. - if (reader.ReadBoolean()) - { - identity.BootstrapContext = reader.ReadString(); - } - - // Determine whether the identity - // has an actor identity attached. - if (reader.ReadBoolean()) - { - identity.Actor = ReadIdentity(reader); - } - - return identity; - } - - protected virtual Claim ReadClaim(BinaryReader reader, ClaimsIdentity identity) - { - var type = ReadWithDefault(reader, identity.NameClaimType); - var value = reader.ReadString(); - var valueType = ReadWithDefault(reader, ClaimValueTypes.String); - var issuer = ReadWithDefault(reader, ClaimsIdentity.DefaultIssuer); - var originalIssuer = ReadWithDefault(reader, issuer); - - var claim = new Claim(type, value, valueType, issuer, originalIssuer, identity); - - // Read the number of properties stored in the claim. - var count = reader.ReadInt32(); - - for (var index = 0; index != count; ++index) - { - var key = reader.ReadString(); - var propertyValue = reader.ReadString(); - - claim.Properties.Add(key, propertyValue); - } - - return claim; - } - - private static void WriteWithDefault(BinaryWriter writer, string value, string defaultValue) - { - if (string.Equals(value, defaultValue, StringComparison.Ordinal)) - { - writer.Write(DefaultStringPlaceholder); - } - else - { - writer.Write(value); - } - } - - private static string ReadWithDefault(BinaryReader reader, string defaultValue) - { - var value = reader.ReadString(); - if (string.Equals(value, DefaultStringPlaceholder, StringComparison.Ordinal)) - { - return defaultValue; - } - return value; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs deleted file mode 100644 index b323258d9b..0000000000 --- a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using Microsoft.Owin.Infrastructure; - -namespace Microsoft.Owin.Security.Interop -{ - // This MUST be kept in sync with Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager - /// - /// This handles cookies that are limited by per cookie length. It breaks down long cookies for responses, and reassembles them - /// from requests. - /// - public class ChunkingCookieManager : ICookieManager - { - private const string ChunkKeySuffix = "C"; - private const string ChunkCountPrefix = "chunks-"; - - public ChunkingCookieManager() - { - // Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case. - // See http://browsercookielimits.x64.me/. - // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. - ChunkSize = 4070; - ThrowForPartialCookies = true; - } - - /// - /// The maximum size of cookie to send back to the client. If a cookie exceeds this size it will be broken down into multiple - /// cookies. Set this value to null to disable this behavior. The default is 4090 characters, which is supported by all - /// common browsers. - /// - /// Note that browsers may also have limits on the total size of all cookies per domain, and on the number of cookies per domain. - /// - public int? ChunkSize { get; set; } - - /// - /// Throw if not all chunks of a cookie are available on a request for re-assembly. - /// - public bool ThrowForPartialCookies { get; set; } - - // Parse the "chunks-XX" to determine how many chunks there should be. - private static int ParseChunksCount(string value) - { - if (value != null && value.StartsWith(ChunkCountPrefix, StringComparison.Ordinal)) - { - var chunksCountString = value.Substring(ChunkCountPrefix.Length); - int chunksCount; - if (int.TryParse(chunksCountString, NumberStyles.None, CultureInfo.InvariantCulture, out chunksCount)) - { - return chunksCount; - } - } - return 0; - } - - /// - /// Get the reassembled cookie. Non chunked cookies are returned normally. - /// Cookies with missing chunks just have their "chunks-XX" header returned. - /// - /// - /// - /// The reassembled cookie, if any, or null. - public string GetRequestCookie(IOwinContext context, string key) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } - - var requestCookies = context.Request.Cookies; - var value = requestCookies[key]; - var chunksCount = ParseChunksCount(value); - if (chunksCount > 0) - { - var chunks = new string[chunksCount]; - for (var chunkId = 1; chunkId <= chunksCount; chunkId++) - { - var chunk = requestCookies[key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture)]; - if (string.IsNullOrEmpty(chunk)) - { - if (ThrowForPartialCookies) - { - var totalSize = 0; - for (int i = 0; i < chunkId - 1; i++) - { - totalSize += chunks[i].Length; - } - throw new FormatException( - string.Format(CultureInfo.CurrentCulture, - "The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded.", - chunkId - 1, chunksCount, totalSize)); - } - // Missing chunk, abort by returning the original cookie value. It may have been a false positive? - return value; - } - - chunks[chunkId - 1] = chunk; - } - - return string.Join(string.Empty, chunks); - } - return value; - } - - /// - /// Appends a new response cookie to the Set-Cookie header. If the cookie is larger than the given size limit - /// then it will be broken down into multiple cookies as follows: - /// Set-Cookie: CookieName=chunks-3; path=/ - /// Set-Cookie: CookieNameC1=Segment1; path=/ - /// Set-Cookie: CookieNameC2=Segment2; path=/ - /// Set-Cookie: CookieNameC3=Segment3; path=/ - /// - /// - /// - /// - /// - public void AppendResponseCookie(IOwinContext context, string key, string value, CookieOptions options) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - var domainHasValue = !string.IsNullOrEmpty(options.Domain); - var pathHasValue = !string.IsNullOrEmpty(options.Path); - var expiresHasValue = options.Expires.HasValue; - - var templateLength = key.Length + "=".Length - + (domainHasValue ? "; domain=".Length + options.Domain.Length : 0) - + (pathHasValue ? "; path=".Length + options.Path.Length : 0) - + (expiresHasValue ? "; expires=ddd, dd-MMM-yyyy HH:mm:ss GMT".Length : 0) - + (options.Secure ? "; secure".Length : 0) - + (options.HttpOnly ? "; HttpOnly".Length : 0); - - // Normal cookie - var responseCookies = context.Response.Cookies; - if (!ChunkSize.HasValue || ChunkSize.Value > templateLength + value.Length) - { - responseCookies.Append(key, value, options); - } - else if (ChunkSize.Value < templateLength + 10) - { - // 10 is the minimum data we want to put in an individual cookie, including the cookie chunk identifier "CXX". - // No room for data, we can't chunk the options and name - throw new InvalidOperationException("The cookie key and options are larger than ChunksSize, leaving no room for data."); - } - else - { - // Break the cookie down into multiple cookies. - // Key = CookieName, value = "Segment1Segment2Segment2" - // Set-Cookie: CookieName=chunks-3; path=/ - // Set-Cookie: CookieNameC1="Segment1"; path=/ - // Set-Cookie: CookieNameC2="Segment2"; path=/ - // Set-Cookie: CookieNameC3="Segment3"; path=/ - var dataSizePerCookie = ChunkSize.Value - templateLength - 3; // Budget 3 chars for the chunkid. - var cookieChunkCount = (int)Math.Ceiling(value.Length * 1.0 / dataSizePerCookie); - - responseCookies.Append(key, ChunkCountPrefix + cookieChunkCount.ToString(CultureInfo.InvariantCulture), options); - - var offset = 0; - for (var chunkId = 1; chunkId <= cookieChunkCount; chunkId++) - { - var remainingLength = value.Length - offset; - var length = Math.Min(dataSizePerCookie, remainingLength); - var segment = value.Substring(offset, length); - offset += length; - - responseCookies.Append(key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture), segment, options); - } - } - } - - /// - /// Deletes the cookie with the given key by setting an expired state. If a matching chunked cookie exists on - /// the request, delete each chunk. - /// - /// - /// - /// - public void DeleteCookie(IOwinContext context, string key, CookieOptions options) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - var keys = new List(); - keys.Add(key + "="); - - var requestCookie = context.Request.Cookies[key]; - var chunks = ParseChunksCount(requestCookie); - if (chunks > 0) - { - for (int i = 1; i <= chunks + 1; i++) - { - var subkey = key + ChunkKeySuffix + i.ToString(CultureInfo.InvariantCulture); - keys.Add(subkey + "="); - } - } - - var domainHasValue = !string.IsNullOrEmpty(options.Domain); - var pathHasValue = !string.IsNullOrEmpty(options.Path); - - Func rejectPredicate; - Func predicate = value => keys.Any(k => value.StartsWith(k, StringComparison.OrdinalIgnoreCase)); - if (domainHasValue) - { - rejectPredicate = value => predicate(value) && value.IndexOf("domain=" + options.Domain, StringComparison.OrdinalIgnoreCase) != -1; - } - else if (pathHasValue) - { - rejectPredicate = value => predicate(value) && value.IndexOf("path=" + options.Path, StringComparison.OrdinalIgnoreCase) != -1; - } - else - { - rejectPredicate = value => predicate(value); - } - - var responseHeaders = context.Response.Headers; - string[] existingValues; - if (responseHeaders.TryGetValue(Constants.Headers.SetCookie, out existingValues) && existingValues != null) - { - responseHeaders.SetValues(Constants.Headers.SetCookie, existingValues.Where(value => !rejectPredicate(value)).ToArray()); - } - - AppendResponseCookie( - context, - key, - string.Empty, - new CookieOptions() - { - Path = options.Path, - Domain = options.Domain, - Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), - }); - - for (int i = 1; i <= chunks; i++) - { - AppendResponseCookie( - context, - key + "C" + i.ToString(CultureInfo.InvariantCulture), - string.Empty, - new CookieOptions() - { - Path = options.Path, - Domain = options.Domain, - Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), - }); - } - } - } -} diff --git a/src/Microsoft.Owin.Security.Interop/Constants.cs b/src/Microsoft.Owin.Security.Interop/Constants.cs deleted file mode 100644 index 1e75761b70..0000000000 --- a/src/Microsoft.Owin.Security.Interop/Constants.cs +++ /dev/null @@ -1,13 +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.Owin.Security.Interop -{ - internal static class Constants - { - internal static class Headers - { - internal const string SetCookie = "Set-Cookie"; - } - } -} diff --git a/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs b/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs deleted file mode 100644 index 7313588948..0000000000 --- a/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.DataProtection; - -namespace Microsoft.Owin.Security.Interop -{ - /// - /// Converts an to an - /// . - /// - public sealed class DataProtectorShim : Microsoft.Owin.Security.DataProtection.IDataProtector - { - private readonly IDataProtector _protector; - - public DataProtectorShim(IDataProtector protector) - { - _protector = protector; - } - - public byte[] Protect(byte[] userData) - { - return _protector.Protect(userData); - } - - public byte[] Unprotect(byte[] protectedData) - { - return _protector.Unprotect(protectedData); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj deleted file mode 100644 index 1a66791194..0000000000 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication. - net46 - $(NoWarn);CS1591 - true - aspnetcore;katana;owin;security - - - - - - - - diff --git a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs deleted file mode 100644 index 490fa7cb2a..0000000000 --- a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,8 +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.Runtime.InteropServices; - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a7922dd8-09f1-43e4-938b-cc523ea08898")] - diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json deleted file mode 100644 index 1fc242ec55..0000000000 --- a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json +++ /dev/null @@ -1,373 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.Owin.Security.DataHandler.SecureDataFormat", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.Owin.Security.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Owin.Security.Interop.AspNetTicketSerializer", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Default", - "Parameters": [], - "ReturnType": "Microsoft.Owin.Security.Interop.AspNetTicketSerializer", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Serialize", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.Owin.Security.AuthenticationTicket" - } - ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "Microsoft.Owin.Security.AuthenticationTicket", - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "ticket", - "Type": "Microsoft.Owin.Security.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WriteIdentity", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WriteClaim", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "claim", - "Type": "System.Security.Claims.Claim" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Read", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "Microsoft.Owin.Security.AuthenticationTicket", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ReadIdentity", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "System.Security.Claims.ClaimsIdentity", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ReadClaim", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - } - ], - "ReturnType": "System.Security.Claims.Claim", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Owin.Security.Interop.ChunkingCookieManager", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.Owin.Infrastructure.ICookieManager" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_ChunkSize", - "Parameters": [], - "ReturnType": "System.Nullable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ChunkSize", - "Parameters": [ - { - "Name": "value", - "Type": "System.Nullable" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ThrowForPartialCookies", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ThrowForPartialCookies", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetRequestCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.Owin.IOwinContext" - }, - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AppendResponseCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.Owin.IOwinContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "value", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.Owin.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "DeleteCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.Owin.IOwinContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.Owin.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Owin.Security.Interop.DataProtectorShim", - "Visibility": "Public", - "Kind": "Class", - "Sealed": true, - "ImplementedInterfaces": [ - "Microsoft.Owin.Security.DataProtection.IDataProtector" - ], - "Members": [ - { - "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "userData", - "Type": "System.Byte[]" - } - ], - "ReturnType": "System.Byte[]", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Security.DataProtection.IDataProtector", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Unprotect", - "Parameters": [ - { - "Name": "protectedData", - "Type": "System.Byte[]" - } - ], - "ReturnType": "System.Byte[]", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Security.DataProtection.IDataProtector", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 801567d7e9..df51faf882 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -2,8 +2,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0 true true diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index c964221fbb..a2d4a61dea 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -2,8 +2,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index d2736ca0d7..6ca53f519c 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -2,8 +2,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index a972731ea5..ca850d7549 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -2,8 +2,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0 true true diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs deleted file mode 100644 index ae5e6f0183..0000000000 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ /dev/null @@ -1,332 +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.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Security.Claims; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using System.Xml.Linq; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Net.Http.Headers; -using Microsoft.Owin.Security.Cookies; -using Microsoft.Owin.Testing; -using Owin; -using Xunit; - -namespace Microsoft.Owin.Security.Interop -{ - public class CookiesInteropTests - { - [Fact] - public async Task AspNetCoreWithInteropCookieContainsIdentity() - { - var identity = new ClaimsIdentity("Cookies"); - identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); - - var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); - var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); - - var interopServer = TestServer.Create(app => - { - app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - - app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions - { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), - CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix - + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, - }); - - app.Run(context => - { - context.Authentication.SignIn(identity); - return Task.FromResult(0); - }); - }); - - var transaction = await SendAsync(interopServer, "http://example.com"); - - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseAuthentication(); - app.Run(async context => - { - var result = await context.AuthenticateAsync("Cookies"); - await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); - }); - }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); - var newServer = new AspNetCore.TestHost.TestServer(builder); - - var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); - foreach (var cookie in SetCookieHeaderValue.ParseList(transaction.SetCookie)) - { - request.Headers.Add("Cookie", cookie.Name + "=" + cookie.Value); - } - var response = await newServer.CreateClient().SendAsync(request); - - Assert.Equal("Alice", await response.Content.ReadAsStringAsync()); - } - - [Fact] - public async Task AspNetCoreWithLargeInteropCookieContainsIdentity() - { - var identity = new ClaimsIdentity("Cookies"); - identity.AddClaim(new Claim(ClaimTypes.Name, new string('a', 1024 * 5))); - - var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); - var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); - - var interopServer = TestServer.Create(app => - { - app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - - app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions - { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), - CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix - + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, - CookieManager = new ChunkingCookieManager(), - }); - - app.Run(context => - { - context.Authentication.SignIn(identity); - return Task.FromResult(0); - }); - }); - - var transaction = await SendAsync(interopServer, "http://example.com"); - - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseAuthentication(); - app.Run(async context => - { - var result = await context.AuthenticateAsync("Cookies"); - await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); - }); - }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); - var newServer = new AspNetCore.TestHost.TestServer(builder); - - var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); - foreach (var cookie in SetCookieHeaderValue.ParseList(transaction.SetCookie)) - { - request.Headers.Add("Cookie", cookie.Name + "=" + cookie.Value); - } - var response = await newServer.CreateClient().SendAsync(request); - - Assert.Equal(1024 * 5, (await response.Content.ReadAsStringAsync()).Length); - } - - [Fact] - public async Task InteropWithNewCookieContainsIdentity() - { - var user = new ClaimsPrincipal(); - var identity = new ClaimsIdentity("scheme"); - identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); - user.AddIdentity(identity); - - var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); - var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); - - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseAuthentication(); - app.Run(context => context.SignInAsync("Cookies", user)); - }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); - var newServer = new AspNetCore.TestHost.TestServer(builder); - - var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); - - var server = TestServer.Create(app => - { - app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - - app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions - { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), - CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix - + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, - }); - - app.Run(async context => - { - var result = await context.Authentication.AuthenticateAsync("Cookies"); - Describe(context.Response, result); - }); - }); - - var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookies); - - Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); - } - - [Fact] - public async Task InteropWithLargeNewCookieContainsIdentity() - { - var user = new ClaimsPrincipal(); - var identity = new ClaimsIdentity("scheme"); - identity.AddClaim(new Claim(ClaimTypes.Name, new string('a', 1024 * 5))); - user.AddIdentity(identity); - - var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); - var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); - - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseAuthentication(); - app.Run(context => context.SignInAsync("Cookies", user)); - }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); - var newServer = new AspNetCore.TestHost.TestServer(builder); - - var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); - - var server = TestServer.Create(app => - { - app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - - app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions - { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), - CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix - + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, - CookieManager = new ChunkingCookieManager(), - }); - - app.Run(async context => - { - var result = await context.Authentication.AuthenticateAsync("Cookies"); - Describe(context.Response, result); - }); - }); - - var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookies); - - Assert.Equal(1024 * 5, FindClaimValue(transaction2, ClaimTypes.Name).Length); - } - - private static async Task> SendAndGetCookies(AspNetCore.TestHost.TestServer server, string uri) - { - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var response = await server.CreateClient().SendAsync(request); - if (response.Headers.Contains("Set-Cookie")) - { - IList cookieHeaders = new List(); - foreach (var cookie in SetCookieHeaderValue.ParseList(response.Headers.GetValues("Set-Cookie").ToList())) - { - cookieHeaders.Add(cookie.Name + "=" + cookie.Value); - } - return cookieHeaders; - } - return null; - } - - private static string FindClaimValue(Transaction transaction, string claimType) - { - XElement claim = transaction.ResponseElement.Elements("claim").SingleOrDefault(elt => elt.Attribute("type").Value == claimType); - if (claim == null) - { - return null; - } - return claim.Attribute("value").Value; - } - - private static void Describe(IOwinResponse res, AuthenticateResult result) - { - res.StatusCode = 200; - res.ContentType = "text/xml"; - var xml = new XElement("xml"); - if (result != null && result.Identity != null) - { - xml.Add(result.Identity.Claims.Select(claim => new XElement("claim", new XAttribute("type", claim.Type), new XAttribute("value", claim.Value)))); - } - if (result != null && result.Properties != null) - { - xml.Add(result.Properties.Dictionary.Select(extra => new XElement("extra", new XAttribute("type", extra.Key), new XAttribute("value", extra.Value)))); - } - using (var memory = new MemoryStream()) - { - using (var writer = new XmlTextWriter(memory, Encoding.UTF8)) - { - xml.WriteTo(writer); - } - res.Body.Write(memory.ToArray(), 0, memory.ToArray().Length); - } - } - - private static async Task SendAsync(TestServer server, string uri, IList cookieHeaders = null, bool ajaxRequest = false) - { - var request = new HttpRequestMessage(HttpMethod.Get, uri); - if (cookieHeaders != null) - { - request.Headers.Add("Cookie", cookieHeaders); - } - if (ajaxRequest) - { - request.Headers.Add("X-Requested-With", "XMLHttpRequest"); - } - var transaction = new Transaction - { - Request = request, - Response = await server.HttpClient.SendAsync(request), - }; - if (transaction.Response.Headers.Contains("Set-Cookie")) - { - transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").ToList(); - } - if (transaction.SetCookie != null && transaction.SetCookie.Any()) - { - transaction.CookieNameValue = transaction.SetCookie.First().Split(new[] { ';' }, 2).First(); - } - transaction.ResponseText = await transaction.Response.Content.ReadAsStringAsync(); - - if (transaction.Response.Content != null && - transaction.Response.Content.Headers.ContentType != null && - transaction.Response.Content.Headers.ContentType.MediaType == "text/xml") - { - transaction.ResponseElement = XElement.Parse(transaction.ResponseText); - } - return transaction; - } - - private class Transaction - { - public HttpRequestMessage Request { get; set; } - public HttpResponseMessage Response { get; set; } - - public IList SetCookie { get; set; } - public string CookieNameValue { get; set; } - - public string ResponseText { get; set; } - public XElement ResponseElement { get; set; } - } - - } -} - diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj deleted file mode 100644 index 02763b93f2..0000000000 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - net46 - true - true - - - - - - - - - - - - - - - - - - - - diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs deleted file mode 100644 index b14ea0d74e..0000000000 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Linq; -using System.Security.Claims; -using Microsoft.AspNetCore.Authentication; -using Xunit; - -namespace Microsoft.Owin.Security.Interop.Test -{ - public class TicketInteropTests - { - [Fact] - public void NewSerializerCanReadInteropTicket() - { - var identity = new ClaimsIdentity("scheme"); - identity.AddClaim(new Claim("Test", "Value")); - - var expires = DateTime.Today; - var issued = new DateTime(1979, 11, 11); - var properties = new Owin.Security.AuthenticationProperties(); - properties.IsPersistent = true; - properties.RedirectUri = "/redirect"; - properties.Dictionary["key"] = "value"; - properties.ExpiresUtc = expires; - properties.IssuedUtc = issued; - - var interopTicket = new Owin.Security.AuthenticationTicket(identity, properties); - var interopSerializer = new AspNetTicketSerializer(); - - var bytes = interopSerializer.Serialize(interopTicket); - - var newSerializer = new TicketSerializer(); - var newTicket = newSerializer.Deserialize(bytes); - - Assert.NotNull(newTicket); - Assert.Equal(1, newTicket.Principal.Identities.Count()); - var newIdentity = newTicket.Principal.Identity as ClaimsIdentity; - Assert.NotNull(newIdentity); - Assert.Equal("scheme", newIdentity.AuthenticationType); - Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); - Assert.NotNull(newTicket.Properties); - Assert.True(newTicket.Properties.IsPersistent); - Assert.Equal("/redirect", newTicket.Properties.RedirectUri); - Assert.Equal("value", newTicket.Properties.Items["key"]); - Assert.Equal(expires, newTicket.Properties.ExpiresUtc); - Assert.Equal(issued, newTicket.Properties.IssuedUtc); - } - - [Fact] - public void InteropSerializerCanReadNewTicket() - { - var user = new ClaimsPrincipal(); - var identity = new ClaimsIdentity("scheme"); - identity.AddClaim(new Claim("Test", "Value")); - user.AddIdentity(identity); - - var expires = DateTime.Today; - var issued = new DateTime(1979, 11, 11); - var properties = new AspNetCore.Authentication.AuthenticationProperties(); - properties.IsPersistent = true; - properties.RedirectUri = "/redirect"; - properties.Items["key"] = "value"; - properties.ExpiresUtc = expires; - properties.IssuedUtc = issued; - - var newTicket = new AspNetCore.Authentication.AuthenticationTicket(user, properties, "scheme"); - var newSerializer = new TicketSerializer(); - - var bytes = newSerializer.Serialize(newTicket); - - var interopSerializer = new AspNetTicketSerializer(); - var interopTicket = interopSerializer.Deserialize(bytes); - - Assert.NotNull(interopTicket); - var newIdentity = interopTicket.Identity; - Assert.NotNull(newIdentity); - Assert.Equal("scheme", newIdentity.AuthenticationType); - Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); - Assert.NotNull(interopTicket.Properties); - Assert.True(interopTicket.Properties.IsPersistent); - Assert.Equal("/redirect", interopTicket.Properties.RedirectUri); - Assert.Equal("value", interopTicket.Properties.Dictionary["key"]); - Assert.Equal(expires, interopTicket.Properties.ExpiresUtc); - Assert.Equal(issued, interopTicket.Properties.IssuedUtc); - } - } -} - - From b7a5a6044d61ee2fa0625446b52ef4f181c08505 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Tue, 9 May 2017 08:57:39 -0700 Subject: [PATCH 721/900] Fix samples logging (#1205) --- samples/CookieSample/Program.cs | 6 ++++++ samples/CookieSample/Startup.cs | 5 +---- samples/CookieSessionSample/Program.cs | 7 ++++++- samples/CookieSessionSample/Startup.cs | 5 +---- samples/OpenIdConnect.AzureAdSample/Program.cs | 6 ++++++ samples/OpenIdConnect.AzureAdSample/Startup.cs | 5 +---- samples/OpenIdConnectSample/Program.cs | 8 ++++++++ samples/OpenIdConnectSample/Startup.cs | 6 +----- samples/SocialSample/Program.cs | 7 ++++++- samples/SocialSample/Startup.cs | 5 +---- 10 files changed, 37 insertions(+), 23 deletions(-) diff --git a/samples/CookieSample/Program.cs b/samples/CookieSample/Program.cs index 7deed359e1..3f40d3194b 100644 --- a/samples/CookieSample/Program.cs +++ b/samples/CookieSample/Program.cs @@ -1,5 +1,6 @@ using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; namespace CookieSample { @@ -8,6 +9,11 @@ namespace CookieSample public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 0480556f69..3aebb419f8 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; namespace CookieSample { @@ -17,10 +16,8 @@ namespace CookieSample services.AddCookieAuthentication(); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(LogLevel.Information); - app.UseAuthentication(); app.Run(async context => diff --git a/samples/CookieSessionSample/Program.cs b/samples/CookieSessionSample/Program.cs index adf8f1f1a4..1a19850e64 100644 --- a/samples/CookieSessionSample/Program.cs +++ b/samples/CookieSessionSample/Program.cs @@ -1,6 +1,6 @@ using System.IO; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace CookieSessionSample { @@ -9,6 +9,11 @@ namespace CookieSessionSample public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index ca21070dcd..9ad9e6841e 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; namespace CookieSessionSample { @@ -18,10 +17,8 @@ namespace CookieSessionSample services.AddCookieAuthentication(o => o.SessionStore = new MemoryCacheTicketStore()); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(LogLevel.Information); - app.UseAuthentication(); app.Run(async context => diff --git a/samples/OpenIdConnect.AzureAdSample/Program.cs b/samples/OpenIdConnect.AzureAdSample/Program.cs index 11d1fbeafb..9de0185a40 100644 --- a/samples/OpenIdConnect.AzureAdSample/Program.cs +++ b/samples/OpenIdConnect.AzureAdSample/Program.cs @@ -1,5 +1,6 @@ using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; namespace OpenIdConnect.AzureAdSample { @@ -8,6 +9,11 @@ namespace OpenIdConnect.AzureAdSample public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 19bb0ac6a3..ebb59c0604 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -12,7 +12,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -79,10 +78,8 @@ namespace OpenIdConnect.AzureAdSample }); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(Microsoft.Extensions.Logging.LogLevel.Information); - app.UseDeveloperExceptionPage(); app.UseAuthentication(); diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs index 741dd6ebf5..b4d24505d5 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -5,6 +5,7 @@ using System.Reflection; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Logging; namespace OpenIdConnectSample { @@ -13,6 +14,13 @@ namespace OpenIdConnectSample public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddDebug(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + factory.AddFilter("Debug", level => level >= LogLevel.Information); + }) .UseKestrel(options => { if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 5faa48b52a..af1406289d 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace OpenIdConnectSample @@ -76,11 +75,8 @@ namespace OpenIdConnectSample }); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(LogLevel.Information); - loggerfactory.AddDebug(LogLevel.Information); - app.UseDeveloperExceptionPage(); app.UseAuthentication(); diff --git a/samples/SocialSample/Program.cs b/samples/SocialSample/Program.cs index 76fb5e59a9..96bce512d5 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -4,8 +4,8 @@ using System.Net; using System.Reflection; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Logging; namespace SocialSample { @@ -14,6 +14,11 @@ namespace SocialSample public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) .UseKestrel(options => { if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 7c1dd9d8db..22c44b3ea7 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -16,7 +16,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; namespace SocialSample @@ -209,10 +208,8 @@ namespace SocialSample }); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(LogLevel.Information); - app.UseDeveloperExceptionPage(); app.UseAuthentication(); From 36605636dfbb84fbcbe96058c75154e08254767f Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 10 May 2017 11:47:56 -0700 Subject: [PATCH 722/900] Remove unnecessary package references (#1210) --- build/dependencies.props | 2 -- .../Microsoft.AspNetCore.Authentication.JwtBearer.csproj | 3 +-- .../Microsoft.AspNetCore.Authentication.OAuth.csproj | 6 +----- ...Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj | 3 +-- .../Microsoft.AspNetCore.Authorization.csproj | 6 +----- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 3 +-- 6 files changed, 5 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 8dbb18b6c5..955457fe8d 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,13 +1,11 @@ 2.0.0-* - 4.3.0 3.13.8 2.1.3 2.1.0-* 10.0.1 $(BundledNETStandardPackageVersion) - 3.0.1 15.0.0 2.2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 05bdd41313..c2b99e47db 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -1,4 +1,4 @@ - + ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. @@ -11,7 +11,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 5fb75ead95..8e33372c1f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -1,4 +1,4 @@ - + @@ -17,8 +17,4 @@ - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index aab8833d28..b3829b59dc 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -1,4 +1,4 @@ - + ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. @@ -13,6 +13,5 @@ - diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index bc5b7be915..b39a7bf3dd 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -1,4 +1,4 @@ - + @@ -19,8 +19,4 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute - - - - diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index ca850d7549..34224e21f1 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -1,4 +1,4 @@ - + @@ -13,7 +13,6 @@ - From 785c1251dd511dfa4dd0218a65a31bb806494190 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Thu, 11 May 2017 16:32:19 -0700 Subject: [PATCH 723/900] Add auth link --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ab822bd682..e8e64c2936 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ Travis: [![Travis](https://travis-ci.org/aspnet/Security.svg?branch=dev)](http Contains the security and authorization middlewares for ASP.NET Core. +A list of community projects related to authentication and security for ASP.NET Core are listed in the [documentation](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/community). + ### Notes ASP.NET Security will not include Basic Authentication middleware due to its potential insecurity and performance problems. If you host under IIS you can enable it via IIS configuration. From bdd4d219962201907393734d9fab2903921fec9d Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 12 May 2017 14:25:44 -0700 Subject: [PATCH 724/900] Update test framework versions and fix issues with tests --- build/dependencies.props | 4 ++-- .../GoogleTests.cs | 22 +++++++++---------- ...soft.AspNetCore.Authentication.Test.csproj | 12 +++++----- .../OAuthTests.cs | 2 ++ .../TicketSerializerTests.cs | 16 +++++++------- .../TokenExtensionTests.cs | 6 ++--- .../DefaultAuthorizationServiceTests.cs | 3 ++- ...osoft.AspNetCore.Authorization.Test.csproj | 13 ++++++----- ....ChunkingCookieManager.Sources.Test.csproj | 8 +++---- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 12 +++++----- 10 files changed, 54 insertions(+), 44 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 955457fe8d..74d501f7cd 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -6,7 +6,7 @@ 2.1.0-* 10.0.1 $(BundledNETStandardPackageVersion) - 15.0.0 - 2.2.0 + 15.3.0-* + 2.3.0-beta2-* diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 0ab3e44938..68ea33462b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -405,7 +405,7 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal("Test Family Name", transaction.FindClaimValue(ClaimTypes.Surname, expectedIssuer)); Assert.Equal("Test email", transaction.FindClaimValue(ClaimTypes.Email, expectedIssuer)); - // Ensure claims transformation + // Ensure claims transformation Assert.Equal("yup", transaction.FindClaimValue("xform")); transaction = await server.SendAsync("https://example.com/tokens", authCookie); @@ -688,14 +688,14 @@ namespace Microsoft.AspNetCore.Authentication.Google OnCreatingTicket = context => { Assert.NotNull(context.User); - Assert.Equal(context.AccessToken, "Test Access Token"); - Assert.Equal(context.RefreshToken, "Test Refresh Token"); - Assert.Equal(context.ExpiresIn, TimeSpan.FromSeconds(3600)); - Assert.Equal(context.Identity.FindFirst(ClaimTypes.Email)?.Value, "Test email"); - Assert.Equal(context.Identity.FindFirst(ClaimTypes.NameIdentifier)?.Value, "Test User ID"); - Assert.Equal(context.Identity.FindFirst(ClaimTypes.Name)?.Value, "Test Name"); - Assert.Equal(context.Identity.FindFirst(ClaimTypes.Surname)?.Value, "Test Family Name"); - Assert.Equal(context.Identity.FindFirst(ClaimTypes.GivenName)?.Value, "Test Given Name"); + Assert.Equal("Test Access Token", context.AccessToken); + Assert.Equal("Test Refresh Token", context.RefreshToken); + Assert.Equal(TimeSpan.FromSeconds(3600), context.ExpiresIn); + Assert.Equal("Test email", context.Identity.FindFirst(ClaimTypes.Email)?.Value); + Assert.Equal("Test User ID", context.Identity.FindFirst(ClaimTypes.NameIdentifier)?.Value); + Assert.Equal("Test Name", context.Identity.FindFirst(ClaimTypes.Name)?.Value); + Assert.Equal("Test Family Name", context.Identity.FindFirst(ClaimTypes.Surname)?.Value); + Assert.Equal("Test Given Name", context.Identity.FindFirst(ClaimTypes.GivenName)?.Value); return Task.FromResult(0); } }; @@ -954,7 +954,7 @@ namespace Microsoft.AspNetCore.Authentication.Google var authCookie = transaction.AuthenticationCookieValue; transaction = await server.SendAsync("https://example.com/authenticateFacebook", authCookie); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.Equal(null, transaction.FindClaimValue(ClaimTypes.Name)); + Assert.Null(transaction.FindClaimValue(ClaimTypes.Name)); } [Fact] @@ -1103,7 +1103,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } else if (req.Path == new PathString("/unauthorized")) { - // Simulate Authorization failure + // Simulate Authorization failure var result = await context.AuthenticateAsync("Google"); await context.ChallengeAsync("Google"); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index df51faf882..98d727fde5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -1,11 +1,13 @@  + netcoreapp2.0 true true + @@ -16,14 +18,14 @@ - - + + + + + - - - diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index dd48f7c956..2381fd6cd7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -73,6 +73,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } + [Fact] public async Task ThrowsIfCallbackPathMissing() { var server = CreateServer( @@ -118,6 +119,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } + [Fact] public async Task ThrowsIfAuthorizationEndpointMissing() { var server = CreateServer( diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs index 8eeedde0da..41429cd377 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs @@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Authentication var identity = (ClaimsIdentity) readTicket.Principal.Identity; Assert.NotNull(identity.Actor); - Assert.Equal(identity.Actor.AuthenticationType, "actor"); + Assert.Equal("actor", identity.Actor.AuthenticationType); } } @@ -113,17 +113,17 @@ namespace Microsoft.AspNetCore.Authentication var readClaim = readTicket.Principal.FindFirst("type"); Assert.NotNull(claim); - Assert.Equal(claim.Type, "type"); - Assert.Equal(claim.Value, "value"); - Assert.Equal(claim.ValueType, "valueType"); - Assert.Equal(claim.Issuer, "issuer"); - Assert.Equal(claim.OriginalIssuer, "original-issuer"); + Assert.Equal("type", claim.Type); + Assert.Equal("value", claim.Value); + Assert.Equal("valueType", claim.ValueType); + Assert.Equal("issuer", claim.Issuer); + Assert.Equal("original-issuer", claim.OriginalIssuer); var property1 = readClaim.Properties["property-1"]; - Assert.Equal(property1, "property-value"); + Assert.Equal("property-value", property1); var property2 = readClaim.Properties["property-2"]; - Assert.Equal(property2, string.Empty); + Assert.Equal(string.Empty, property2); } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs index fb7ea34436..afdef0a408 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -45,9 +45,9 @@ namespace Microsoft.AspNetCore.Authentication props.StoreTokens(new[] { new AuthenticationToken { Name = "Zero", Value = "0" } }); Assert.Equal("0", props.GetTokenValue("Zero")); - Assert.Equal(null, props.GetTokenValue("One")); - Assert.Equal(null, props.GetTokenValue("Two")); - Assert.Equal(null, props.GetTokenValue("Three")); + Assert.Null(props.GetTokenValue("One")); + Assert.Null(props.GetTokenValue("Two")); + Assert.Null(props.GetTokenValue("Three")); Assert.Equal(1, props.GetTokens().Count()); } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 7b0fc8c8b9..246eed9a50 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -106,6 +106,7 @@ namespace Microsoft.AspNetCore.Authorization.Test Assert.True(allowed); } + [Fact] public async Task Authorize_ShouldInvokeAllHandlersByDefault() { // Arrange @@ -1152,4 +1153,4 @@ namespace Microsoft.AspNetCore.Authorization.Test } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index a2d4a61dea..a9ba71a797 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -1,19 +1,22 @@  + netcoreapp2.0 + - - + + + + + - - - + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 6ca53f519c..7908e98fcb 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -1,20 +1,20 @@  + netcoreapp2.0 + + + - - - - diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index 34224e21f1..b7b2c6afe0 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -6,16 +6,18 @@ true true + - - + + + + + - - - + From 1f5a27e20adf5438adcd9caf8587230307b685ce Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 17 May 2017 14:05:27 -0700 Subject: [PATCH 725/900] Switch to Options Initializer --- samples/SocialSample/Startup.cs | 4 - .../CookieAuthenticationHandler.cs | 33 ----- .../CookieAuthenticationInitializer.cs | 60 +++++++++ .../CookieAuthenticationOptions.cs | 7 +- .../CookieExtensions.cs | 11 +- .../FacebookExtensions.cs | 2 +- .../FacebookHandler.cs | 5 +- .../GoogleExtensions.cs | 2 +- .../GoogleHandler.cs | 5 +- .../JwtBearerExtensions.cs | 2 + .../JwtBearerHandler.cs | 43 ------- .../JwtBearerInitializer.cs | 63 ++++++++++ .../MicrosoftAccountExtensions.cs | 2 +- .../MicrosoftAccountHandler.cs | 5 +- .../Events/OAuthCreatingTicketContext.cs | 2 +- .../OAuthExtensions.cs | 19 ++- .../OAuthHandler.cs | 27 +---- .../OAuthInitializer.cs | 45 +++++++ .../OpenIdConnectExtensions.cs | 4 +- .../OpenIdConnectHandler.cs | 93 +------------- .../OpenIdConnectInitializer.cs | 114 ++++++++++++++++++ .../OpenIdConnectOptions.cs | 1 - .../TwitterExtensions.cs | 4 +- .../TwitterHandler.cs | 40 ++---- .../TwitterInitializer.cs | 51 ++++++++ .../AuthenticationHandler.cs | 24 +--- .../AuthenticationSchemeOptions.cs | 24 ++-- ...thenticationServiceCollectionExtensions.cs | 25 ++++ .../RemoteAuthenticationHandler.cs | 26 +--- .../FacebookTests.cs | 2 - .../GoogleTests.cs | 2 - .../JwtBearerTests.cs | 6 +- .../MicrosoftAccountTests.cs | 2 - .../OpenIdConnect/OpenIdConnectTests.cs | 2 + .../TwitterTests.cs | 2 - 35 files changed, 434 insertions(+), 325 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 22c44b3ea7..ffffa46460 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -75,7 +75,6 @@ namespace SocialSample // https://console.developers.google.com/project services.AddOAuthAuthentication("Google-AccessToken", o => { - o.DisplayName = "Google-AccessToken"; o.ClientId = Configuration["google:clientid"]; o.ClientSecret = Configuration["google:clientsecret"]; o.CallbackPath = new PathString("/signin-google-token"); @@ -137,7 +136,6 @@ namespace SocialSample // https://apps.dev.microsoft.com/ services.AddOAuthAuthentication("Microsoft-AccessToken", o => { - o.DisplayName = "MicrosoftAccount-AccessToken"; o.ClientId = Configuration["microsoftaccount:clientid"]; o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; o.CallbackPath = new PathString("/signin-microsoft-token"); @@ -160,7 +158,6 @@ namespace SocialSample // https://github.com/settings/applications/ services.AddOAuthAuthentication("GitHub-AccessToken", o => { - o.DisplayName = "Github-AccessToken"; o.ClientId = Configuration["github-token:clientid"]; o.ClientSecret = Configuration["github-token:clientsecret"]; o.CallbackPath = new PathString("/signin-github-token"); @@ -178,7 +175,6 @@ namespace SocialSample // https://github.com/settings/applications/ services.AddOAuthAuthentication("GitHub", o => { - o.DisplayName = "Github"; o.ClientId = Configuration["github:clientid"]; o.ClientSecret = Configuration["github:clientsecret"]; o.CallbackPath = new PathString("/signin-github"); diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 017e7911cc..5a4ffc547c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -59,39 +59,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// A new instance of the events instance. protected override Task CreateEventsAsync() => Task.FromResult(new CookieAuthenticationEvents()); - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (String.IsNullOrEmpty(Options.CookieName)) - { - Options.CookieName = CookieAuthenticationDefaults.CookiePrefix + Scheme.Name; - } - if (Options.TicketDataFormat == null) - { - var provider = Options.DataProtectionProvider ?? Context.RequestServices.GetRequiredService(); - // Note: the purpose for the data protector must remain fixed for interop to work. - var dataProtector = provider.CreateProtector("Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", Scheme.Name, "v2"); - Options.TicketDataFormat = new TicketDataFormat(dataProtector); - } - if (Options.CookieManager == null) - { - Options.CookieManager = new ChunkingCookieManager(); - } - if (!Options.LoginPath.HasValue) - { - Options.LoginPath = CookieAuthenticationDefaults.LoginPath; - } - if (!Options.LogoutPath.HasValue) - { - Options.LogoutPath = CookieAuthenticationDefaults.LogoutPath; - } - if (!Options.AccessDeniedPath.HasValue) - { - Options.AccessDeniedPath = CookieAuthenticationDefaults.AccessDeniedPath; - } - } - private Task EnsureCookieTicket() { // We only need to read the ticket once diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs new file mode 100644 index 0000000000..af4a85b191 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs @@ -0,0 +1,60 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.Cookies +{ + /// + /// Used to setup defaults for all . + /// + public class CookieAuthenticationInitializer : IInitializeOptions + { + private readonly IDataProtectionProvider _dp; + + public CookieAuthenticationInitializer(IDataProtectionProvider dataProtection) + { + _dp = dataProtection; + } + + /// + /// Invoked to initialize a TOptions instance. + /// + /// The name of the options instance being initialized. + /// The options instance to initialize. + public void Initialize(string name, CookieAuthenticationOptions options) + { + options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; + + if (String.IsNullOrEmpty(options.CookieName)) + { + options.CookieName = CookieAuthenticationDefaults.CookiePrefix + name; + } + if (options.TicketDataFormat == null) + { + // Note: the purpose for the data protector must remain fixed for interop to work. + var dataProtector = options.DataProtectionProvider.CreateProtector("Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", name, "v2"); + options.TicketDataFormat = new TicketDataFormat(dataProtector); + } + if (options.CookieManager == null) + { + options.CookieManager = new ChunkingCookieManager(); + } + if (!options.LoginPath.HasValue) + { + options.LoginPath = CookieAuthenticationDefaults.LoginPath; + } + if (!options.LogoutPath.HasValue) + { + options.LogoutPath = CookieAuthenticationDefaults.LogoutPath; + } + if (!options.AccessDeniedPath.HasValue) + { + options.AccessDeniedPath = CookieAuthenticationDefaults.AccessDeniedPath; + } + } + + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 56d6ca238a..9b6b51d8eb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -4,6 +4,7 @@ using System; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -71,7 +72,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies public CookieSecurePolicy CookieSecure { get; set; } /// - /// If set this will be used by the CookieAuthenticationMiddleware for data protection. + /// If set this will be used by the CookieAuthenticationHandler for data protection. /// public IDataProtectionProvider DataProtectionProvider { get; set; } @@ -129,9 +130,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// The TicketDataFormat is used to protect and unprotect the identity and other properties which are stored in the - /// cookie value. If it is not provided a default data handler is created using the data protection service contained - /// in the IApplicationBuilder.Properties. The default data protection service is based on machine key when running on ASP.NET, - /// and on DPAPI when running in a different process. + /// cookie value. If not provided one will be created using . /// public ISecureDataFormat TicketDataFormat { get; set; } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index e8a21d01b1..b528dec9cb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -3,6 +3,10 @@ using System; using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Options; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.AspNetCore.Authentication; namespace Microsoft.Extensions.DependencyInjection { @@ -15,7 +19,10 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, Action configureOptions) => services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions); - public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) => - services.AddScheme(authenticationScheme, configureOptions); + public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + { + services.TryAddEnumerable(ServiceDescriptor.Singleton, CookieAuthenticationInitializer>()); + return services.AddScheme(authenticationScheme, configureOptions); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 79d9ac66ca..032be82356 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); + return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 521684d14a..c94048f9b9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -9,7 +9,6 @@ using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -19,8 +18,8 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { internal class FacebookHandler : OAuthHandler { - public FacebookHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, logger, encoder, dataProtection, clock) + public FacebookHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { } protected override async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index 420d14030a..d71e8b461c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); + return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index c699f5cc9d..3a93c5cbf7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -9,7 +9,6 @@ using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -19,8 +18,8 @@ namespace Microsoft.AspNetCore.Authentication.Google { internal class GoogleHandler : OAuthHandler { - public GoogleHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, logger, encoder, dataProtection, clock) + public GoogleHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { } protected override async Task CreateTicketAsync( diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 77ffd76ff4..4f6453bd96 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection @@ -26,6 +27,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { + services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerInitializer>()); return services.AddScheme(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 2ea03a51f0..ec48e3e20b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -40,49 +40,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer protected override Task CreateEventsAsync() => Task.FromResult(new JwtBearerEvents()); - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.Audience)) - { - Options.TokenValidationParameters.ValidAudience = Options.Audience; - } - - if (Options.ConfigurationManager == null) - { - if (Options.Configuration != null) - { - Options.ConfigurationManager = new StaticConfigurationManager(Options.Configuration); - } - else if (!(string.IsNullOrEmpty(Options.MetadataAddress) && string.IsNullOrEmpty(Options.Authority))) - { - if (string.IsNullOrEmpty(Options.MetadataAddress) && !string.IsNullOrEmpty(Options.Authority)) - { - Options.MetadataAddress = Options.Authority; - if (!Options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) - { - Options.MetadataAddress += "/"; - } - - Options.MetadataAddress += ".well-known/openid-configuration"; - } - - if (Options.RequireHttpsMetadata && !Options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); - } - - var httpClient = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - httpClient.Timeout = Options.BackchannelTimeout; - httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - - Options.ConfigurationManager = new ConfigurationManager(Options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), - new HttpDocumentRetriever(httpClient) { RequireHttps = Options.RequireHttpsMetadata }); - } - } - } - /// /// Searches the 'Authorization' header for a 'Bearer' token. If the 'Bearer' token is found, it is validated using set in the options. /// diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs new file mode 100644 index 0000000000..0aeed11832 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs @@ -0,0 +1,63 @@ +// 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.Net.Http; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; + +namespace Microsoft.AspNetCore.Authentication.JwtBearer +{ + /// + /// Used to setup defaults for all . + /// + public class JwtBearerInitializer : IInitializeOptions + { + /// + /// Invoked to initialize a JwtBearerOptions instance. + /// + /// The name of the options instance being initialized. + /// The options instance to initialize. + public void Initialize(string name, JwtBearerOptions options) + { + if (string.IsNullOrEmpty(options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(options.Audience)) + { + options.TokenValidationParameters.ValidAudience = options.Audience; + } + + if (options.ConfigurationManager == null) + { + if (options.Configuration != null) + { + options.ConfigurationManager = new StaticConfigurationManager(options.Configuration); + } + else if (!(string.IsNullOrEmpty(options.MetadataAddress) && string.IsNullOrEmpty(options.Authority))) + { + if (string.IsNullOrEmpty(options.MetadataAddress) && !string.IsNullOrEmpty(options.Authority)) + { + options.MetadataAddress = options.Authority; + if (!options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) + { + options.MetadataAddress += "/"; + } + + options.MetadataAddress += ".well-known/openid-configuration"; + } + + if (options.RequireHttpsMetadata && !options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); + } + + var httpClient = new HttpClient(options.BackchannelHttpHandler ?? new HttpClientHandler()); + httpClient.Timeout = options.BackchannelTimeout; + httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + + options.ConfigurationManager = new ConfigurationManager(options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), + new HttpDocumentRetriever(httpClient) { RequireHttps = options.RequireHttpsMetadata }); + } + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 509016ff29..6ccb392344 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); + return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index b2b787b97c..815b94bf40 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -7,7 +7,6 @@ using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; @@ -16,8 +15,8 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { internal class MicrosoftAccountHandler : OAuthHandler { - public MicrosoftAccountHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, logger, encoder, dataProtection, clock) + public MicrosoftAccountHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { } protected override async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs index f50dff3f55..6e31056392 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -170,7 +170,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth foreach (var action in Options.ClaimActions) { - action.Run(userData, Identity, Options.ClaimsIssuer); + action.Run(userData, Identity, Options.ClaimsIssuer ?? Scheme.Name); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 6fd0f57f4b..408789b037 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -3,13 +3,24 @@ using System; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Options; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.Extensions.DependencyInjection { public static class OAuthExtensions { - public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) => - services.AddScheme>(authenticationScheme, authenticationScheme, configureOptions); + public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + { + return services.AddScheme>(authenticationScheme, authenticationScheme, configureOptions); + } + + public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + where TOptions : OAuthOptions, new() + where THandler : OAuthHandler + { + services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthInitializer>()); + return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index cafc4f0bcf..63bcdbdf2b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -10,7 +10,6 @@ using System.Security.Claims; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -33,30 +32,10 @@ namespace Microsoft.AspNetCore.Authentication.OAuth set { base.Events = value; } } - public OAuthHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, dataProtection, logger, encoder, clock) + public OAuthHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { } - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (Options.Backchannel == null) - { - Options.Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - Options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OAuth handler"); - Options.Backchannel.Timeout = Options.BackchannelTimeout; - Options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - } - - if (Options.StateDataFormat == null) - { - var dataProtector = DataProtection.CreateProtector( - GetType().FullName, Scheme.Name, "v1"); - Options.StateDataFormat = new PropertiesDataFormat(dataProtector); - } - } - /// /// Creates a new instance of the events instance. /// @@ -119,7 +98,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth return AuthenticateResult.Fail("Failed to retrieve access token."); } - var identity = new ClaimsIdentity(Options.ClaimsIssuer); + var identity = new ClaimsIdentity(ClaimsIssuer); if (Options.SaveTokens) { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs new file mode 100644 index 0000000000..99f65253a8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs @@ -0,0 +1,45 @@ +// 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.Net.Http; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Options; + +namespace Microsoft.Extensions.DependencyInjection +{ + /// + /// Used to setup defaults for the OAuthOptions. + /// + public class OAuthInitializer : IInitializeOptions + where TOptions : OAuthOptions, new() + where THandler : OAuthHandler + { + private readonly IDataProtectionProvider _dp; + + public OAuthInitializer(IDataProtectionProvider dataProtection) + { + _dp = dataProtection; + } + + public void Initialize(string name, TOptions options) + { + options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; + if (options.Backchannel == null) + { + options.Backchannel = new HttpClient(options.BackchannelHttpHandler ?? new HttpClientHandler()); + options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OAuth handler"); + options.Backchannel.Timeout = options.BackchannelTimeout; + options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + } + + if (options.StateDataFormat == null) + { + var dataProtector = options.DataProtectionProvider.CreateProtector( + typeof(THandler).FullName, name, "v1"); + options.StateDataFormat = new PropertiesDataFormat(dataProtector); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index 64737a9ad8..c79dc7212d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection @@ -26,7 +27,8 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); + services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectInitializer>()); + return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 69acbf9a06..d51c324dc4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -13,12 +13,10 @@ using System.Security.Cryptography; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; -using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; @@ -57,8 +55,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect protected HtmlEncoder HtmlEncoder { get; } - public OpenIdConnectHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, HtmlEncoder htmlEncoder, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, dataProtection, logger, encoder, clock) + public OpenIdConnectHandler(IOptionsSnapshot options, ILoggerFactory logger, HtmlEncoder htmlEncoder, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { HtmlEncoder = htmlEncoder; } @@ -75,76 +73,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect protected override Task CreateEventsAsync() => Task.FromResult(new OpenIdConnectEvents()); - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (string.IsNullOrEmpty(Options.SignOutScheme)) - { - Options.SignOutScheme = SignInScheme; - } - - if (Options.StateDataFormat == null) - { - var dataProtector = DataProtection.CreateProtector( - GetType().FullName, Scheme.Name, "v1"); - Options.StateDataFormat = new PropertiesDataFormat(dataProtector); - } - - if (Options.StringDataFormat == null) - { - var dataProtector = DataProtection.CreateProtector( - GetType().FullName, - typeof(string).FullName, - Scheme.Name, - "v1"); - - Options.StringDataFormat = new SecureDataFormat(new StringSerializer(), dataProtector); - } - - if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.ClientId)) - { - Options.TokenValidationParameters.ValidAudience = Options.ClientId; - } - - if (Options.Backchannel == null) - { - Options.Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - Options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OpenIdConnect handler"); - Options.Backchannel.Timeout = Options.BackchannelTimeout; - Options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - } - - if (Options.ConfigurationManager == null) - { - if (Options.Configuration != null) - { - Options.ConfigurationManager = new StaticConfigurationManager(Options.Configuration); - } - else if (!(string.IsNullOrEmpty(Options.MetadataAddress) && string.IsNullOrEmpty(Options.Authority))) - { - if (string.IsNullOrEmpty(Options.MetadataAddress) && !string.IsNullOrEmpty(Options.Authority)) - { - Options.MetadataAddress = Options.Authority; - if (!Options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) - { - Options.MetadataAddress += "/"; - } - - Options.MetadataAddress += ".well-known/openid-configuration"; - } - - if (Options.RequireHttpsMetadata && !Options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); - } - - Options.ConfigurationManager = new ConfigurationManager(Options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), - new HttpDocumentRetriever(Backchannel) { RequireHttps = Options.RequireHttpsMetadata }); - } - } - } - public override Task HandleRequestAsync() { if (Options.RemoteSignOutPath.HasValue && Options.RemoteSignOutPath == Request.Path) @@ -749,7 +677,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var identity = (ClaimsIdentity)ticket.Principal.Identity; foreach (var action in Options.ClaimActions) { - action.Run(null, identity, Options.ClaimsIssuer); + action.Run(null, identity, ClaimsIssuer); } } @@ -902,7 +830,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect foreach (var action in Options.ClaimActions) { - action.Run(user, identity, Options.ClaimsIssuer); + action.Run(user, identity, ClaimsIssuer); } return AuthenticateResult.Success(ticket); @@ -1301,18 +1229,5 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect description, errorUri)); } - - private class StringSerializer : IDataSerializer - { - public string Deserialize(byte[] data) - { - return Encoding.UTF8.GetString(data); - } - - public byte[] Serialize(string model) - { - return Encoding.UTF8.GetBytes(model); - } - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs new file mode 100644 index 0000000000..7421af9c0a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs @@ -0,0 +1,114 @@ +// 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.Net.Http; +using System.Text; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; + +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect +{ + /// + /// Used to setup defaults for all . + /// + public class OpenIdConnectInitializer : IInitializeOptions + { + private readonly IDataProtectionProvider _dp; + + public OpenIdConnectInitializer(IDataProtectionProvider dataProtection) + { + _dp = dataProtection; + } + + /// + /// Invoked to initialize a TOptions instance. + /// + /// The name of the options instance being initialized. + /// The options instance to initialize. + public void Initialize(string name, OpenIdConnectOptions options) + { + options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; + + if (string.IsNullOrEmpty(options.SignOutScheme)) + { + options.SignOutScheme = options.SignInScheme; + } + + if (options.StateDataFormat == null) + { + var dataProtector = options.DataProtectionProvider.CreateProtector( + typeof(OpenIdConnectHandler).FullName, name, "v1"); + options.StateDataFormat = new PropertiesDataFormat(dataProtector); + } + + if (options.StringDataFormat == null) + { + var dataProtector = options.DataProtectionProvider.CreateProtector( + typeof(OpenIdConnectHandler).FullName, + typeof(string).FullName, + name, + "v1"); + + options.StringDataFormat = new SecureDataFormat(new StringSerializer(), dataProtector); + } + + if (string.IsNullOrEmpty(options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(options.ClientId)) + { + options.TokenValidationParameters.ValidAudience = options.ClientId; + } + + if (options.Backchannel == null) + { + options.Backchannel = new HttpClient(options.BackchannelHttpHandler ?? new HttpClientHandler()); + options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OpenIdConnect handler"); + options.Backchannel.Timeout = options.BackchannelTimeout; + options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + } + + if (options.ConfigurationManager == null) + { + if (options.Configuration != null) + { + options.ConfigurationManager = new StaticConfigurationManager(options.Configuration); + } + else if (!(string.IsNullOrEmpty(options.MetadataAddress) && string.IsNullOrEmpty(options.Authority))) + { + if (string.IsNullOrEmpty(options.MetadataAddress) && !string.IsNullOrEmpty(options.Authority)) + { + options.MetadataAddress = options.Authority; + if (!options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) + { + options.MetadataAddress += "/"; + } + + options.MetadataAddress += ".well-known/openid-configuration"; + } + + if (options.RequireHttpsMetadata && !options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); + } + + options.ConfigurationManager = new ConfigurationManager(options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), + new HttpDocumentRetriever(options.Backchannel) { RequireHttps = options.RequireHttpsMetadata }); + } + } + } + + private class StringSerializer : IDataSerializer + { + public string Deserialize(byte[] data) + { + return Encoding.UTF8.GetString(data); + } + + public byte[] Serialize(string model) + { + return Encoding.UTF8.GetBytes(model); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 5ca270dde8..b2d69d5249 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -39,7 +39,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// public OpenIdConnectOptions() { - DisplayName = OpenIdConnectDefaults.Caption; CallbackPath = new PathString("/signin-oidc"); SignedOutCallbackPath = new PathString("/signout-callback-oidc"); RemoteSignOutPath = new PathString("/signout-oidc"); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index 1e126d4c4a..3bcc80c3d7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Twitter; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection @@ -26,7 +27,8 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); + services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterInitializer>()); + return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index c166b175af..7ae9f973c1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -40,36 +40,12 @@ namespace Microsoft.AspNetCore.Authentication.Twitter set { base.Events = value; } } - public TwitterHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, dataProtection, logger, encoder, clock) + public TwitterHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { } protected override Task CreateEventsAsync() => Task.FromResult(new TwitterEvents()); - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (Options.StateDataFormat == null) - { - var dataProtector = DataProtection.CreateProtector( - GetType().FullName, Scheme.Name, "v1"); - Options.StateDataFormat = new SecureDataFormat( - new RequestTokenSerializer(), - dataProtector); - } - - if (Options.Backchannel == null) - { - Options.Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - Options.Backchannel.Timeout = Options.BackchannelTimeout; - Options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - Options.Backchannel.DefaultRequestHeaders.Accept.ParseAdd("*/*"); - Options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core Twitter handler"); - Options.Backchannel.DefaultRequestHeaders.ExpectContinue = false; - } - } - protected override async Task HandleRemoteAuthenticateAsync() { AuthenticationProperties properties = null; @@ -116,12 +92,12 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var identity = new ClaimsIdentity(new[] { - new Claim(ClaimTypes.NameIdentifier, accessToken.UserId, ClaimValueTypes.String, Options.ClaimsIssuer), - new Claim(ClaimTypes.Name, accessToken.ScreenName, ClaimValueTypes.String, Options.ClaimsIssuer), - new Claim("urn:twitter:userid", accessToken.UserId, ClaimValueTypes.String, Options.ClaimsIssuer), - new Claim("urn:twitter:screenname", accessToken.ScreenName, ClaimValueTypes.String, Options.ClaimsIssuer) + new Claim(ClaimTypes.NameIdentifier, accessToken.UserId, ClaimValueTypes.String, ClaimsIssuer), + new Claim(ClaimTypes.Name, accessToken.ScreenName, ClaimValueTypes.String, ClaimsIssuer), + new Claim("urn:twitter:userid", accessToken.UserId, ClaimValueTypes.String, ClaimsIssuer), + new Claim("urn:twitter:screenname", accessToken.ScreenName, ClaimValueTypes.String, ClaimsIssuer) }, - Options.ClaimsIssuer); + ClaimsIssuer); JObject user = null; if (Options.RetrieveUserDetails) @@ -145,7 +121,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { foreach (var action in Options.ClaimActions) { - action.Run(user, identity, Options.ClaimsIssuer); + action.Run(user, identity, ClaimsIssuer); } var context = new TwitterCreatingTicketContext(Context, Scheme, Options, properties, token.UserId, token.ScreenName, token.Token, token.TokenSecret, user) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs new file mode 100644 index 0000000000..08e9c5b832 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs @@ -0,0 +1,51 @@ +// 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.Net.Http; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.Twitter +{ + /// + /// Used to setup defaults for all . + /// + public class TwitterInitializer : IInitializeOptions + { + private readonly IDataProtectionProvider _dp; + + public TwitterInitializer(IDataProtectionProvider dataProtection) + { + _dp = dataProtection; + } + + /// + /// Invoked to initialize a TOptions instance. + /// + /// The name of the options instance being initialized. + /// The options instance to initialize. + public void Initialize(string name, TwitterOptions options) + { + options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; + + if (options.StateDataFormat == null) + { + var dataProtector = options.DataProtectionProvider.CreateProtector( + typeof(TwitterHandler).FullName, name, "v1"); + options.StateDataFormat = new SecureDataFormat( + new RequestTokenSerializer(), + dataProtector); + } + + if (options.Backchannel == null) + { + options.Backchannel = new HttpClient(options.BackchannelHttpHandler ?? new HttpClientHandler()); + options.Backchannel.Timeout = options.BackchannelTimeout; + options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + options.Backchannel.DefaultRequestHeaders.Accept.ParseAdd("*/*"); + options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core Twitter handler"); + options.Backchannel.DefaultRequestHeaders.ExpectContinue = false; + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 083884a026..ba1c919fe5 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -48,6 +48,8 @@ namespace Microsoft.AspNetCore.Authentication /// protected virtual object Events { get; set; } + protected virtual string ClaimsIssuer => Options.ClaimsIssuer ?? Scheme.Name; + protected string CurrentUri { get @@ -85,18 +87,6 @@ namespace Microsoft.AspNetCore.Authentication Context = context; Options = OptionsSnapshot.Get(Scheme.Name) ?? new TOptions(); - if (!Options.Initialized) - { - lock (Options.InitializeLock) - { - if (!Options.Initialized) - { - InitializeOptions(); - Options.Initialized = true; - } - } - } - Options.Validate(); await InitializeEventsAsync(); @@ -122,16 +112,6 @@ namespace Microsoft.AspNetCore.Authentication /// A new instance of the events instance. protected virtual Task CreateEventsAsync() => Task.FromResult(new object()); - /// - /// Initializes the options, will be called only once by . - /// - protected virtual void InitializeOptions() - { - // REVIEW: is there a better place for this default? - Options.DisplayName = Options.DisplayName ?? Scheme.Name; - Options.ClaimsIssuer = Options.ClaimsIssuer ?? Scheme.Name; - } - /// /// Called after options/events have been initialized for the handler to finish initializing itself. /// diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs index 09e7abbd4f..55bc09d8ae 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -2,9 +2,18 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication { + public class InitializeAuthenticationSchemeOptions : InitializeOptions + where TOptions : AuthenticationSchemeOptions + { + public InitializeAuthenticationSchemeOptions(string name) + : base(name, options => options.ClaimsIssuer = options.ClaimsIssuer ?? name) + { } + } + /// /// Contains the options used by the . /// @@ -17,11 +26,6 @@ namespace Microsoft.AspNetCore.Authentication { } - /// - /// Gets or sets the display name for the authentication provider. - /// - public string DisplayName { get; set; } - /// /// Gets or sets the issuer that should be used for any claims that are created /// @@ -36,15 +40,5 @@ namespace Microsoft.AspNetCore.Authentication /// If set, will be used as the service type to get the Events instance instead of the property. /// public Type EventsType { get; set; } - - /// - /// Used to ensure that the options are only initialized once. - /// - public bool Initialized { get; set; } - - /// - /// Used to prevent concurrent access during intialization. - /// - public object InitializeLock { get; } = new object(); } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 0315562ffb..ff367f5557 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -74,5 +74,30 @@ namespace Microsoft.Extensions.DependencyInjection where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler => services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); + + public static IServiceCollection AddRemoteScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureOptions) + where TOptions : RemoteAuthenticationOptions, new() + where THandler : RemoteAuthenticationHandler + { + services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); + return services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); + } + + // Used to ensure that there's always a default data protection provider + private class EnsureSignInScheme : IInitializeOptions where TOptions : RemoteAuthenticationOptions + { + private readonly AuthenticationOptions _authOptions; + + public EnsureSignInScheme(IOptions authOptions) + { + _authOptions = authOptions.Value; + } + + public void Initialize(string name, TOptions options) + { + options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme; + } + } + } } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index fc663317e4..bf875a7a04 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -5,9 +5,7 @@ using System; using System.Security.Cryptography; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -25,10 +23,6 @@ namespace Microsoft.AspNetCore.Authentication protected string SignInScheme => Options.SignInScheme; - protected IDataProtectionProvider DataProtection { get; set; } - - private readonly AuthenticationOptions _authOptions; - /// /// The handler calls methods on the events which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. @@ -39,17 +33,9 @@ namespace Microsoft.AspNetCore.Authentication set { base.Events = value; } } - protected RemoteAuthenticationHandler(IOptions sharedOptions, IOptionsSnapshot options, IDataProtectionProvider dataProtection, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + protected RemoteAuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { - _authOptions = sharedOptions.Value; - DataProtection = dataProtection; - } - - protected override Task InitializeHandlerAsync() - { - DataProtection = Options.DataProtectionProvider ?? DataProtection; - return TaskCache.CompletedTask; } protected override Task CreateEventsAsync() @@ -57,16 +43,6 @@ namespace Microsoft.AspNetCore.Authentication return Task.FromResult(new RemoteAuthenticationEvents()); } - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (Options.SignInScheme == null) - { - Options.SignInScheme = _authOptions.DefaultSignInScheme; - } - } - public virtual Task ShouldHandleRequestAsync() { return Task.FromResult(Options.CallbackPath == Request.Path); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index edd9eb5788..060eb649fc 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -50,7 +50,6 @@ namespace Microsoft.AspNetCore.Authentication.Facebook {"Facebook:BackchannelTimeout", "0.0:0:30"}, //{"Facebook:CallbackPath", "/callbackpath"}, // PathString doesn't convert {"Facebook:ClaimsIssuer", ""}, - {"Facebook:DisplayName", ""}, {"Facebook:RemoteAuthenticationTimeout", "0.0:0:30"}, {"Facebook:SaveTokens", "true"}, {"Facebook:SendAppSecretProof", "true"}, @@ -73,7 +72,6 @@ namespace Microsoft.AspNetCore.Authentication.Facebook Assert.Equal("", options.ClaimsIssuer); Assert.Equal("", options.ClientId); Assert.Equal("", options.ClientSecret); - Assert.Equal("", options.DisplayName); Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); Assert.True(options.SaveTokens); Assert.True(options.SendAppSecretProof); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 68ea33462b..2c86bc7781 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -49,7 +49,6 @@ namespace Microsoft.AspNetCore.Authentication.Google {"Google:BackchannelTimeout", "0.0:0:30"}, //{"Google:CallbackPath", "/callbackpath"}, // PathString doesn't convert {"Google:ClaimsIssuer", ""}, - {"Google:DisplayName", ""}, {"Google:RemoteAuthenticationTimeout", "0.0:0:30"}, {"Google:SaveTokens", "true"}, {"Google:SendAppSecretProof", "true"}, @@ -70,7 +69,6 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal("", options.ClaimsIssuer); Assert.Equal("", options.ClientId); Assert.Equal("", options.ClientSecret); - Assert.Equal("", options.DisplayName); Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); Assert.True(options.SaveTokens); Assert.Equal("", options.SignInScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 42efe00dd3..59f1e880c7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -48,11 +48,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer {"Bearer:BackchannelTimeout", "0.0:0:30"}, {"Bearer:Challenge", ""}, {"Bearer:ClaimsIssuer", ""}, - {"Bearer:DisplayName", ""}, {"Bearer:IncludeErrorDetails", "true"}, {"Bearer:MetadataAddress", ""}, {"Bearer:RefreshOnIssuerKeyNotFound", "true"}, - {"Bearer:RequireHttpsMetadata", "true"}, + {"Bearer:RequireHttpsMetadata", "false"}, {"Bearer:SaveToken", "true"}, }; var configurationBuilder = new ConfigurationBuilder(); @@ -67,11 +66,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal("", options.Authority); Assert.Equal("", options.Challenge); Assert.Equal("", options.ClaimsIssuer); - Assert.Equal("", options.DisplayName); Assert.True(options.IncludeErrorDetails); Assert.Equal("", options.MetadataAddress); Assert.True(options.RefreshOnIssuerKeyNotFound); - Assert.True(options.RequireHttpsMetadata); + Assert.False(options.RequireHttpsMetadata); Assert.True(options.SaveToken); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 1f0f394f3c..062215ff46 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -50,7 +50,6 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount {"Microsoft:BackchannelTimeout", "0.0:0:30"}, //{"Microsoft:CallbackPath", "/callbackpath"}, // PathString doesn't convert {"Microsoft:ClaimsIssuer", ""}, - {"Microsoft:DisplayName", ""}, {"Microsoft:RemoteAuthenticationTimeout", "0.0:0:30"}, {"Microsoft:SaveTokens", "true"}, {"Microsoft:SendAppSecretProof", "true"}, @@ -71,7 +70,6 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount Assert.Equal("", options.ClaimsIssuer); Assert.Equal("", options.ClientId); Assert.Equal("", options.ClientSecret); - Assert.Equal("", options.DisplayName); Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); Assert.True(options.SaveTokens); Assert.Equal("", options.SignInScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index a3d7f5130f..b2459cf819 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -36,6 +36,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { {"OpenIdConnect:ClientId", ""}, {"OpenIdConnect:ClientSecret", ""}, + {"OpenIdConnect:RequireHttpsMetadata", "false"}, {"OpenIdConnect:Authority", ""} }; var configurationBuilder = new ConfigurationBuilder(); @@ -48,6 +49,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.Equal("", options.ClientId); Assert.Equal("", options.ClientSecret); Assert.Equal("", options.Authority); + Assert.False(options.RequireHttpsMetadata); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 9993559f69..1acddc5afd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -42,7 +42,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter {"Twitter:BackchannelTimeout", "0.0:0:30"}, //{"Twitter:CallbackPath", "/callbackpath"}, // PathString doesn't convert {"Twitter:ClaimsIssuer", ""}, - {"Twitter:DisplayName", ""}, {"Twitter:RemoteAuthenticationTimeout", "0.0:0:30"}, {"Twitter:SaveTokens", "true"}, {"Twitter:SendAppSecretProof", "true"}, @@ -60,7 +59,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter Assert.Equal("", options.ClaimsIssuer); Assert.Equal("", options.ConsumerKey); Assert.Equal("", options.ConsumerSecret); - Assert.Equal("", options.DisplayName); Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); Assert.True(options.SaveTokens); Assert.Equal("", options.SignInScheme); From 2a4a7dd26af2f55a3d8be67fd5d12840d229b0b6 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 22 May 2017 10:01:44 -0700 Subject: [PATCH 726/900] Make samples work. Fix AddOAuthAuthentication extension. (#1226) --- samples/CookieSample/Startup.cs | 7 +++++++ samples/CookieSessionSample/Startup.cs | 7 +++++++ samples/JwtBearerSample/Startup.cs | 7 +++++++ .../OpenIdConnectSample/OpenIdConnectSample.csproj | 10 +++++++++- samples/OpenIdConnectSample/Program.cs | 14 +++++--------- samples/SocialSample/Program.cs | 14 +++++--------- samples/SocialSample/SocialSample.csproj | 10 +++++++++- samples/SocialSample/Startup.cs | 10 +++++----- .../OAuthExtensions.cs | 2 +- 9 files changed, 55 insertions(+), 26 deletions(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 3aebb419f8..79d1b3c3fe 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -13,6 +13,13 @@ namespace CookieSample { public void ConfigureServices(IServiceCollection services) { + // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + services.AddCookieAuthentication(); } diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 9ad9e6841e..c35dfd9998 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -14,6 +14,13 @@ namespace CookieSessionSample { public void ConfigureServices(IServiceCollection services) { + // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + services.AddCookieAuthentication(o => o.SessionStore = new MemoryCacheTicketStore()); } diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 9df41a9ab7..030e640c99 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -43,6 +43,13 @@ namespace JwtBearerSample // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { + // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + }); + services.AddJwtBearerAuthentication(o => { // You also need to update /wwwroot/app/scripts/app.js diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index e69563ced1..875762d126 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,4 +1,4 @@ - + @@ -7,6 +7,10 @@ aspnet5-OpenIdConnectSample-20151210110318 + + + + @@ -25,4 +29,8 @@ + + + + diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs index b4d24505d5..87e7755084 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -23,16 +23,12 @@ namespace OpenIdConnectSample }) .UseKestrel(options => { - if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + options.Listen(IPAddress.Loopback, 44318, listenOptions => { - // ANCM is not hosting the process - options.Listen(IPAddress.Loopback, 44318, listenOptions => - { - // Configure SSL - var serverCertificate = LoadCertificate(); - listenOptions.UseHttps(serverCertificate); - }); - } + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/SocialSample/Program.cs b/samples/SocialSample/Program.cs index 96bce512d5..a712b6c03f 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -21,16 +21,12 @@ namespace SocialSample }) .UseKestrel(options => { - if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + options.Listen(IPAddress.Loopback, 44318, listenOptions => { - // ANCM is not hosting the process - options.Listen(IPAddress.Loopback, 44318, listenOptions => - { - // Configure SSL - var serverCertificate = LoadCertificate(); - listenOptions.UseHttps(serverCertificate); - }); - } + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index e0336cc0e3..723d74de32 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,4 +1,4 @@ - + @@ -7,6 +7,14 @@ aspnet5-SocialSample-20151210111056 + + + + + + + + diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index ffffa46460..0039720096 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -164,11 +164,6 @@ namespace SocialSample o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; o.TokenEndpoint = "https://github.com/login/oauth/access_token"; o.SaveTokens = true; - o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); - o.ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); - o.ClaimActions.MapJsonKey("urn:github:name", "name"); - o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); - o.ClaimActions.MapJsonKey("urn:github:url", "url"); }); // You must first create an app with GitHub and add its ID and Secret to your user-secrets. @@ -184,6 +179,11 @@ namespace SocialSample o.ClaimsIssuer = "OAuth2-Github"; o.SaveTokens = true; // Retrieving user information is unique to each provider. + o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); + o.ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); + o.ClaimActions.MapJsonKey("urn:github:name", "name"); + o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); + o.ClaimActions.MapJsonKey("urn:github:url", "url"); o.Events = new OAuthEvents { OnCreatingTicket = async context => diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 408789b037..257aed9cb1 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.DependencyInjection { public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme>(authenticationScheme, authenticationScheme, configureOptions); + return services.AddOAuthAuthentication>(authenticationScheme, configureOptions); } public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) From 769da5fd8768ae1ceab0c77b5af2ca394aa1d812 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 18 May 2017 20:12:41 -0700 Subject: [PATCH 727/900] Add SameSitePolicy to CookiePolicyMiddleware --- .../ChunkingCookieManager.cs | 7 +- .../CookieAuthenticationHandler.cs | 1 + .../CookieAuthenticationOptions.cs | 8 +- .../OpenIdConnectHandler.cs | 2 + .../TwitterHandler.cs | 2 + .../RemoteAuthenticationHandler.cs | 2 + .../CookiePolicyMiddleware.cs | 20 ++- .../CookiePolicyOptions.cs | 5 + .../CookieTests.cs | 5 + .../CookieChunkingTests.cs | 38 +++--- .../CookiePolicyTests.cs | 126 ++++++++++++++---- 11 files changed, 165 insertions(+), 51 deletions(-) diff --git a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs index 16426507ce..9b602383cf 100644 --- a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs +++ b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Internal /// /// The default maximum size of characters in a cookie to send back to the client. /// - public const int DefaultChunkSize = 4070; + public const int DefaultChunkSize = 4050; private const string ChunkKeySuffix = "C"; private const string ChunkCountPrefix = "chunks-"; @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Internal { // Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case. // See http://browsercookielimits.x64.me/. - // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. + // Leave at least 40 in case CookiePolicy tries to add 'secure', 'samesite=strict' and/or 'httponly'. ChunkSize = DefaultChunkSize; ThrowForPartialCookies = true; } @@ -166,6 +166,7 @@ namespace Microsoft.AspNetCore.Internal { Domain = options.Domain, Expires = options.Expires, + SameSite = (Net.Http.Headers.SameSiteMode)options.SameSite, HttpOnly = options.HttpOnly, Path = options.Path, Secure = options.Secure, @@ -284,6 +285,7 @@ namespace Microsoft.AspNetCore.Internal { Path = options.Path, Domain = options.Domain, + SameSite = options.SameSite, Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), }); @@ -297,6 +299,7 @@ namespace Microsoft.AspNetCore.Internal { Path = options.Path, Domain = options.Domain, + SameSite = options.SameSite, Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), }); } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 5a4ffc547c..13a20e55b9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -179,6 +179,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var cookieOptions = new CookieOptions { Domain = Options.CookieDomain, + SameSite = Options.CookieSameSite, HttpOnly = Options.CookieHttpOnly, Path = Options.CookiePath ?? (OriginalPathBase.HasValue ? OriginalPathBase.ToString() : "/"), }; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 9b6b51d8eb..02d0361b72 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -4,7 +4,6 @@ using System; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -23,6 +22,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; + CookieSameSite = SameSiteMode.Strict; CookieHttpOnly = true; CookieSecure = CookieSecurePolicy.SameAsRequest; Events = new CookieAuthenticationEvents(); @@ -57,6 +57,12 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// public string CookiePath { get; set; } + /// + /// Determines if the browser should allow the cookie to be attached to same-site or cross-site requests. The + /// default is Strict, which means the cookie is only allowed to be attached to same-site requests. + /// + public SameSiteMode CookieSameSite { get; set; } + /// /// Determines if the browser should allow the cookie to be accessed by client-side javascript. The /// default is true, which means the cookie will only be passed to http requests and is not made available diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index d51c324dc4..04359142a6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -899,6 +899,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect new CookieOptions { HttpOnly = true, + SameSite = Http.SameSiteMode.Lax, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) }); @@ -930,6 +931,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = Http.SameSiteMode.Lax, Secure = Request.IsHttps }; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 7ae9f973c1..ff054d3c6f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -83,6 +83,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = SameSiteMode.Lax, Secure = Request.IsHttps }; @@ -160,6 +161,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = SameSiteMode.Lax, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index bf875a7a04..a7de95dfed 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -203,6 +203,7 @@ namespace Microsoft.AspNetCore.Authentication var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = SameSiteMode.Lax, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; @@ -242,6 +243,7 @@ namespace Microsoft.AspNetCore.Authentication var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = SameSiteMode.Lax, Secure = Request.IsHttps }; Response.Cookies.Delete(cookieName, cookieOptions); diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs index 46daaad810..92adac9677 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.CookiePolicy private bool PolicyRequiresCookieOptions() { - return Policy.HttpOnly != HttpOnlyPolicy.None || Policy.Secure != CookieSecurePolicy.None; + return Policy.MinimumSameSitePolicy != SameSiteMode.None || Policy.HttpOnly != HttpOnlyPolicy.None || Policy.Secure != CookieSecurePolicy.None; } public void Append(string key, string value) @@ -151,6 +151,22 @@ namespace Microsoft.AspNetCore.CookiePolicy default: throw new InvalidOperationException(); } + switch (Policy.MinimumSameSitePolicy) + { + case SameSiteMode.None: + break; + case SameSiteMode.Lax: + if (options.SameSite == SameSiteMode.None) + { + options.SameSite = SameSiteMode.Lax; + } + break; + case SameSiteMode.Strict: + options.SameSite = SameSiteMode.Strict; + break; + default: + throw new InvalidOperationException($"Unrecognized {nameof(SameSiteMode)} value {Policy.MinimumSameSitePolicy.ToString()}"); + } switch (Policy.HttpOnly) { case HttpOnlyPolicy.Always: @@ -159,7 +175,7 @@ namespace Microsoft.AspNetCore.CookiePolicy case HttpOnlyPolicy.None: break; default: - throw new InvalidOperationException(); + throw new InvalidOperationException($"Unrecognized {nameof(HttpOnlyPolicy)} value {Policy.HttpOnly.ToString()}"); } } } diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index 6aed18bfb0..7203e73e69 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -12,6 +12,11 @@ namespace Microsoft.AspNetCore.Builder /// public class CookiePolicyOptions { + /// + /// Affects the cookie's same site attribute. + /// + public SameSiteMode MinimumSameSitePolicy { get; set; } = SameSiteMode.Strict; + /// /// Affects whether cookies must be HttpOnly. /// diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 419d82493d..e38dc15870 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -136,6 +136,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.StartsWith("TestCookie=", setCookie); Assert.Contains("; path=/", setCookie); Assert.Contains("; httponly", setCookie); + Assert.Contains("; samesite=", setCookie); Assert.DoesNotContain("; expires=", setCookie); Assert.DoesNotContain("; domain=", setCookie); Assert.DoesNotContain("; secure", setCookie); @@ -206,6 +207,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies o.CookiePath = "/foo"; o.CookieDomain = "another.com"; o.CookieSecure = CookieSecurePolicy.Always; + o.CookieSameSite = SameSiteMode.None; o.CookieHttpOnly = true; }, SignInAsAlice, baseAddress: new Uri("http://example.com/base")); @@ -217,12 +219,14 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Contains(" path=/foo", setCookie1); Assert.Contains(" domain=another.com", setCookie1); Assert.Contains(" secure", setCookie1); + Assert.DoesNotContain(" samesite", setCookie1); Assert.Contains(" httponly", setCookie1); var server2 = CreateServer(o => { o.CookieName = "SecondCookie"; o.CookieSecure = CookieSecurePolicy.None; + o.CookieSameSite = SameSiteMode.Strict; o.CookieHttpOnly = false; }, SignInAsAlice, baseAddress: new Uri("http://example.com/base")); @@ -232,6 +236,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Contains("SecondCookie=", setCookie2); Assert.Contains(" path=/base", setCookie2); + Assert.Contains(" samesite=strict", setCookie2); Assert.DoesNotContain(" domain=", setCookie2); Assert.DoesNotContain(" secure", setCookie2); Assert.DoesNotContain(" httponly", setCookie2); diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs index c978d169e4..143e1d254c 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Internal new ChunkingCookieManager() { ChunkSize = null }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); var values = context.Response.Headers["Set-Cookie"]; Assert.Equal(1, values.Count); - Assert.Equal("TestCookie=" + testString + "; path=/", values[0]); + Assert.Equal("TestCookie=" + testString + "; path=/; samesite=lax", values[0]); } [Fact] @@ -27,20 +27,20 @@ namespace Microsoft.AspNetCore.Internal HttpContext context = new DefaultHttpContext(); string testString = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - new ChunkingCookieManager() { ChunkSize = 30 }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); + new ChunkingCookieManager() { ChunkSize = 44 }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); var values = context.Response.Headers["Set-Cookie"]; Assert.Equal(9, values.Count); Assert.Equal(new[] { - "TestCookie=chunks-8; path=/", - "TestCookieC1=abcdefgh; path=/", - "TestCookieC2=ijklmnop; path=/", - "TestCookieC3=qrstuvwx; path=/", - "TestCookieC4=yz012345; path=/", - "TestCookieC5=6789ABCD; path=/", - "TestCookieC6=EFGHIJKL; path=/", - "TestCookieC7=MNOPQRST; path=/", - "TestCookieC8=UVWXYZ; path=/", + "TestCookie=chunks-8; path=/; samesite=lax", + "TestCookieC1=abcdefgh; path=/; samesite=lax", + "TestCookieC2=ijklmnop; path=/; samesite=lax", + "TestCookieC3=qrstuvwx; path=/; samesite=lax", + "TestCookieC4=yz012345; path=/; samesite=lax", + "TestCookieC5=6789ABCD; path=/; samesite=lax", + "TestCookieC6=EFGHIJKL; path=/; samesite=lax", + "TestCookieC7=MNOPQRST; path=/; samesite=lax", + "TestCookieC8=UVWXYZ; path=/; samesite=lax", }, values); } @@ -116,14 +116,14 @@ namespace Microsoft.AspNetCore.Internal Assert.Equal(8, cookies.Count); Assert.Equal(new[] { - "TestCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC1=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC2=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC3=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC4=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC5=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC6=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC7=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", + "TestCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC1=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC2=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC3=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC4=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC5=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC6=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC7=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", }, cookies); } } diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index e45c7f6909..737c12dc39 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -36,6 +36,15 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test context.Response.Cookies.Append("D", "D", new CookieOptions { HttpOnly = true }); return Task.FromResult(0); }; + private RequestDelegate SameSiteCookieAppends = context => + { + context.Response.Cookies.Append("A", "A"); + context.Response.Cookies.Append("B", "B", new CookieOptions { SameSite = Http.SameSiteMode.None }); + context.Response.Cookies.Append("C", "C", new CookieOptions()); + context.Response.Cookies.Append("D", "D", new CookieOptions { SameSite = Http.SameSiteMode.Lax }); + context.Response.Cookies.Append("E", "E", new CookieOptions { SameSite = Http.SameSiteMode.Strict }); + return Task.FromResult(0); + }; [Fact] public async Task SecureAlwaysSetsSecure() @@ -50,10 +59,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; secure", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; secure", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; secure", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; secure; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; secure; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; secure; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); })); } @@ -70,10 +79,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); })); } @@ -90,19 +99,19 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=strict", transaction.SetCookie[3]); }), new RequestTest("https://example.com/secureSame", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; secure", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; secure", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; secure", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; secure; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; secure; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; secure; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); })); } @@ -119,10 +128,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; httponly", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; httponly", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; httponly", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; httponly", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=strict; httponly", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=strict; httponly", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=strict; httponly", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=strict; httponly", transaction.SetCookie[3]); })); } @@ -137,12 +146,75 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test HttpCookieAppends, new RequestTest("http://example.com/httpOnlyNone", transaction => + { + Assert.NotNull(transaction.SetCookie); + Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=strict; httponly", transaction.SetCookie[3]); + })); + } + + [Fact] + public async Task SameSiteStrictSetsItAlways() + { + await RunTest("/sameSiteStrict", + new CookiePolicyOptions + { + MinimumSameSitePolicy = Http.SameSiteMode.Strict + }, + SameSiteCookieAppends, + new RequestTest("http://example.com/sameSiteStrict", + transaction => + { + Assert.NotNull(transaction.SetCookie); + Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("E=E; path=/; samesite=strict", transaction.SetCookie[4]); + })); + } + + [Fact] + public async Task SameSiteLaxSetsItAlways() + { + await RunTest("/sameSiteLax", + new CookiePolicyOptions + { + MinimumSameSitePolicy = Http.SameSiteMode.Lax + }, + SameSiteCookieAppends, + new RequestTest("http://example.com/sameSiteLax", + transaction => + { + Assert.NotNull(transaction.SetCookie); + Assert.Equal("A=A; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=lax", transaction.SetCookie[3]); + Assert.Equal("E=E; path=/; samesite=strict", transaction.SetCookie[4]); + })); + } + + [Fact] + public async Task SameSiteNoneLeavesItAlone() + { + await RunTest("/sameSiteNone", + new CookiePolicyOptions + { + MinimumSameSitePolicy = Http.SameSiteMode.None + }, + SameSiteCookieAppends, + new RequestTest("http://example.com/sameSiteNone", + transaction => { Assert.NotNull(transaction.SetCookie); Assert.Equal("A=A; path=/", transaction.SetCookie[0]); Assert.Equal("B=B; path=/", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; httponly", transaction.SetCookie[3]); + Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=lax", transaction.SetCookie[3]); + Assert.Equal("E=E; path=/; samesite=strict", transaction.SetCookie[4]); })); } @@ -170,10 +242,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test var transaction = await server.SendAsync("http://example.com/login"); Assert.NotNull(transaction.SetCookie); - Assert.Equal("Hao=Hao; path=/", transaction.SetCookie[0]); - Assert.Equal("Hao=Hao; path=/", transaction.SetCookie[1]); - Assert.Equal("Hao=Hao; path=/", transaction.SetCookie[2]); - Assert.Equal("Hao=Hao; path=/; secure", transaction.SetCookie[3]); + Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("Hao=Hao; path=/; secure; samesite=strict", transaction.SetCookie[3]); } [Fact] @@ -201,7 +273,7 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test Assert.NotNull(transaction.SetCookie); Assert.Equal(1, transaction.SetCookie.Count); - Assert.Equal("A=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/", transaction.SetCookie[0]); + Assert.Equal("A=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax", transaction.SetCookie[0]); } [Fact] From 30392a1811d45b41ffb12c0c57e4df6cac51e1fb Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 24 May 2017 09:24:08 -0700 Subject: [PATCH 728/900] Retarget to netstandard2.0 and net461 --- Security.sln | 48 ++- build/common.props | 4 +- build/dependencies.props | 4 +- build/repo.props | 1 + samples/CookieSample/CookieSample.csproj | 8 +- .../CookieSessionSample.csproj | 8 +- .../JwtBearerSample/JwtBearerSample.csproj | 8 +- .../OpenIdConnect.AzureAdSample.csproj | 6 +- .../OpenIdConnectSample.csproj | 6 +- samples/SocialSample/SocialSample.csproj | 6 +- ...t.AspNetCore.Authentication.Cookies.csproj | 2 +- ....AspNetCore.Authentication.Facebook.csproj | 2 +- ...ft.AspNetCore.Authentication.Google.csproj | 2 +- ...AspNetCore.Authentication.JwtBearer.csproj | 2 +- ...ore.Authentication.MicrosoftAccount.csproj | 2 +- ...oft.AspNetCore.Authentication.OAuth.csproj | 2 +- ...etCore.Authentication.OpenIdConnect.csproj | 2 +- ...t.AspNetCore.Authentication.Twitter.csproj | 2 +- ...Microsoft.AspNetCore.Authentication.csproj | 4 +- .../Microsoft.AspNetCore.Authorization.csproj | 2 +- .../Microsoft.AspNetCore.CookiePolicy.csproj | 2 +- .../AspNetTicketDataFormat.cs | 17 + .../AspNetTicketSerializer.cs | 220 +++++++++++ .../ChunkingCookieManager.cs | 281 +++++++++++++ .../Constants.cs | 13 + .../DataProtectorShim.cs | 31 ++ .../Microsoft.Owin.Security.Interop.csproj | 18 + .../Properties/AssemblyInfo.cs | 8 + .../baseline.netframework.json | 373 ++++++++++++++++++ ...soft.AspNetCore.Authentication.Test.csproj | 6 +- ...osoft.AspNetCore.Authorization.Test.csproj | 3 +- ....ChunkingCookieManager.Sources.Test.csproj | 3 +- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 5 +- .../CookieInteropTests.cs | 332 ++++++++++++++++ ...icrosoft.Owin.Security.Interop.Test.csproj | 26 ++ .../TicketInteropTests.cs | 91 +++++ 36 files changed, 1517 insertions(+), 33 deletions(-) create mode 100644 src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs create mode 100644 src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs create mode 100644 src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs create mode 100644 src/Microsoft.Owin.Security.Interop/Constants.cs create mode 100644 src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs create mode 100644 src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj create mode 100644 src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.Owin.Security.Interop/baseline.netframework.json create mode 100644 test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs create mode 100644 test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj create mode 100644 test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs diff --git a/Security.sln b/Security.sln index 157849c911..b9e6ac5672 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26403.7 +VisualStudioVersion = 15.0.26510.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -46,10 +46,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtBearerSample", "samples\JwtBearerSample\JwtBearerSample.csproj", "{D399B84F-591B-4E98-92BA-B0F63E7B6957}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Owin.Security.Interop", "src\Microsoft.Owin.Security.Interop\Microsoft.Owin.Security.Interop.csproj", "{A7922DD8-09F1-43E4-938B-CC523EA08898}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Owin.Security.Interop.Test", "test\Microsoft.Owin.Security.Interop.Test\Microsoft.Owin.Security.Interop.Test.csproj", "{A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenIdConnect.AzureAdSample", "samples\OpenIdConnect.AzureAdSample\OpenIdConnect.AzureAdSample.csproj", "{3A7AD414-EBDE-4F92-B307-4E8F19B6117E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test", "test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj", "{51563775-C659-4907-9BAF-9995BAB87D01}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86BD08B1-F978-4F58-9982-2A017807F01C}" + ProjectSection(SolutionItems) = preProject + build\common.props = build\common.props + build\dependencies.props = build\dependencies.props + build\Key.snk = build\Key.snk + build\repo.props = build\repo.props + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -360,6 +372,38 @@ Global {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x64.Build.0 = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.ActiveCfg = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x64.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x64.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x64.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x64.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x64.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x64.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x64.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x64.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.Build.0 = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.Build.0 = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -416,6 +460,8 @@ Global {1790E052-646F-4529-B90E-6FEA95520D69} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {2755BFE5-7421-4A31-A644-F817DF5CAA98} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {D399B84F-591B-4E98-92BA-B0F63E7B6957} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} + {A7922DD8-09F1-43E4-938B-CC523EA08898} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} EndGlobalSection diff --git a/build/common.props b/build/common.props index 3f55ba5b33..dc4ad9a786 100644 --- a/build/common.props +++ b/build/common.props @@ -16,8 +16,8 @@ - - + + diff --git a/build/dependencies.props b/build/dependencies.props index 74d501f7cd..f7e538a504 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,11 +1,13 @@ 2.0.0-* + 4.4.0-* 3.13.8 2.1.3 2.1.0-* 10.0.1 - $(BundledNETStandardPackageVersion) + 2.0.0-* + 3.0.1 15.3.0-* 2.3.0-beta2-* diff --git a/build/repo.props b/build/repo.props index 396aed1f53..d4bab3eebd 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,5 @@ + diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 27fa4ca17b..d251b844e1 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,9 +1,9 @@ - + - netcoreapp2.0 + net461;netcoreapp2.0 @@ -19,4 +19,8 @@ + + + + diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 2a838df7e4..a2d0490f1a 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,9 +1,9 @@ - + - netcoreapp2.0 + net461;netcoreapp2.0 @@ -19,4 +19,8 @@ + + + + diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 86b04d587c..c2f73fd961 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,9 +1,9 @@ - + - netcoreapp2.0 + net461;netcoreapp2.0 aspnet5-JwtBearerSample-20151210102827 @@ -20,4 +20,8 @@ + + + + diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 78ba03c2af..7857249087 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + net461;netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 @@ -23,4 +23,8 @@ + + + + diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 875762d126..03384f567e 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + net461;netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 @@ -33,4 +33,8 @@ + + + + diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 723d74de32..999dc91a6f 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + net461;netcoreapp2.0 aspnet5-SocialSample-20151210111056 @@ -35,4 +35,8 @@ + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index a5728fbabc..41c4ff7905 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to use cookie based authentication. - netcoreapp2.0 + netstandard2.0 $(DefineConstants);SECURITY $(NoWarn);CS1591 true diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index 19ec83413c..e39b31e904 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index e403fe4a95..c4f1e7ad8f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -4,7 +4,7 @@ ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index c2b99e47db..5b25e00e86 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 4d91e0da1e..1a954c850a 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 8e33372c1f..508c815fe8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index b3829b59dc..0ce2fe34e0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 5dd58d680c..b78de6597f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 54b560702a..cbdb05b58a 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -4,7 +4,7 @@ ASP.NET Core common types used by the various authentication middleware components. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security @@ -18,7 +18,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index b39a7bf3dd..93673ef007 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -7,7 +7,7 @@ Commonly used types: Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute Microsoft.AspNetCore.Authorization.AuthorizeAttribute - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authorization diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 31ce5b761a..5dc2cd9281 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -4,7 +4,7 @@ ASP.NET Core cookie policy classes to control the behavior of cookies. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs new file mode 100644 index 0000000000..f1a07c5bf7 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Owin.Security.DataHandler; +using Microsoft.Owin.Security.DataHandler.Encoder; +using Microsoft.Owin.Security.DataProtection; + +namespace Microsoft.Owin.Security.Interop +{ + public class AspNetTicketDataFormat : SecureDataFormat + { + public AspNetTicketDataFormat(IDataProtector protector) + : base(AspNetTicketSerializer.Default, protector, TextEncodings.Base64Url) + { + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs new file mode 100644 index 0000000000..6a1019fbc8 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs @@ -0,0 +1,220 @@ +// Copyright (c) Microsoft Open Technologies, Inc. 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.IO; +using System.Linq; +using System.Security.Claims; +using Microsoft.Owin.Security.DataHandler.Serializer; + +namespace Microsoft.Owin.Security.Interop +{ + // This MUST be kept in sync with Microsoft.AspNetCore.Authentication.DataHandler.TicketSerializer + public class AspNetTicketSerializer : IDataSerializer + { + private const string DefaultStringPlaceholder = "\0"; + private const int FormatVersion = 5; + + public static AspNetTicketSerializer Default { get; } = new AspNetTicketSerializer(); + + public virtual byte[] Serialize(AuthenticationTicket ticket) + { + using (var memory = new MemoryStream()) + { + using (var writer = new BinaryWriter(memory)) + { + Write(writer, ticket); + } + return memory.ToArray(); + } + } + + public virtual AuthenticationTicket Deserialize(byte[] data) + { + using (var memory = new MemoryStream(data)) + { + using (var reader = new BinaryReader(memory)) + { + return Read(reader); + } + } + } + + public virtual void Write(BinaryWriter writer, AuthenticationTicket ticket) + { + writer.Write(FormatVersion); + writer.Write(ticket.Identity.AuthenticationType); + + var identity = ticket.Identity; + if (identity == null) + { + throw new ArgumentNullException("ticket.Identity"); + } + + // There is always a single identity + writer.Write(1); + WriteIdentity(writer, identity); + PropertiesSerializer.Write(writer, ticket.Properties); + } + + protected virtual void WriteIdentity(BinaryWriter writer, ClaimsIdentity identity) + { + var authenticationType = identity.AuthenticationType ?? string.Empty; + + writer.Write(authenticationType); + WriteWithDefault(writer, identity.NameClaimType, ClaimsIdentity.DefaultNameClaimType); + WriteWithDefault(writer, identity.RoleClaimType, ClaimsIdentity.DefaultRoleClaimType); + + // Write the number of claims contained in the identity. + writer.Write(identity.Claims.Count()); + + foreach (var claim in identity.Claims) + { + WriteClaim(writer, claim); + } + + var bootstrap = identity.BootstrapContext as string; + if (!string.IsNullOrEmpty(bootstrap)) + { + writer.Write(true); + writer.Write(bootstrap); + } + else + { + writer.Write(false); + } + + if (identity.Actor != null) + { + writer.Write(true); + WriteIdentity(writer, identity.Actor); + } + else + { + writer.Write(false); + } + } + + protected virtual void WriteClaim(BinaryWriter writer, Claim claim) + { + WriteWithDefault(writer, claim.Type, claim.Subject?.NameClaimType ?? ClaimsIdentity.DefaultNameClaimType); + writer.Write(claim.Value); + WriteWithDefault(writer, claim.ValueType, ClaimValueTypes.String); + WriteWithDefault(writer, claim.Issuer, ClaimsIdentity.DefaultIssuer); + WriteWithDefault(writer, claim.OriginalIssuer, claim.Issuer); + + // Write the number of properties contained in the claim. + writer.Write(claim.Properties.Count); + + foreach (var property in claim.Properties) + { + writer.Write(property.Key ?? string.Empty); + writer.Write(property.Value ?? string.Empty); + } + } + + public virtual AuthenticationTicket Read(BinaryReader reader) + { + if (reader.ReadInt32() != FormatVersion) + { + return null; + } + + var scheme = reader.ReadString(); + + // Any identities after the first will be ignored. + var count = reader.ReadInt32(); + if (count < 0) + { + return null; + } + + var identity = ReadIdentity(reader); + var properties = PropertiesSerializer.Read(reader); + + return new AuthenticationTicket(identity, properties); + } + + protected virtual ClaimsIdentity ReadIdentity(BinaryReader reader) + { + var authenticationType = reader.ReadString(); + var nameClaimType = ReadWithDefault(reader, ClaimsIdentity.DefaultNameClaimType); + var roleClaimType = ReadWithDefault(reader, ClaimsIdentity.DefaultRoleClaimType); + + // Read the number of claims contained + // in the serialized identity. + var count = reader.ReadInt32(); + + var identity = new ClaimsIdentity(authenticationType, nameClaimType, roleClaimType); + + for (int index = 0; index != count; ++index) + { + var claim = ReadClaim(reader, identity); + + identity.AddClaim(claim); + } + + // Determine whether the identity + // has a bootstrap context attached. + if (reader.ReadBoolean()) + { + identity.BootstrapContext = reader.ReadString(); + } + + // Determine whether the identity + // has an actor identity attached. + if (reader.ReadBoolean()) + { + identity.Actor = ReadIdentity(reader); + } + + return identity; + } + + protected virtual Claim ReadClaim(BinaryReader reader, ClaimsIdentity identity) + { + var type = ReadWithDefault(reader, identity.NameClaimType); + var value = reader.ReadString(); + var valueType = ReadWithDefault(reader, ClaimValueTypes.String); + var issuer = ReadWithDefault(reader, ClaimsIdentity.DefaultIssuer); + var originalIssuer = ReadWithDefault(reader, issuer); + + var claim = new Claim(type, value, valueType, issuer, originalIssuer, identity); + + // Read the number of properties stored in the claim. + var count = reader.ReadInt32(); + + for (var index = 0; index != count; ++index) + { + var key = reader.ReadString(); + var propertyValue = reader.ReadString(); + + claim.Properties.Add(key, propertyValue); + } + + return claim; + } + + private static void WriteWithDefault(BinaryWriter writer, string value, string defaultValue) + { + if (string.Equals(value, defaultValue, StringComparison.Ordinal)) + { + writer.Write(DefaultStringPlaceholder); + } + else + { + writer.Write(value); + } + } + + private static string ReadWithDefault(BinaryReader reader, string defaultValue) + { + var value = reader.ReadString(); + if (string.Equals(value, DefaultStringPlaceholder, StringComparison.Ordinal)) + { + return defaultValue; + } + return value; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs new file mode 100644 index 0000000000..b323258d9b --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs @@ -0,0 +1,281 @@ +// 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.Collections.Generic; +using System.Globalization; +using System.Linq; +using Microsoft.Owin.Infrastructure; + +namespace Microsoft.Owin.Security.Interop +{ + // This MUST be kept in sync with Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager + /// + /// This handles cookies that are limited by per cookie length. It breaks down long cookies for responses, and reassembles them + /// from requests. + /// + public class ChunkingCookieManager : ICookieManager + { + private const string ChunkKeySuffix = "C"; + private const string ChunkCountPrefix = "chunks-"; + + public ChunkingCookieManager() + { + // Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case. + // See http://browsercookielimits.x64.me/. + // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. + ChunkSize = 4070; + ThrowForPartialCookies = true; + } + + /// + /// The maximum size of cookie to send back to the client. If a cookie exceeds this size it will be broken down into multiple + /// cookies. Set this value to null to disable this behavior. The default is 4090 characters, which is supported by all + /// common browsers. + /// + /// Note that browsers may also have limits on the total size of all cookies per domain, and on the number of cookies per domain. + /// + public int? ChunkSize { get; set; } + + /// + /// Throw if not all chunks of a cookie are available on a request for re-assembly. + /// + public bool ThrowForPartialCookies { get; set; } + + // Parse the "chunks-XX" to determine how many chunks there should be. + private static int ParseChunksCount(string value) + { + if (value != null && value.StartsWith(ChunkCountPrefix, StringComparison.Ordinal)) + { + var chunksCountString = value.Substring(ChunkCountPrefix.Length); + int chunksCount; + if (int.TryParse(chunksCountString, NumberStyles.None, CultureInfo.InvariantCulture, out chunksCount)) + { + return chunksCount; + } + } + return 0; + } + + /// + /// Get the reassembled cookie. Non chunked cookies are returned normally. + /// Cookies with missing chunks just have their "chunks-XX" header returned. + /// + /// + /// + /// The reassembled cookie, if any, or null. + public string GetRequestCookie(IOwinContext context, string key) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + var requestCookies = context.Request.Cookies; + var value = requestCookies[key]; + var chunksCount = ParseChunksCount(value); + if (chunksCount > 0) + { + var chunks = new string[chunksCount]; + for (var chunkId = 1; chunkId <= chunksCount; chunkId++) + { + var chunk = requestCookies[key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture)]; + if (string.IsNullOrEmpty(chunk)) + { + if (ThrowForPartialCookies) + { + var totalSize = 0; + for (int i = 0; i < chunkId - 1; i++) + { + totalSize += chunks[i].Length; + } + throw new FormatException( + string.Format(CultureInfo.CurrentCulture, + "The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded.", + chunkId - 1, chunksCount, totalSize)); + } + // Missing chunk, abort by returning the original cookie value. It may have been a false positive? + return value; + } + + chunks[chunkId - 1] = chunk; + } + + return string.Join(string.Empty, chunks); + } + return value; + } + + /// + /// Appends a new response cookie to the Set-Cookie header. If the cookie is larger than the given size limit + /// then it will be broken down into multiple cookies as follows: + /// Set-Cookie: CookieName=chunks-3; path=/ + /// Set-Cookie: CookieNameC1=Segment1; path=/ + /// Set-Cookie: CookieNameC2=Segment2; path=/ + /// Set-Cookie: CookieNameC3=Segment3; path=/ + /// + /// + /// + /// + /// + public void AppendResponseCookie(IOwinContext context, string key, string value, CookieOptions options) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var domainHasValue = !string.IsNullOrEmpty(options.Domain); + var pathHasValue = !string.IsNullOrEmpty(options.Path); + var expiresHasValue = options.Expires.HasValue; + + var templateLength = key.Length + "=".Length + + (domainHasValue ? "; domain=".Length + options.Domain.Length : 0) + + (pathHasValue ? "; path=".Length + options.Path.Length : 0) + + (expiresHasValue ? "; expires=ddd, dd-MMM-yyyy HH:mm:ss GMT".Length : 0) + + (options.Secure ? "; secure".Length : 0) + + (options.HttpOnly ? "; HttpOnly".Length : 0); + + // Normal cookie + var responseCookies = context.Response.Cookies; + if (!ChunkSize.HasValue || ChunkSize.Value > templateLength + value.Length) + { + responseCookies.Append(key, value, options); + } + else if (ChunkSize.Value < templateLength + 10) + { + // 10 is the minimum data we want to put in an individual cookie, including the cookie chunk identifier "CXX". + // No room for data, we can't chunk the options and name + throw new InvalidOperationException("The cookie key and options are larger than ChunksSize, leaving no room for data."); + } + else + { + // Break the cookie down into multiple cookies. + // Key = CookieName, value = "Segment1Segment2Segment2" + // Set-Cookie: CookieName=chunks-3; path=/ + // Set-Cookie: CookieNameC1="Segment1"; path=/ + // Set-Cookie: CookieNameC2="Segment2"; path=/ + // Set-Cookie: CookieNameC3="Segment3"; path=/ + var dataSizePerCookie = ChunkSize.Value - templateLength - 3; // Budget 3 chars for the chunkid. + var cookieChunkCount = (int)Math.Ceiling(value.Length * 1.0 / dataSizePerCookie); + + responseCookies.Append(key, ChunkCountPrefix + cookieChunkCount.ToString(CultureInfo.InvariantCulture), options); + + var offset = 0; + for (var chunkId = 1; chunkId <= cookieChunkCount; chunkId++) + { + var remainingLength = value.Length - offset; + var length = Math.Min(dataSizePerCookie, remainingLength); + var segment = value.Substring(offset, length); + offset += length; + + responseCookies.Append(key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture), segment, options); + } + } + } + + /// + /// Deletes the cookie with the given key by setting an expired state. If a matching chunked cookie exists on + /// the request, delete each chunk. + /// + /// + /// + /// + public void DeleteCookie(IOwinContext context, string key, CookieOptions options) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var keys = new List(); + keys.Add(key + "="); + + var requestCookie = context.Request.Cookies[key]; + var chunks = ParseChunksCount(requestCookie); + if (chunks > 0) + { + for (int i = 1; i <= chunks + 1; i++) + { + var subkey = key + ChunkKeySuffix + i.ToString(CultureInfo.InvariantCulture); + keys.Add(subkey + "="); + } + } + + var domainHasValue = !string.IsNullOrEmpty(options.Domain); + var pathHasValue = !string.IsNullOrEmpty(options.Path); + + Func rejectPredicate; + Func predicate = value => keys.Any(k => value.StartsWith(k, StringComparison.OrdinalIgnoreCase)); + if (domainHasValue) + { + rejectPredicate = value => predicate(value) && value.IndexOf("domain=" + options.Domain, StringComparison.OrdinalIgnoreCase) != -1; + } + else if (pathHasValue) + { + rejectPredicate = value => predicate(value) && value.IndexOf("path=" + options.Path, StringComparison.OrdinalIgnoreCase) != -1; + } + else + { + rejectPredicate = value => predicate(value); + } + + var responseHeaders = context.Response.Headers; + string[] existingValues; + if (responseHeaders.TryGetValue(Constants.Headers.SetCookie, out existingValues) && existingValues != null) + { + responseHeaders.SetValues(Constants.Headers.SetCookie, existingValues.Where(value => !rejectPredicate(value)).ToArray()); + } + + AppendResponseCookie( + context, + key, + string.Empty, + new CookieOptions() + { + Path = options.Path, + Domain = options.Domain, + Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), + }); + + for (int i = 1; i <= chunks; i++) + { + AppendResponseCookie( + context, + key + "C" + i.ToString(CultureInfo.InvariantCulture), + string.Empty, + new CookieOptions() + { + Path = options.Path, + Domain = options.Domain, + Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), + }); + } + } + } +} diff --git a/src/Microsoft.Owin.Security.Interop/Constants.cs b/src/Microsoft.Owin.Security.Interop/Constants.cs new file mode 100644 index 0000000000..1e75761b70 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/Constants.cs @@ -0,0 +1,13 @@ +// 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.Owin.Security.Interop +{ + internal static class Constants + { + internal static class Headers + { + internal const string SetCookie = "Set-Cookie"; + } + } +} diff --git a/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs b/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs new file mode 100644 index 0000000000..7313588948 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.DataProtection; + +namespace Microsoft.Owin.Security.Interop +{ + /// + /// Converts an to an + /// . + /// + public sealed class DataProtectorShim : Microsoft.Owin.Security.DataProtection.IDataProtector + { + private readonly IDataProtector _protector; + + public DataProtectorShim(IDataProtector protector) + { + _protector = protector; + } + + public byte[] Protect(byte[] userData) + { + return _protector.Protect(userData); + } + + public byte[] Unprotect(byte[] protectedData) + { + return _protector.Unprotect(protectedData); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj new file mode 100644 index 0000000000..10a8be30f5 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -0,0 +1,18 @@ + + + + + + A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication. + net461 + $(NoWarn);CS1591 + true + aspnetcore;katana;owin;security + + + + + + + + diff --git a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..490fa7cb2a --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs @@ -0,0 +1,8 @@ +// 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.Runtime.InteropServices; + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a7922dd8-09f1-43e4-938b-cc523ea08898")] + diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json new file mode 100644 index 0000000000..1fc242ec55 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json @@ -0,0 +1,373 @@ +{ + "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.Owin.Security.DataHandler.SecureDataFormat", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.Owin.Security.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Owin.Security.Interop.AspNetTicketSerializer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Default", + "Parameters": [], + "ReturnType": "Microsoft.Owin.Security.Interop.AspNetTicketSerializer", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.Owin.Security.AuthenticationTicket" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.Owin.Security.AuthenticationTicket", + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Write", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "ticket", + "Type": "Microsoft.Owin.Security.AuthenticationTicket" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteIdentity", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteClaim", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "claim", + "Type": "System.Security.Claims.Claim" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "Microsoft.Owin.Security.AuthenticationTicket", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReadIdentity", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReadClaim", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + } + ], + "ReturnType": "System.Security.Claims.Claim", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Owin.Security.Interop.ChunkingCookieManager", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Owin.Infrastructure.ICookieManager" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_ChunkSize", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ChunkSize", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ThrowForPartialCookies", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ThrowForPartialCookies", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetRequestCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.Owin.IOwinContext" + }, + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AppendResponseCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.Owin.IOwinContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.Owin.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.Owin.IOwinContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.Owin.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Owin.Security.Interop.DataProtectorShim", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "ImplementedInterfaces": [ + "Microsoft.Owin.Security.DataProtection.IDataProtector" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "userData", + "Type": "System.Byte[]" + } + ], + "ReturnType": "System.Byte[]", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataProtection.IDataProtector", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedData", + "Type": "System.Byte[]" + } + ], + "ReturnType": "System.Byte[]", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataProtection.IDataProtector", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 98d727fde5..c44069f437 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -3,9 +3,8 @@ - netcoreapp2.0 - true - true + netcoreapp2.0;net461 + netcoreapp2.0 @@ -24,6 +23,7 @@ + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index a9ba71a797..48b134740a 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -3,7 +3,8 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 7908e98fcb..b578f5dcfa 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -3,7 +3,8 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index b7b2c6afe0..f513de4b35 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -2,9 +2,8 @@ - netcoreapp2.0 - true - true + netcoreapp2.0;net461 + netcoreapp2.0 diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs new file mode 100644 index 0000000000..ae5e6f0183 --- /dev/null +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -0,0 +1,332 @@ +// 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.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Security.Claims; +using System.Text; +using System.Threading.Tasks; +using System.Xml; +using System.Xml.Linq; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; +using Microsoft.Owin.Security.Cookies; +using Microsoft.Owin.Testing; +using Owin; +using Xunit; + +namespace Microsoft.Owin.Security.Interop +{ + public class CookiesInteropTests + { + [Fact] + public async Task AspNetCoreWithInteropCookieContainsIdentity() + { + var identity = new ClaimsIdentity("Cookies"); + identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); + + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); + + var interopServer = TestServer.Create(app => + { + app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; + + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, + }); + + app.Run(context => + { + context.Authentication.SignIn(identity); + return Task.FromResult(0); + }); + }); + + var transaction = await SendAsync(interopServer, "http://example.com"); + + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Run(async context => + { + var result = await context.AuthenticateAsync("Cookies"); + await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); + }); + }) + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + var newServer = new AspNetCore.TestHost.TestServer(builder); + + var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); + foreach (var cookie in SetCookieHeaderValue.ParseList(transaction.SetCookie)) + { + request.Headers.Add("Cookie", cookie.Name + "=" + cookie.Value); + } + var response = await newServer.CreateClient().SendAsync(request); + + Assert.Equal("Alice", await response.Content.ReadAsStringAsync()); + } + + [Fact] + public async Task AspNetCoreWithLargeInteropCookieContainsIdentity() + { + var identity = new ClaimsIdentity("Cookies"); + identity.AddClaim(new Claim(ClaimTypes.Name, new string('a', 1024 * 5))); + + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); + + var interopServer = TestServer.Create(app => + { + app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; + + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, + CookieManager = new ChunkingCookieManager(), + }); + + app.Run(context => + { + context.Authentication.SignIn(identity); + return Task.FromResult(0); + }); + }); + + var transaction = await SendAsync(interopServer, "http://example.com"); + + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Run(async context => + { + var result = await context.AuthenticateAsync("Cookies"); + await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); + }); + }) + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + var newServer = new AspNetCore.TestHost.TestServer(builder); + + var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); + foreach (var cookie in SetCookieHeaderValue.ParseList(transaction.SetCookie)) + { + request.Headers.Add("Cookie", cookie.Name + "=" + cookie.Value); + } + var response = await newServer.CreateClient().SendAsync(request); + + Assert.Equal(1024 * 5, (await response.Content.ReadAsStringAsync()).Length); + } + + [Fact] + public async Task InteropWithNewCookieContainsIdentity() + { + var user = new ClaimsPrincipal(); + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); + user.AddIdentity(identity); + + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); + + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Run(context => context.SignInAsync("Cookies", user)); + }) + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + var newServer = new AspNetCore.TestHost.TestServer(builder); + + var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); + + var server = TestServer.Create(app => + { + app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; + + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, + }); + + app.Run(async context => + { + var result = await context.Authentication.AuthenticateAsync("Cookies"); + Describe(context.Response, result); + }); + }); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookies); + + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + } + + [Fact] + public async Task InteropWithLargeNewCookieContainsIdentity() + { + var user = new ClaimsPrincipal(); + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim(ClaimTypes.Name, new string('a', 1024 * 5))); + user.AddIdentity(identity); + + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); + + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Run(context => context.SignInAsync("Cookies", user)); + }) + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + var newServer = new AspNetCore.TestHost.TestServer(builder); + + var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); + + var server = TestServer.Create(app => + { + app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; + + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, + CookieManager = new ChunkingCookieManager(), + }); + + app.Run(async context => + { + var result = await context.Authentication.AuthenticateAsync("Cookies"); + Describe(context.Response, result); + }); + }); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookies); + + Assert.Equal(1024 * 5, FindClaimValue(transaction2, ClaimTypes.Name).Length); + } + + private static async Task> SendAndGetCookies(AspNetCore.TestHost.TestServer server, string uri) + { + var request = new HttpRequestMessage(HttpMethod.Get, uri); + var response = await server.CreateClient().SendAsync(request); + if (response.Headers.Contains("Set-Cookie")) + { + IList cookieHeaders = new List(); + foreach (var cookie in SetCookieHeaderValue.ParseList(response.Headers.GetValues("Set-Cookie").ToList())) + { + cookieHeaders.Add(cookie.Name + "=" + cookie.Value); + } + return cookieHeaders; + } + return null; + } + + private static string FindClaimValue(Transaction transaction, string claimType) + { + XElement claim = transaction.ResponseElement.Elements("claim").SingleOrDefault(elt => elt.Attribute("type").Value == claimType); + if (claim == null) + { + return null; + } + return claim.Attribute("value").Value; + } + + private static void Describe(IOwinResponse res, AuthenticateResult result) + { + res.StatusCode = 200; + res.ContentType = "text/xml"; + var xml = new XElement("xml"); + if (result != null && result.Identity != null) + { + xml.Add(result.Identity.Claims.Select(claim => new XElement("claim", new XAttribute("type", claim.Type), new XAttribute("value", claim.Value)))); + } + if (result != null && result.Properties != null) + { + xml.Add(result.Properties.Dictionary.Select(extra => new XElement("extra", new XAttribute("type", extra.Key), new XAttribute("value", extra.Value)))); + } + using (var memory = new MemoryStream()) + { + using (var writer = new XmlTextWriter(memory, Encoding.UTF8)) + { + xml.WriteTo(writer); + } + res.Body.Write(memory.ToArray(), 0, memory.ToArray().Length); + } + } + + private static async Task SendAsync(TestServer server, string uri, IList cookieHeaders = null, bool ajaxRequest = false) + { + var request = new HttpRequestMessage(HttpMethod.Get, uri); + if (cookieHeaders != null) + { + request.Headers.Add("Cookie", cookieHeaders); + } + if (ajaxRequest) + { + request.Headers.Add("X-Requested-With", "XMLHttpRequest"); + } + var transaction = new Transaction + { + Request = request, + Response = await server.HttpClient.SendAsync(request), + }; + if (transaction.Response.Headers.Contains("Set-Cookie")) + { + transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").ToList(); + } + if (transaction.SetCookie != null && transaction.SetCookie.Any()) + { + transaction.CookieNameValue = transaction.SetCookie.First().Split(new[] { ';' }, 2).First(); + } + transaction.ResponseText = await transaction.Response.Content.ReadAsStringAsync(); + + if (transaction.Response.Content != null && + transaction.Response.Content.Headers.ContentType != null && + transaction.Response.Content.Headers.ContentType.MediaType == "text/xml") + { + transaction.ResponseElement = XElement.Parse(transaction.ResponseText); + } + return transaction; + } + + private class Transaction + { + public HttpRequestMessage Request { get; set; } + public HttpResponseMessage Response { get; set; } + + public IList SetCookie { get; set; } + public string CookieNameValue { get; set; } + + public string ResponseText { get; set; } + public XElement ResponseElement { get; set; } + } + + } +} + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj new file mode 100644 index 0000000000..d6e9d16e5f --- /dev/null +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -0,0 +1,26 @@ + + + + + + net461 + + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs new file mode 100644 index 0000000000..b14ea0d74e --- /dev/null +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -0,0 +1,91 @@ +// 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.Linq; +using System.Security.Claims; +using Microsoft.AspNetCore.Authentication; +using Xunit; + +namespace Microsoft.Owin.Security.Interop.Test +{ + public class TicketInteropTests + { + [Fact] + public void NewSerializerCanReadInteropTicket() + { + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim("Test", "Value")); + + var expires = DateTime.Today; + var issued = new DateTime(1979, 11, 11); + var properties = new Owin.Security.AuthenticationProperties(); + properties.IsPersistent = true; + properties.RedirectUri = "/redirect"; + properties.Dictionary["key"] = "value"; + properties.ExpiresUtc = expires; + properties.IssuedUtc = issued; + + var interopTicket = new Owin.Security.AuthenticationTicket(identity, properties); + var interopSerializer = new AspNetTicketSerializer(); + + var bytes = interopSerializer.Serialize(interopTicket); + + var newSerializer = new TicketSerializer(); + var newTicket = newSerializer.Deserialize(bytes); + + Assert.NotNull(newTicket); + Assert.Equal(1, newTicket.Principal.Identities.Count()); + var newIdentity = newTicket.Principal.Identity as ClaimsIdentity; + Assert.NotNull(newIdentity); + Assert.Equal("scheme", newIdentity.AuthenticationType); + Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); + Assert.NotNull(newTicket.Properties); + Assert.True(newTicket.Properties.IsPersistent); + Assert.Equal("/redirect", newTicket.Properties.RedirectUri); + Assert.Equal("value", newTicket.Properties.Items["key"]); + Assert.Equal(expires, newTicket.Properties.ExpiresUtc); + Assert.Equal(issued, newTicket.Properties.IssuedUtc); + } + + [Fact] + public void InteropSerializerCanReadNewTicket() + { + var user = new ClaimsPrincipal(); + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim("Test", "Value")); + user.AddIdentity(identity); + + var expires = DateTime.Today; + var issued = new DateTime(1979, 11, 11); + var properties = new AspNetCore.Authentication.AuthenticationProperties(); + properties.IsPersistent = true; + properties.RedirectUri = "/redirect"; + properties.Items["key"] = "value"; + properties.ExpiresUtc = expires; + properties.IssuedUtc = issued; + + var newTicket = new AspNetCore.Authentication.AuthenticationTicket(user, properties, "scheme"); + var newSerializer = new TicketSerializer(); + + var bytes = newSerializer.Serialize(newTicket); + + var interopSerializer = new AspNetTicketSerializer(); + var interopTicket = interopSerializer.Deserialize(bytes); + + Assert.NotNull(interopTicket); + var newIdentity = interopTicket.Identity; + Assert.NotNull(newIdentity); + Assert.Equal("scheme", newIdentity.AuthenticationType); + Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); + Assert.NotNull(interopTicket.Properties); + Assert.True(interopTicket.Properties.IsPersistent); + Assert.Equal("/redirect", interopTicket.Properties.RedirectUri); + Assert.Equal("value", interopTicket.Properties.Dictionary["key"]); + Assert.Equal(expires, interopTicket.Properties.ExpiresUtc); + Assert.Equal(issued, interopTicket.Properties.IssuedUtc); + } + } +} + + From e940cdb36bc7617af3d762ff9cc853a8fef55b0a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 25 May 2017 18:29:19 -0700 Subject: [PATCH 729/900] AuthZ 2.0 changes + react to Http --- Security.sln | 57 ++++++ .../CookieAuthenticationHandler.cs | 21 +- .../FacebookConfigureOptions.cs | 6 +- .../FacebookExtensions.cs | 16 +- .../GoogleConfigureOptions.cs | 6 +- .../GoogleExtensions.cs | 16 +- .../JwtBearerConfigureOptions.cs | 6 +- .../JwtBearerExtensions.cs | 15 +- .../JwtBearerHandler.cs | 8 +- .../MicrosoftAccountConfigureOptions.cs | 6 +- .../MicrosoftAccountExtensions.cs | 20 +- .../OAuthHandler.cs | 8 +- .../OpenIdConnectConfigureOptions.cs | 6 +- .../OpenIdConnectExtensions.cs | 13 +- .../OpenIdConnectHandler.cs | 11 +- .../TwitterConfigureOptions.cs | 6 +- .../TwitterExtensions.cs | 13 +- .../TwitterHandler.cs | 9 +- .../AuthenticationHandler.cs | 65 +++---- .../Events/BaseAuthenticationContext.cs | 41 ++++ .../Events/BaseContext.cs | 49 +++++ .../RemoteAuthenticationHandler.cs | 8 +- .../IPolicyEvaluator.cs | 36 ++++ ...oft.AspNetCore.Authorization.Policy.csproj | 27 +++ .../PolicyAuthorizationResult.cs | 35 ++++ .../PolicyEvaluator.cs | 92 +++++++++ .../PolicyServiceCollectionExtensions.cs | 31 +++ .../AuthorizationFailure.cs | 46 +++++ .../AuthorizationPolicy.cs | 2 +- .../AuthorizationResult.cs | 37 ++++ ...uthorizationServiceCollectionExtensions.cs | 1 + .../AuthorizationServiceExtensions.cs | 8 +- .../AuthorizeAttribute.cs | 24 ++- .../DefaultAuthorizationEvaluator.cs | 24 +-- .../DefaultAuthorizationHandlerProvider.cs | 35 ++++ .../DefaultAuthorizationService.cs | 28 +-- .../IAuthorizationEvaluator.cs | 13 +- .../IAuthorizationHandlerProvider.cs | 21 ++ .../IAuthorizationService.cs | 4 +- .../IAuthorizeData.cs | 2 +- .../AuthenticationMiddlewareTests.cs | 35 +++- .../CookieTests.cs | 40 +--- .../FacebookTests.cs | 28 +-- .../GoogleTests.cs | 64 ++----- .../JwtBearerTests.cs | 62 +++--- .../MicrosoftAccountTests.cs | 28 +-- .../OpenIdConnect/OpenIdConnectTests.cs | 14 +- .../TicketSerializerTests.cs | 2 +- .../TwitterTests.cs | 22 ++- .../AuthorizationPolicyFacts.cs | 12 +- .../DefaultAuthorizationServiceTests.cs | 134 +++++++------ ...osoft.AspNetCore.Authorization.Test.csproj | 2 + .../PolicyEvaluatorTests.cs | 179 ++++++++++++++++++ 53 files changed, 1029 insertions(+), 465 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs diff --git a/Security.sln b/Security.sln index b9e6ac5672..61ea7b0c31 100644 --- a/Security.sln +++ b/Security.sln @@ -62,6 +62,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution build\repo.props = build\repo.props EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authorization.Policy", "src\Microsoft.AspNetCore.Authorization.Policy\Microsoft.AspNetCore.Authorization.Policy.csproj", "{58194599-F07D-47A3-9DF2-E21A22C5EF9E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Abstractions", "..\HttpAbstractions\src\Microsoft.AspNetCore.Authentication.Abstractions\Microsoft.AspNetCore.Authentication.Abstractions.csproj", "{97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Core", "..\HttpAbstractions\src\Microsoft.AspNetCore.Authentication.Core\Microsoft.AspNetCore.Authentication.Core.csproj", "{85545633-7E70-47EA-8CD2-30654C80112C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -436,6 +442,54 @@ Global {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x64.Build.0 = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.ActiveCfg = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.Build.0 = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|x64.ActiveCfg = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|x64.Build.0 = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|x86.ActiveCfg = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|x86.Build.0 = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|Any CPU.Build.0 = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x64.ActiveCfg = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x64.Build.0 = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.ActiveCfg = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.Build.0 = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x64.ActiveCfg = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x64.Build.0 = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x86.ActiveCfg = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x86.Build.0 = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Any CPU.Build.0 = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x64.ActiveCfg = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x64.Build.0 = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x86.ActiveCfg = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x86.Build.0 = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x64.ActiveCfg = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x64.Build.0 = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x86.ActiveCfg = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x86.Build.0 = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Any CPU.Build.0 = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x64.ActiveCfg = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x64.Build.0 = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x86.ActiveCfg = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -464,5 +518,8 @@ Global {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} + {58194599-F07D-47A3-9DF2-E21A22C5EF9E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {85545633-7E70-47EA-8CD2-30654C80112C} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 13a20e55b9..bb2c10fee5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -247,7 +247,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } } - protected override async Task HandleSignInAsync(SignInContext signin) + protected override async Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { _signInCalled = true; @@ -259,8 +259,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Context, Scheme, Options, - signin.Principal, - signin.Properties, + user, + properties, cookieOptions); DateTimeOffset issuedUtc; @@ -325,7 +325,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies await ApplyHeaders(shouldRedirect, signedInContext.Properties); } - protected override async Task HandleSignOutAsync(SignOutContext signOutContext) + protected override async Task HandleSignOutAsync(AuthenticationProperties properties) { _signOutCalled = true; @@ -341,7 +341,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Context, Scheme, Options, - signOutContext.Properties, + properties, cookieOptions); await Events.SigningOut(context); @@ -401,9 +401,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies return path[0] == '/' && path[1] != '/' && path[1] != '\\'; } - protected override async Task HandleForbiddenAsync(ChallengeContext context) + protected override async Task HandleForbiddenAsync(AuthenticationProperties properties) { - var properties = context.Properties; var returnUrl = properties.RedirectUri; if (string.IsNullOrEmpty(returnUrl)) { @@ -414,14 +413,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies await Events.RedirectToAccessDenied(redirectContext); } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var properties = context.Properties; var redirectUri = properties.RedirectUri; if (string.IsNullOrEmpty(redirectUri)) { diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs index 9305623dad..887789ebf1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.Facebook { - internal class FacebookConfigureOptions : ConfigureNamedOptions + internal class FacebookConfigureOptions : ConfigureDefaultOptions { public FacebookConfigureOptions(IConfiguration config) : base(FacebookDefaults.AuthenticationScheme, - options => config.GetSection(FacebookDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+FacebookDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 032be82356..1bb065414d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -3,29 +3,21 @@ using System; using Microsoft.AspNetCore.Authentication.Facebook; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class FacebookAuthenticationOptionsExtensions { - /// - /// Adds facebook authentication with options bound against the "Facebook" section - /// from the IConfiguration in the service container. - /// - /// - /// - public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services) - { - services.AddSingleton, FacebookConfigureOptions>(); - return services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { }); - } + public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services) + => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { }); public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, Action configureOptions) => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { + services.AddSingleton, FacebookConfigureOptions>(); return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs index e19c1fdb1d..1041f1eec5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.Google { - internal class GoogleConfigureOptions : ConfigureNamedOptions + internal class GoogleConfigureOptions : ConfigureDefaultOptions { public GoogleConfigureOptions(IConfiguration config) : base(GoogleDefaults.AuthenticationScheme, - options => config.GetSection(GoogleDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+GoogleDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index d71e8b461c..c11b155d9c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -3,29 +3,21 @@ using System; using Microsoft.AspNetCore.Authentication.Google; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class GoogleExtensions { - /// - /// Adds google authentication with options bound against the "Google" section - /// from the IConfiguration in the service container. - /// - /// - /// - public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services) - { - services.AddSingleton, GoogleConfigureOptions>(); - return services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { }); - } + public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services) + => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { }); public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, Action configureOptions) => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { + services.AddSingleton, GoogleConfigureOptions>(); return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs index f3571a49c4..d26bf66711 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs @@ -2,16 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - internal class JwtBearerConfigureOptions : ConfigureNamedOptions + internal class JwtBearerConfigureOptions : ConfigureDefaultOptions { // Bind to "Bearer" section by default public JwtBearerConfigureOptions(IConfiguration config) : base(JwtBearerDefaults.AuthenticationScheme, - options => config.GetSection(JwtBearerDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+JwtBearerDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 4f6453bd96..0bd3a9400c 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -5,22 +5,14 @@ using System; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class JwtBearerExtensions { - /// - /// Adds JwtBearer authentication with options bound against the "Bearer" section - /// from the IConfiguration in the service container. - /// - /// - /// - public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services) - { - services.AddSingleton, JwtBearerConfigureOptions>(); - return services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { }); - } + public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services) + => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { }); public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, Action configureOptions) => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, configureOptions); @@ -28,6 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerInitializer>()); + services.AddSingleton, JwtBearerConfigureOptions>(); return services.AddScheme(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index ec48e3e20b..0087d38d0f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -201,10 +201,10 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { var authResult = await HandleAuthenticateOnceSafeAsync(); - var eventContext = new JwtBearerChallengeContext(Context, Scheme, Options, context.Properties) + var eventContext = new JwtBearerChallengeContext(Context, Scheme, Options, properties) { AuthenticateFailure = authResult?.Failure }; @@ -330,12 +330,12 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer return string.Join("; ", messages); } - protected override Task HandleSignOutAsync(SignOutContext context) + protected override Task HandleSignOutAsync(AuthenticationProperties properties) { throw new NotSupportedException(); } - protected override Task HandleSignInAsync(SignInContext context) + protected override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { throw new NotSupportedException(); } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs index 520c3758d5..b0be3de977 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs @@ -2,16 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { - internal class MicrosoftAccountConfigureOptions : ConfigureNamedOptions + internal class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions { // Bind to "Microsoft" section by default public MicrosoftAccountConfigureOptions(IConfiguration config) : base(MicrosoftAccountDefaults.AuthenticationScheme, - options => config.GetSection(MicrosoftAccountDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+MicrosoftAccountDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 6ccb392344..1a7fee370f 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -3,29 +3,21 @@ using System; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class MicrosoftAccountExtensions { - /// - /// Adds MicrosoftAccount authentication with options bound against the "Microsoft" section - /// from the IConfiguration in the service container. - /// - /// - /// - public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services) - { - services.AddSingleton, MicrosoftAccountConfigureOptions>(); - return services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, o => { }); - } + public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services) + => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, _ => { }); - public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, Action configureOptions) => - services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); + public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, Action configureOptions) + => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { + services.AddSingleton, MicrosoftAccountConfigureOptions>(); return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 63bcdbdf2b..bbe4f4038b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -191,14 +191,8 @@ namespace Microsoft.AspNetCore.Authentication.OAuth return context.Ticket; } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var properties = context.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs index 9afae436dd..1a6450b7b2 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs @@ -2,16 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - internal class OpenIdConnectConfigureOptions : ConfigureNamedOptions + internal class OpenIdConnectConfigureOptions : ConfigureDefaultOptions { // Bind to "OpenIdConnect" section by default public OpenIdConnectConfigureOptions(IConfiguration config) : base(OpenIdConnectDefaults.AuthenticationScheme, - options => config.GetSection(OpenIdConnectDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+OpenIdConnectDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index c79dc7212d..b4ac4b9fb7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -5,22 +5,14 @@ using System; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class OpenIdConnectExtensions { - /// - /// Adds OpenIdConnect authentication with options bound against the "OpenIdConnect" section - /// from the IConfiguration in the service container. - /// - /// - /// public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services) - { - services.AddSingleton, OpenIdConnectConfigureOptions>(); - return services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); - } + => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, Action configureOptions) => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); @@ -28,6 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectInitializer>()); + services.AddSingleton, OpenIdConnectConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 04359142a6..9c8f4ecc6f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Redirect user to the identity provider for sign out /// /// A task executing the sign out procedure - protected override async Task HandleSignOutAsync(SignOutContext signout) + protected override async Task HandleSignOutAsync(AuthenticationProperties properties) { Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); @@ -180,7 +180,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect }; // Get the post redirect URI. - var properties = signout.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = BuildRedirectUriIfRelative(Options.PostLogoutRedirectUri); @@ -292,19 +291,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Responds to a 401 Challenge. Sends an OpenIdConnect message to the 'identity authority' to obtain an identity. /// /// - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - Logger.EnteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync(GetType().FullName); // order for local RedirectUri // 1. challenge.Properties.RedirectUri // 2. CurrentUri if RedirectUri is not set) - var properties = context.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs index b10435f189..03d7ae8092 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs @@ -2,16 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.Twitter { - internal class TwitterConfigureOptions : ConfigureNamedOptions + internal class TwitterConfigureOptions : ConfigureDefaultOptions { // Bind to "Twitter" section by default public TwitterConfigureOptions(IConfiguration config) : base(TwitterDefaults.AuthenticationScheme, - options => config.GetSection(TwitterDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+TwitterDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index 3bcc80c3d7..11586f9844 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -5,22 +5,14 @@ using System; using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class TwitterExtensions { - /// - /// Adds Twitter authentication with options bound against the "Twitter" section - /// from the IConfiguration in the service container. - /// - /// - /// public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services) - { - services.AddSingleton, TwitterConfigureOptions>(); - return services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { }); - } + => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { }); public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, Action configureOptions) => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, configureOptions); @@ -28,6 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterInitializer>()); + services.AddSingleton, TwitterConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index ff054d3c6f..63a18e83bc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -140,15 +140,8 @@ namespace Microsoft.AspNetCore.Authentication.Twitter return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var properties = context.Properties; - if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index ba1c919fe5..b094709196 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; @@ -178,44 +179,41 @@ namespace Microsoft.AspNetCore.Authentication protected abstract Task HandleAuthenticateAsync(); - public async Task SignInAsync(SignInContext context) + public async Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { - if (context == null) + if (user == null) { - throw new ArgumentNullException(nameof(context)); + throw new ArgumentNullException(nameof(user)); } - await HandleSignInAsync(context); + properties = properties ?? new AuthenticationProperties(); + await HandleSignInAsync(user, properties); Logger.AuthenticationSchemeSignedIn(Scheme.Name); } - protected virtual Task HandleSignInAsync(SignInContext context) + protected virtual Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { return TaskCache.CompletedTask; } - public async Task SignOutAsync(SignOutContext context) + public async Task SignOutAsync(AuthenticationProperties properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - await HandleSignOutAsync(context); + properties = properties ?? new AuthenticationProperties(); + await HandleSignOutAsync(properties); Logger.AuthenticationSchemeSignedOut(Scheme.Name); } - protected virtual Task HandleSignOutAsync(SignOutContext context) + protected virtual Task HandleSignOutAsync(AuthenticationProperties properties) { return TaskCache.CompletedTask; } /// - /// Override this method to deal with a challenge that is forbidden. + /// Override this method to handle Forbid. /// - /// + /// /// A Task. - protected virtual Task HandleForbiddenAsync(ChallengeContext context) + protected virtual Task HandleForbiddenAsync(AuthenticationProperties properties) { Response.StatusCode = 403; return TaskCache.CompletedTask; @@ -226,35 +224,26 @@ namespace Microsoft.AspNetCore.Authentication /// deals an authentication interaction as part of it's request flow. (like adding a response header, or /// changing the 401 result to 302 of a login page or external sign-in location.) /// - /// + /// /// A Task. - protected virtual Task HandleUnauthorizedAsync(ChallengeContext context) + protected virtual Task HandleChallengeAsync(AuthenticationProperties properties) { Response.StatusCode = 401; return TaskCache.CompletedTask; } - public async Task ChallengeAsync(ChallengeContext context) + public async Task ChallengeAsync(AuthenticationProperties properties) { - switch (context.Behavior) - { - case ChallengeBehavior.Automatic: - // If there is a principal already, invoke the forbidden code path - var result = await HandleAuthenticateOnceSafeAsync(); - if (result?.Principal != null) - { - goto case ChallengeBehavior.Forbidden; - } - goto case ChallengeBehavior.Unauthorized; - case ChallengeBehavior.Unauthorized: - await HandleUnauthorizedAsync(context); - Logger.AuthenticationSchemeChallenged(Scheme.Name); - break; - case ChallengeBehavior.Forbidden: - await HandleForbiddenAsync(context); - Logger.AuthenticationSchemeForbidden(Scheme.Name); - break; - } + properties = properties ?? new AuthenticationProperties(); + await HandleChallengeAsync(properties); + Logger.AuthenticationSchemeChallenged(Scheme.Name); + } + + public async Task ForbidAsync(AuthenticationProperties properties) + { + properties = properties ?? new AuthenticationProperties(); + await HandleForbiddenAsync(properties); + Logger.AuthenticationSchemeForbidden(Scheme.Name); } } } diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs new file mode 100644 index 0000000000..cfe5809c5a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs @@ -0,0 +1,41 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base context for authentication. + /// + public abstract class BaseAuthenticationContext : BaseContext + { + /// + /// Constructor. + /// + /// The context. + /// The name of the scheme. + /// The properties. + protected BaseAuthenticationContext(HttpContext context, string authenticationScheme, AuthenticationProperties properties) : base(context) + { + if (string.IsNullOrEmpty(authenticationScheme)) + { + throw new ArgumentException(nameof(authenticationScheme)); + } + + AuthenticationScheme = authenticationScheme; + Properties = properties ?? new AuthenticationProperties(); + } + + /// + /// The name of the scheme. + /// + public string AuthenticationScheme { get; } + + /// + /// Contains the extra meta-data arriving with the authentication. May be altered. + /// + public AuthenticationProperties Properties { get; protected set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs new file mode 100644 index 0000000000..3d65f0dd75 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs @@ -0,0 +1,49 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base class used by other context classes. + /// + public abstract class BaseContext + { + /// + /// Constructor. + /// + /// The request context. + protected BaseContext(HttpContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + HttpContext = context; + } + + /// + /// The context. + /// + public HttpContext HttpContext { get; } + + /// + /// The request. + /// + public HttpRequest Request + { + get { return HttpContext.Request; } + } + + /// + /// The response. + /// + public HttpResponse Response + { + get { return HttpContext.Response; } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index a7de95dfed..9394b75532 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Security.Claims; using System.Security.Cryptography; using System.Text.Encodings.Web; using System.Threading.Tasks; @@ -173,18 +174,17 @@ namespace Microsoft.AspNetCore.Authentication return AuthenticateResult.Fail("Remote authentication does not directly support AuthenticateAsync"); } - protected override Task HandleSignOutAsync(SignOutContext context) + protected override Task HandleSignOutAsync(AuthenticationProperties properties) { throw new NotSupportedException(); } - protected override Task HandleSignInAsync(SignInContext context) + protected override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { throw new NotSupportedException(); } - // REVIEW: This behaviour needs a test (forwarding of forbidden to sign in scheme) - protected override Task HandleForbiddenAsync(ChallengeContext context) + protected override Task HandleForbiddenAsync(AuthenticationProperties properties) { return Context.ForbidAsync(SignInScheme); } diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs b/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs new file mode 100644 index 0000000000..1717a0ae0a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authorization.Policy +{ + /// + /// Base class for authorization handlers that need to be called for a specific requirement type. + /// + public interface IPolicyEvaluator + { + /// + /// Does authentication for and sets the resulting + /// to . If no schemes are set, this is a no-op. + /// + /// The . + /// The . + /// unless all schemes specified by fail to authenticate. + Task AuthenticateAsync(AuthorizationPolicy policy, HttpContext context); + + /// + /// Attempts authorization for a policy using . + /// + /// The . + /// The result of a call to . + /// The . + /// Returns if authorization succeeds. + /// Otherwise returns if , otherwise + /// returns + Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj new file mode 100644 index 0000000000..5123b70699 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -0,0 +1,27 @@ + + + + + + ASP.NET Core authorization policy helper classes. + netstandard2.0 + $(NoWarn);CS1591 + true + aspnetcore;authorization + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs new file mode 100644 index 0000000000..d7d481dcd6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs @@ -0,0 +1,35 @@ +// 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.AspNetCore.Authorization.Policy +{ + public class PolicyAuthorizationResult + { + private PolicyAuthorizationResult() { } + + /// + /// If true, means the callee should challenge and try again. + /// + public bool Challenged { get; private set; } + + /// + /// Authorization was forbidden. + /// + public bool Forbidden { get; private set; } + + /// + /// Authorization was successful. + /// + public bool Succeeded { get; private set; } + + public static PolicyAuthorizationResult Challenge() + => new PolicyAuthorizationResult { Challenged = true }; + + public static PolicyAuthorizationResult Forbid() + => new PolicyAuthorizationResult { Forbidden = true }; + + public static PolicyAuthorizationResult Success() + => new PolicyAuthorizationResult { Succeeded = true }; + + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs new file mode 100644 index 0000000000..60f291f671 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs @@ -0,0 +1,92 @@ +// 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.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Internal; + +namespace Microsoft.AspNetCore.Authorization.Policy +{ + public class PolicyEvaluator : IPolicyEvaluator + { + private readonly IAuthorizationService _authorization; + + /// + /// Constructor + /// + /// The authorization service. + public PolicyEvaluator(IAuthorizationService authorization) + { + _authorization = authorization; + } + + /// + /// Does authentication for and sets the resulting + /// to . If no schemes are set, this is a no-op. + /// + /// The . + /// The . + /// unless all schemes specified by failed to authenticate. + public virtual async Task AuthenticateAsync(AuthorizationPolicy policy, HttpContext context) + { + if (policy.AuthenticationSchemes != null && policy.AuthenticationSchemes.Count > 0) + { + ClaimsPrincipal newPrincipal = null; + foreach (var scheme in policy.AuthenticationSchemes) + { + var result = await context.AuthenticateAsync(scheme); + if (result != null && result.Succeeded) + { + newPrincipal = SecurityHelper.MergeUserPrincipal(newPrincipal, result.Principal); + } + } + + if (newPrincipal != null) + { + context.User = newPrincipal; + return AuthenticateResult.Success(new AuthenticationTicket(newPrincipal, string.Join(";", policy.AuthenticationSchemes))); + } + else + { + context.User = new ClaimsPrincipal(new ClaimsIdentity()); + return AuthenticateResult.None(); + } + } + + return (context.User?.Identity?.IsAuthenticated ?? false) + ? AuthenticateResult.Success(new AuthenticationTicket(context.User, "context.User")) + : AuthenticateResult.None(); + } + + /// + /// Attempts authorization for a policy using . + /// + /// The . + /// The result of a call to . + /// The . + /// Returns if authorization succeeds. + /// Otherwise returns if , otherwise + /// returns + public virtual async Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context) + { + if (policy == null) + { + throw new ArgumentNullException(nameof(policy)); + } + + var result = await _authorization.AuthorizeAsync(context.User, context, policy); + if (result.Succeeded) + { + return PolicyAuthorizationResult.Success(); + } + + // If authentication was successful, return forbidden, otherwise challenge + return (authenticationResult.Succeeded) + ? PolicyAuthorizationResult.Forbid() + : PolicyAuthorizationResult.Challenge(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs new file mode 100644 index 0000000000..9b72a5cab4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authorization.Policy; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace Microsoft.Extensions.DependencyInjection +{ + /// + /// Extension methods for setting up authorization services in an . + /// + public static class PolicyServiceCollectionExtensions + { + /// + /// Adds authorization policy services to the specified . + /// + /// The to add services to. + /// The so that additional calls can be chained. + public static IServiceCollection AddAuthorizationPolicyEvaluator(this IServiceCollection services) + { + if (services == null) + { + throw new ArgumentNullException(nameof(services)); + } + + services.TryAdd(ServiceDescriptor.Transient()); + return services; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs new file mode 100644 index 0000000000..89956c9aa0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs @@ -0,0 +1,46 @@ +// 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.Collections.Generic; +using System.Security.Claims; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// Encapsulates a failure result of . + /// + public class AuthorizationFailure + { + private AuthorizationFailure() { } + + /// + /// Failure was due to being called. + /// + public bool FailCalled { get; private set; } + + /// + /// Failure was due to these requirements not being met via . + /// + public IEnumerable FailedRequirements { get; private set; } + + /// + /// Return a failure due to being called. + /// + /// The failure. + public static AuthorizationFailure ExplicitFail() + => new AuthorizationFailure + { + FailCalled = true, + FailedRequirements = new IAuthorizationRequirement[0] + }; + + /// + /// Return a failure due to some requirements not being met via . + /// + /// The requirements that were not met. + /// The failure. + public static AuthorizationFailure Failed(IEnumerable failed) + => new AuthorizationFailure { FailedRequirements = failed }; + + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs index 5cba0fd9e3..36e0ca7c38 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -143,7 +143,7 @@ namespace Microsoft.AspNetCore.Authorization policyBuilder.RequireRole(trimmedRolesSplit); useDefaultPolicy = false; } - var authTypesSplit = authorizeDatum.ActiveAuthenticationSchemes?.Split(','); + var authTypesSplit = authorizeDatum.AuthenticationSchemes?.Split(','); if (authTypesSplit != null && authTypesSplit.Any()) { foreach (var authType in authTypesSplit) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs new file mode 100644 index 0000000000..46dca35fb5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs @@ -0,0 +1,37 @@ +// 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.Collections.Generic; +using System.Security.Claims; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// Encapsulates the result of . + /// + public class AuthorizationResult + { + private AuthorizationResult() { } + + /// + /// True if authorization was successful. + /// + public bool Succeeded { get; private set; } + + /// + /// Contains information about why authorization failed. + /// + public AuthorizationFailure Failure { get; private set; } + + /// + /// Returns a successful result. + /// + /// A successful result. + public static AuthorizationResult Success() => new AuthorizationResult { Succeeded = true }; + + public static AuthorizationResult Failed(AuthorizationFailure failure) => new AuthorizationResult { Failure = failure }; + + public static AuthorizationResult Failed() => new AuthorizationResult { Failure = AuthorizationFailure.ExplicitFail() }; + + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs index a9961b69ef..c089fba285 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -27,6 +27,7 @@ namespace Microsoft.Extensions.DependencyInjection services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); + services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); services.TryAddEnumerable(ServiceDescriptor.Transient()); diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs index 3b78c952eb..c128152326 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Authorization /// A flag indicating whether requirement evaluation has succeeded or failed. /// This value is true when the user fulfills the policy, otherwise false. /// - public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, IAuthorizationRequirement requirement) + public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, IAuthorizationRequirement requirement) { if (service == null) { @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Authorization /// A flag indicating whether policy evaluation has succeeded or failed. /// This value is true when the user fulfills the policy, otherwise false. /// - public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, AuthorizationPolicy policy) + public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, AuthorizationPolicy policy) { if (service == null) { @@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Authorization /// A flag indicating whether policy evaluation has succeeded or failed. /// This value is true when the user fulfills the policy, otherwise false. /// - public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, AuthorizationPolicy policy) + public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, AuthorizationPolicy policy) { if (service == null) { @@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Authorization /// A flag indicating whether policy evaluation has succeeded or failed. /// This value is true when the user fulfills the policy, otherwise false. /// - public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, string policyName) + public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, string policyName) { if (service == null) { diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs index c911dc56bc..63bfa30d45 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs @@ -25,13 +25,29 @@ namespace Microsoft.AspNetCore.Authorization Policy = policy; } - /// + /// + /// Gets or sets the policy name that determines access to the resource. + /// public string Policy { get; set; } - /// + /// + /// Gets or sets a comma delimited list of roles that are allowed to access the resource. + /// public string Roles { get; set; } - /// - public string ActiveAuthenticationSchemes { get; set; } + /// + /// Gets or sets a comma delimited list of schemes from which user information is constructed. + /// + public string AuthenticationSchemes { get; set; } + + /// + /// Gets or sets a comma delimited list of schemes from which user information is constructed. + /// + [Obsolete("Use AuthenticationSchemes instead.", error: false)] + public string ActiveAuthenticationSchemes + { + get => AuthenticationSchemes; + set => AuthenticationSchemes = value; + } } } diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs index 64cc695b88..4bbc283be0 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs @@ -9,23 +9,15 @@ namespace Microsoft.AspNetCore.Authorization public class DefaultAuthorizationEvaluator : IAuthorizationEvaluator { /// - /// Returns true, if authorization has failed. + /// Determines whether the authorization result was successful or not. /// /// The authorization information. - /// True if authorization has failed. - public virtual bool HasFailed(AuthorizationHandlerContext context) - { - return context.HasFailed; - } - - /// - /// Returns true, if authorization has succeeded. - /// - /// The authorization information. - /// True if authorization has succeeded. - public virtual bool HasSucceeded(AuthorizationHandlerContext context) - { - return context.HasSucceeded; - } + /// The . + public AuthorizationResult Evaluate(AuthorizationHandlerContext context) + => context.HasSucceeded + ? AuthorizationResult.Success() + : AuthorizationResult.Failed(context.HasFailed + ? AuthorizationFailure.ExplicitFail() + : AuthorizationFailure.Failed(context.PendingRequirements)); } } diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs new file mode 100644 index 0000000000..d297d4cdc6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs @@ -0,0 +1,35 @@ +// 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.Collections.Generic; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// The default implementation of a handler provider, + /// which provides the s for an authorization request. + /// + public class DefaultAuthorizationHandlerProvider : IAuthorizationHandlerProvider + { + private readonly IEnumerable _handlers; + + /// + /// Creates a new instance of . + /// + /// The s. + public DefaultAuthorizationHandlerProvider(IEnumerable handlers) + { + if (handlers == null) + { + throw new ArgumentNullException(nameof(handlers)); + } + + _handlers = handlers; + } + + public Task> GetHandlersAsync(AuthorizationHandlerContext context) + => Task.FromResult(_handlers); + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 8980d51ac6..3380f64b14 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Security.Claims; using System.Security.Principal; using System.Threading.Tasks; @@ -19,19 +18,11 @@ namespace Microsoft.AspNetCore.Authorization { private readonly AuthorizationOptions _options; private readonly IAuthorizationHandlerContextFactory _contextFactory; + private readonly IAuthorizationHandlerProvider _handlers; private readonly IAuthorizationEvaluator _evaluator; private readonly IAuthorizationPolicyProvider _policyProvider; - private readonly IList _handlers; private readonly ILogger _logger; - /// - /// Creates a new instance of . - /// - /// The used to provide policies. - /// The handlers used to fulfill s. - /// The logger used to log messages, warnings and errors. - public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) : this(policyProvider, handlers, logger, new DefaultAuthorizationHandlerContextFactory(), new DefaultAuthorizationEvaluator(), Options.Create(new AuthorizationOptions())) { } - /// /// Creates a new instance of . /// @@ -41,7 +32,7 @@ namespace Microsoft.AspNetCore.Authorization /// The used to create the context to handle the authorization. /// The used to determine if authorzation was successful. /// The used. - public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger, IAuthorizationHandlerContextFactory contextFactory, IAuthorizationEvaluator evaluator, IOptions options) + public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IAuthorizationHandlerProvider handlers, ILogger logger, IAuthorizationHandlerContextFactory contextFactory, IAuthorizationEvaluator evaluator, IOptions options) { if (options == null) { @@ -69,7 +60,7 @@ namespace Microsoft.AspNetCore.Authorization } _options = options.Value; - _handlers = handlers.ToArray(); + _handlers = handlers; _policyProvider = policyProvider; _logger = logger; _evaluator = evaluator; @@ -86,7 +77,7 @@ namespace Microsoft.AspNetCore.Authorization /// A flag indicating whether authorization has succeded. /// This value is true when the user fulfills the policy otherwise false. /// - public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) + public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) { if (requirements == null) { @@ -94,7 +85,8 @@ namespace Microsoft.AspNetCore.Authorization } var authContext = _contextFactory.CreateContext(requirements, user, resource); - foreach (var handler in _handlers) + var handlers = await _handlers.GetHandlersAsync(authContext); + foreach (var handler in handlers) { await handler.HandleAsync(authContext); if (!_options.InvokeHandlersAfterFailure && authContext.HasFailed) @@ -103,16 +95,16 @@ namespace Microsoft.AspNetCore.Authorization } } - if (_evaluator.HasSucceeded(authContext)) + var result = _evaluator.Evaluate(authContext); + if (result.Succeeded) { _logger.UserAuthorizationSucceeded(GetUserNameForLogging(user)); - return true; } else { _logger.UserAuthorizationFailed(GetUserNameForLogging(user)); - return false; } + return result; } private string GetUserNameForLogging(ClaimsPrincipal user) @@ -147,7 +139,7 @@ namespace Microsoft.AspNetCore.Authorization /// A flag indicating whether authorization has succeded. /// This value is true when the user fulfills the policy otherwise false. /// - public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) + public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) { if (policyName == null) { diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs index 7b2c5d1bc5..baa6f828cd 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs @@ -9,17 +9,10 @@ namespace Microsoft.AspNetCore.Authorization public interface IAuthorizationEvaluator { /// - /// Returns true, if authorization has failed. + /// Determines whether the authorization result was successful or not. /// /// The authorization information. - /// True if authorization has failed. - bool HasFailed(AuthorizationHandlerContext context); - - /// - /// Returns true, if authorization has succeeded. - /// - /// The authorization information. - /// True if authorization has succeeded. - bool HasSucceeded(AuthorizationHandlerContext context); + /// The . + AuthorizationResult Evaluate(AuthorizationHandlerContext context); } } diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs new file mode 100644 index 0000000000..7f0d9f5d31 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs @@ -0,0 +1,21 @@ +// 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.Collections.Generic; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// A type which can provide the s for an authorization request. + /// + public interface IAuthorizationHandlerProvider + { + /// + /// Return the handlers that will be called for the authorization request. + /// + /// The . + /// The list of handlers. + Task> GetHandlersAsync(AuthorizationHandlerContext context); + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs index a130c84b0d..32af746072 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Authorization /// Resource is an optional parameter and may be null. Please ensure that you check it is not /// null before acting upon it. /// - Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements); + Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements); /// /// Checks if a user meets a specific authorization policy @@ -49,6 +49,6 @@ namespace Microsoft.AspNetCore.Authorization /// Resource is an optional parameter and may be null. Please ensure that you check it is not /// null before acting upon it. /// - Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName); + Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs index b48449b5cb..1196db82d4 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs @@ -21,6 +21,6 @@ namespace Microsoft.AspNetCore.Authorization /// /// Gets or sets a comma delimited list of schemes from which user information is constructed. /// - string ActiveAuthenticationSchemes { get; set; } + string AuthenticationSchemes { get; set; } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs index c4720eb30c..b09f13cab9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; -using System.Net; +using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -77,7 +77,12 @@ namespace Microsoft.AspNetCore.Authentication throw new NotImplementedException(); } - public Task ChallengeAsync(ChallengeContext context) + public Task ChallengeAsync(AuthenticationProperties properties) + { + throw new NotImplementedException(); + } + + public Task ForbidAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } @@ -94,12 +99,12 @@ namespace Microsoft.AspNetCore.Authentication return Task.FromResult(0); } - public Task SignInAsync(SignInContext context) + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { throw new NotImplementedException(); } - public Task SignOutAsync(SignOutContext context) + public Task SignOutAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } @@ -114,7 +119,12 @@ namespace Microsoft.AspNetCore.Authentication throw new NotImplementedException(); } - public Task ChallengeAsync(ChallengeContext context) + public Task ChallengeAsync(AuthenticationProperties properties) + { + throw new NotImplementedException(); + } + + public Task ForbidAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } @@ -130,12 +140,12 @@ namespace Microsoft.AspNetCore.Authentication return Task.FromResult(0); } - public Task SignInAsync(SignInContext context) + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { throw new NotImplementedException(); } - public Task SignOutAsync(SignOutContext context) + public Task SignOutAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } @@ -150,7 +160,12 @@ namespace Microsoft.AspNetCore.Authentication throw new NotImplementedException(); } - public Task ChallengeAsync(ChallengeContext context) + public Task ChallengeAsync(AuthenticationProperties properties) + { + throw new NotImplementedException(); + } + + public Task ForbidAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } @@ -166,12 +181,12 @@ namespace Microsoft.AspNetCore.Authentication return Task.FromResult(0); } - public Task SignInAsync(SignInContext context) + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { throw new NotImplementedException(); } - public Task SignOutAsync(SignOutContext context) + public Task SignOutAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index e38dc15870..677120e4be 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -702,22 +702,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.True(transaction1.SetCookie.Contains("path=/base")); } - [Fact] - public async Task CookieTurnsChallengeIntoForbidWithCookie() - { - var server = CreateServer(o => { }, SignInAsAlice); - - var transaction1 = await SendAsync(server, "http://example.com/testpath"); - - var url = "http://example.com/challenge"; - var transaction2 = await SendAsync(server, url, transaction1.CookieNameValue); - - Assert.Equal(HttpStatusCode.Redirect, transaction2.Response.StatusCode); - var location = transaction2.Response.Headers.Location; - Assert.Equal("/Account/AccessDenied", location.LocalPath); - Assert.Equal("?ReturnUrl=%2Fchallenge", location.Query); - } - [Fact] public async Task CookieChallengeRedirectsToLoginWithoutCookie() { @@ -744,25 +728,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal("/Account/AccessDenied", location.LocalPath); } - [Fact] - public async Task CookieTurns401ToAccessDeniedWhenSetWithCookie() - { - var server = CreateServer(o => - { - o.AccessDeniedPath = new PathString("/accessdenied"); - }, - SignInAsAlice); - - var transaction1 = await SendAsync(server, "http://example.com/testpath"); - - var transaction2 = await SendAsync(server, "http://example.com/challenge", transaction1.CookieNameValue); - - Assert.Equal(HttpStatusCode.Redirect, transaction2.Response.StatusCode); - - var location = transaction2.Response.Headers.Location; - Assert.Equal("/accessdenied", location.LocalPath); - } - [Fact] public async Task CookieChallengeRedirectsWithLoginPath() { @@ -799,7 +764,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies public async Task MapWillAffectChallengeOnlyWithUseAuth(bool useAuth) { var builder = new WebHostBuilder() - .Configure(app => { + .Configure(app => + { if (useAuth) { app.UseAuthentication(); @@ -1296,7 +1262,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } else if (req.Path == new PathString("/unauthorized")) { - await context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme, new AuthenticationProperties(), ChallengeBehavior.Unauthorized); + await context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme, new AuthenticationProperties()); } else if (req.Path == new PathString("/protected/CustomRedirect")) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 060eb649fc..657c957bfb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -20,6 +20,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -44,23 +45,26 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { var dic = new Dictionary { - {"Facebook:AppId", ""}, - {"Facebook:AppSecret", ""}, - {"Facebook:AuthorizationEndpoint", ""}, - {"Facebook:BackchannelTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AppId", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AppSecret", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AuthorizationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:BackchannelTimeout", "0.0:0:30"}, //{"Facebook:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Facebook:ClaimsIssuer", ""}, - {"Facebook:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Facebook:SaveTokens", "true"}, - {"Facebook:SendAppSecretProof", "true"}, - {"Facebook:SignInScheme", ""}, - {"Facebook:TokenEndpoint", ""}, - {"Facebook:UserInformationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:ClaimsIssuer", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SaveTokens", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SendAppSecretProof", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SignInScheme", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:TokenEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:UserInformationEndpoint", ""}, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddFacebookAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddFacebookAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(FacebookDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 2c86bc7781..b316e62751 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -19,6 +19,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -43,23 +44,26 @@ namespace Microsoft.AspNetCore.Authentication.Google { var dic = new Dictionary { - {"Google:ClientId", ""}, - {"Google:ClientSecret", ""}, - {"Google:AuthorizationEndpoint", ""}, - {"Google:BackchannelTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClientId", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClientSecret", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:AuthorizationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:BackchannelTimeout", "0.0:0:30"}, //{"Google:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Google:ClaimsIssuer", ""}, - {"Google:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Google:SaveTokens", "true"}, - {"Google:SendAppSecretProof", "true"}, - {"Google:SignInScheme", ""}, - {"Google:TokenEndpoint", ""}, - {"Google:UserInformationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClaimsIssuer", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:SaveTokens", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:SendAppSecretProof", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:SignInScheme", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:TokenEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:UserInformationEndpoint", ""}, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddGoogleAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddGoogleAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(GoogleDefaults.AuthenticationScheme); @@ -883,42 +887,6 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal("yup", transaction.FindClaimValue("xform")); } - [Fact] - public async Task ChallengeGoogleWhenAlreadySignedInReturnsForbidden() - { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(o => - { - o.ClientId = "Test Id"; - o.ClientSecret = "Test Secret"; - o.StateDataFormat = stateFormat; - o.SaveTokens = true; - o.BackchannelHttpHandler = CreateBackchannel(); - }); - - // Skip the challenge step, go directly to the callback path - - var properties = new AuthenticationProperties(); - var correlationKey = ".xsrf"; - var correlationValue = "TestCorrelationId"; - properties.Items.Add(correlationKey, correlationValue); - properties.RedirectUri = "/me"; - var state = stateFormat.Protect(properties); - var transaction = await server.SendAsync( - "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - $".AspNetCore.Correlation.Google.{correlationValue}=N"); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); - Assert.Equal(2, transaction.SetCookie.Count); - Assert.Contains($".AspNetCore.Correlation.Google.{correlationValue}", transaction.SetCookie[0]); // Delete - Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); - - var authCookie = transaction.AuthenticationCookieValue; - transaction = await server.SendAsync("https://example.com/challenge", authCookie); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.StartsWith("https://example.com/Account/AccessDenied?", transaction.Response.Headers.Location.OriginalString); - } - [Fact] public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 59f1e880c7..6746f5c3f1 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Microsoft.IdentityModel.Tokens; using Xunit; @@ -43,21 +44,24 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { var dic = new Dictionary { - {"Bearer:Audience", ""}, - {"Bearer:Authority", ""}, - {"Bearer:BackchannelTimeout", "0.0:0:30"}, - {"Bearer:Challenge", ""}, - {"Bearer:ClaimsIssuer", ""}, - {"Bearer:IncludeErrorDetails", "true"}, - {"Bearer:MetadataAddress", ""}, - {"Bearer:RefreshOnIssuerKeyNotFound", "true"}, - {"Bearer:RequireHttpsMetadata", "false"}, - {"Bearer:SaveToken", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Audience", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Authority", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:BackchannelTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Challenge", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:ClaimsIssuer", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:IncludeErrorDetails", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:MetadataAddress", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RefreshOnIssuerKeyNotFound", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RequireHttpsMetadata", "false"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:SaveToken", "true"}, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddJwtBearerAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddJwtBearerAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(JwtBearerDefaults.AuthenticationScheme); @@ -74,21 +78,26 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } [Fact] - public void AddWithDelegateIgnoresConfig() + public void AddWithDelegateOverridesConfig() { var dic = new Dictionary { - {"Bearer:Audience", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Audience", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Authority", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RequireHttpsMetadata", "false"} }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddJwtBearerAuthentication(o => o.IncludeErrorDetails = true).AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddJwtBearerAuthentication(o => o.Authority = "authority") + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(JwtBearerDefaults.AuthenticationScheme); - Assert.Null(options.Audience); - Assert.True(options.IncludeErrorDetails); + Assert.Equal("", options.Audience); + Assert.Equal("authority", options.Authority); } [ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")] @@ -440,27 +449,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal("Bob le Tout Puissant", response.ResponseText); } - [Fact] - public async Task BearerTurns401To403IfAuthenticated() - { - var server = CreateServer(options => - { - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); - }); - - var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); - Assert.Equal(HttpStatusCode.Forbidden, response.Response.StatusCode); - } - - [Fact] - public async Task BearerDoesNothingTo401IfNotAuthenticated() - { - var server = CreateServer(); - var response = await SendAsync(server, "http://example.com/unauthorized"); - Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); - } - [Fact] public async Task EventOnMessageReceivedSkip_NoMoreEventsExecuted() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 062215ff46..0d49052f5b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -20,6 +20,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -44,23 +45,26 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { var dic = new Dictionary { - {"Microsoft:ClientId", ""}, - {"Microsoft:ClientSecret", ""}, - {"Microsoft:AuthorizationEndpoint", ""}, - {"Microsoft:BackchannelTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClientId", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClientSecret", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:AuthorizationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:BackchannelTimeout", "0.0:0:30"}, //{"Microsoft:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Microsoft:ClaimsIssuer", ""}, - {"Microsoft:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Microsoft:SaveTokens", "true"}, - {"Microsoft:SendAppSecretProof", "true"}, - {"Microsoft:SignInScheme", ""}, - {"Microsoft:TokenEndpoint", ""}, - {"Microsoft:UserInformationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClaimsIssuer", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SaveTokens", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SendAppSecretProof", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SignInScheme", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:TokenEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:UserInformationEndpoint", ""}, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddMicrosoftAccountAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddMicrosoftAccountAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(MicrosoftAccountDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index b2459cf819..9dc597b856 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -15,6 +15,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; @@ -34,15 +35,18 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { var dic = new Dictionary { - {"OpenIdConnect:ClientId", ""}, - {"OpenIdConnect:ClientSecret", ""}, - {"OpenIdConnect:RequireHttpsMetadata", "false"}, - {"OpenIdConnect:Authority", ""} + {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:ClientId", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:ClientSecret", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:RequireHttpsMetadata", "false"}, + {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:Authority", ""} }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddOpenIdConnectAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddOpenIdConnectAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(OpenIdConnectDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs index 41429cd377..b37ae53d5b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs @@ -5,7 +5,7 @@ using System; using System.IO; using System.Linq; using System.Security.Claims; -using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Testing.xunit; using Xunit; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 1acddc5afd..b8af66cdfb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -14,6 +14,7 @@ using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -37,20 +38,23 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { var dic = new Dictionary { - {"Twitter:ConsumerKey", ""}, - {"Twitter:ConsumerSecret", ""}, - {"Twitter:BackchannelTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ConsumerKey", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ConsumerSecret", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:BackchannelTimeout", "0.0:0:30"}, //{"Twitter:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Twitter:ClaimsIssuer", ""}, - {"Twitter:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Twitter:SaveTokens", "true"}, - {"Twitter:SendAppSecretProof", "true"}, - {"Twitter:SignInScheme", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ClaimsIssuer", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SaveTokens", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SendAppSecretProof", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SignInScheme", ""}, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddTwitterAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddTwitterAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(TwitterDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs index 6825dd868b..714b26c7e1 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -25,9 +25,9 @@ namespace Microsoft.AspNetCore.Authroization.Test // Arrange var attributes = new AuthorizeAttribute[] { new AuthorizeAttribute(), - new AuthorizeAttribute("1") { ActiveAuthenticationSchemes = "dupe" }, - new AuthorizeAttribute("2") { ActiveAuthenticationSchemes = "dupe" }, - new AuthorizeAttribute { Roles = "r1,r2", ActiveAuthenticationSchemes = "roles" }, + new AuthorizeAttribute("1") { AuthenticationSchemes = "dupe" }, + new AuthorizeAttribute("2") { AuthenticationSchemes = "dupe" }, + new AuthorizeAttribute { Roles = "r1,r2", AuthenticationSchemes = "roles" }, }; var options = new AuthorizationOptions(); options.AddPolicy("1", policy => policy.RequireClaim("1")); @@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Authroization.Test // Arrange var attributes = new AuthorizeAttribute[] { new AuthorizeAttribute(), - new AuthorizeAttribute("2") { ActiveAuthenticationSchemes = "dupe" } + new AuthorizeAttribute("2") { AuthenticationSchemes = "dupe" } }; var options = new AuthorizationOptions(); options.DefaultPolicy = new AuthorizationPolicyBuilder("default").RequireClaim("default").Build(); @@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Authroization.Test { // Arrange var attributes = new AuthorizeAttribute[] { - new AuthorizeAttribute() { ActiveAuthenticationSchemes = "a1 , a2" } + new AuthorizeAttribute() { AuthenticationSchemes = "a1 , a2" } }; var options = new AuthorizationOptions(); @@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Authroization.Test { // Arrange var attributes = new AuthorizeAttribute[] { - new AuthorizeAttribute() { ActiveAuthenticationSchemes = "a1 , , ,,, a2" } + new AuthorizeAttribute() { AuthenticationSchemes = "a1 , , ,,, a2" } }; var options = new AuthorizationOptions(); diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 246eed9a50..ef17b94620 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -126,7 +126,8 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "Custom"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); + Assert.True(allowed.Failure.FailCalled); Assert.True(handler1.Invoked); Assert.True(handler2.Invoked); } @@ -154,7 +155,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "Custom"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); Assert.True(handler1.Invoked); Assert.Equal(invokeAllHandlers, handler2.Invoked); } @@ -171,8 +172,6 @@ namespace Microsoft.AspNetCore.Authorization.Test } } - - [Fact] public async Task Authorize_ShouldFailWhenAllRequirementsNotHandled() { @@ -196,7 +195,8 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); + Assert.IsType(allowed.Failure.FailedRequirements.First()); } [Fact] @@ -222,7 +222,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -248,7 +248,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -272,7 +272,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -291,7 +291,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(null, null, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -311,7 +311,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -337,7 +337,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -372,7 +372,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -393,7 +393,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -410,7 +410,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -427,7 +427,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, null, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -443,7 +443,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -464,7 +464,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -489,7 +489,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -527,7 +527,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -553,7 +553,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -575,7 +575,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -597,7 +597,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -622,7 +622,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, null, "Any"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -642,7 +642,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, null, "Any"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } public class CustomRequirement : IAuthorizationRequirement { } @@ -675,7 +675,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, null, "Custom"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -696,7 +696,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, null, "Custom"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } public class PassThroughRequirement : AuthorizationHandler, IAuthorizationRequirement @@ -736,7 +736,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, null, "Passthrough"); // Assert - Assert.Equal(shouldSucceed, allowed); + Assert.Equal(shouldSucceed, allowed.Succeeded); } [Fact] @@ -764,7 +764,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, null, "Combined"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -791,7 +791,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, null, "Combined"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -818,7 +818,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, null, "Combined"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } public class ExpenseReport { } @@ -880,9 +880,9 @@ namespace Microsoft.AspNetCore.Authorization.Test // Act // Assert - Assert.True(await authorizationService.AuthorizeAsync(user, null, Operations.Edit)); - Assert.True(await authorizationService.AuthorizeAsync(user, null, Operations.Delete)); - Assert.True(await authorizationService.AuthorizeAsync(user, null, Operations.Create)); + Assert.True((await authorizationService.AuthorizeAsync(user, null, Operations.Edit)).Succeeded); + Assert.True((await authorizationService.AuthorizeAsync(user, null, Operations.Delete)).Succeeded); + Assert.True((await authorizationService.AuthorizeAsync(user, null, Operations.Create)).Succeeded); } public class NotCalledHandler : AuthorizationHandler @@ -922,8 +922,8 @@ namespace Microsoft.AspNetCore.Authorization.Test // Act // Assert - Assert.False(await authorizationService.AuthorizeAsync(user, 1, Operations.Edit)); - Assert.True(await authorizationService.AuthorizeAsync(user, 2, Operations.Edit)); + Assert.False((await authorizationService.AuthorizeAsync(user, 1, Operations.Edit)).Succeeded); + Assert.True((await authorizationService.AuthorizeAsync(user, 2, Operations.Edit)).Succeeded); } @@ -945,7 +945,7 @@ namespace Microsoft.AspNetCore.Authorization.Test // Act // Assert - Assert.False(await authorizationService.AuthorizeAsync(user, 1, Operations.Edit)); + Assert.False((await authorizationService.AuthorizeAsync(user, 1, Operations.Edit)).Succeeded); } [Fact] @@ -960,9 +960,9 @@ namespace Microsoft.AspNetCore.Authorization.Test // Act // Assert - Assert.True(await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Edit)); - Assert.False(await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Delete)); - Assert.False(await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Create)); + Assert.True((await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Edit)).Succeeded); + Assert.False((await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Delete)).Succeeded); + Assert.False((await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Create)).Succeeded); } [Fact] @@ -977,7 +977,7 @@ namespace Microsoft.AspNetCore.Authorization.Test // Act // Assert - Assert.False(await authorizationService.AuthorizeAsync(user, null, Operations.Edit)); + Assert.False((await authorizationService.AuthorizeAsync(user, null, Operations.Edit)).Succeeded); } [Fact] @@ -996,7 +996,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -1015,7 +1015,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } public class StaticPolicyProvider : IAuthorizationPolicyProvider @@ -1049,7 +1049,7 @@ namespace Microsoft.AspNetCore.Authorization.Test var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } public class DynamicPolicyProvider : IAuthorizationPolicyProvider @@ -1081,23 +1081,15 @@ namespace Microsoft.AspNetCore.Authorization.Test // Act // Assert - Assert.False(await authorizationService.AuthorizeAsync(user, "0")); - Assert.True(await authorizationService.AuthorizeAsync(user, "1")); - Assert.True(await authorizationService.AuthorizeAsync(user, "2")); - Assert.False(await authorizationService.AuthorizeAsync(user, "3")); + Assert.False((await authorizationService.AuthorizeAsync(user, "0")).Succeeded); + Assert.True((await authorizationService.AuthorizeAsync(user, "1")).Succeeded); + Assert.True((await authorizationService.AuthorizeAsync(user, "2")).Succeeded); + Assert.False((await authorizationService.AuthorizeAsync(user, "3")).Succeeded); } public class SuccessEvaluator : IAuthorizationEvaluator { - public bool HasFailed(AuthorizationHandlerContext context) - { - return false; - } - - public bool HasSucceeded(AuthorizationHandlerContext context) - { - return true; - } + public AuthorizationResult Evaluate(AuthorizationHandlerContext context) => AuthorizationResult.Success(); } [Fact] @@ -1108,7 +1100,8 @@ namespace Microsoft.AspNetCore.Authorization.Test services.AddSingleton(); services.AddAuthorization(options => options.AddPolicy("Fail", p => p.RequireAssertion(c => false))); }); - Assert.True(await authorizationService.AuthorizeAsync(null, "Fail")); + var result = await authorizationService.AuthorizeAsync(null, "Fail"); + Assert.True(result.Succeeded); } @@ -1149,7 +1142,26 @@ namespace Microsoft.AspNetCore.Authorization.Test services.AddSingleton(); services.AddAuthorization(options => options.AddPolicy("Success", p => p.RequireAssertion(c => true))); }); - Assert.False(await authorizationService.AuthorizeAsync(null, "Success")); + Assert.False((await authorizationService.AuthorizeAsync(null, "Success")).Succeeded); + } + + public class SadHandlerProvider : IAuthorizationHandlerProvider + { + public Task> GetHandlersAsync(AuthorizationHandlerContext context) + { + return Task.FromResult>(new IAuthorizationHandler[1] { new FailHandler() }); + } + } + + [Fact] + public async Task CanUseCustomHandlerProvider() + { + var authorizationService = BuildAuthorizationService(services => + { + services.AddSingleton(); + services.AddAuthorization(options => options.AddPolicy("Success", p => p.RequireAssertion(c => true))); + }); + Assert.False((await authorizationService.AuthorizeAsync(null, "Success")).Succeeded); } } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 48b134740a..6eb74aeebf 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -9,9 +9,11 @@ + + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs new file mode 100644 index 0000000000..216fc1440e --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs @@ -0,0 +1,179 @@ +// 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.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Microsoft.AspNetCore.Authorization.Policy.Test +{ + public class PolicyEvaluatorTests + { + [Fact] + public async Task AuthenticateFailsIfNoPrincipalReturned() + { + // Arrange + var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var context = new DefaultHttpContext(); + var services = new ServiceCollection().AddSingleton(); + context.RequestServices = services.BuildServiceProvider(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + + // Act + var result = await evaluator.AuthenticateAsync(policy, context); + + // Assert + Assert.False(result.Succeeded); + } + + [Fact] + public async Task AuthenticateMergeSchemes() + { + // Arrange + var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var context = new DefaultHttpContext(); + var services = new ServiceCollection().AddSingleton(); + context.RequestServices = services.BuildServiceProvider(); + var policy = new AuthorizationPolicyBuilder().AddAuthenticationSchemes("A","B","C").RequireAssertion(_ => true).Build(); + + // Act + var result = await evaluator.AuthenticateAsync(policy, context); + + // Assert + Assert.True(result.Succeeded); + Assert.Equal(3, result.Principal.Identities.Count()); + } + + + [Fact] + public async Task AuthorizeSucceedsEvenIfAuthenticationFails() + { + // Arrange + var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var context = new DefaultHttpContext(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + + // Act + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context); + + // Assert + Assert.True(result.Succeeded); + Assert.False(result.Challenged); + Assert.False(result.Forbidden); + } + + [Fact] + public async Task AuthorizeChallengesIfAuthenticationFails() + { + // Arrange + var evaluator = new PolicyEvaluator(new SadAuthorization()); + var context = new DefaultHttpContext(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + + // Act + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context); + + // Assert + Assert.False(result.Succeeded); + Assert.True(result.Challenged); + Assert.False(result.Forbidden); + } + + [Fact] + public async Task AuthorizeForbidsIfAuthenticationSuceeds() + { + // Arrange + var evaluator = new PolicyEvaluator(new SadAuthorization()); + var context = new DefaultHttpContext(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + + // Act + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), "scheme")), context); + + // Assert + Assert.False(result.Succeeded); + Assert.False(result.Challenged); + Assert.True(result.Forbidden); + } + + public class HappyAuthorization : IAuthorizationService + { + public Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) + => Task.FromResult(AuthorizationResult.Success()); + + public Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) + => Task.FromResult(AuthorizationResult.Success()); + } + + public class SadAuthorization : IAuthorizationService + { + public Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) + => Task.FromResult(AuthorizationResult.Failed()); + + public Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) + => Task.FromResult(AuthorizationResult.Failed()); + } + + public class SadAuthentication : IAuthenticationService + { + public Task AuthenticateAsync(HttpContext context, string scheme) + { + return Task.FromResult(AuthenticateResult.Fail("Sad.")); + } + + public Task ChallengeAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task ForbidAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task SignInAsync(HttpContext context, string scheme, ClaimsPrincipal principal, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + } + + public class EchoAuthentication : IAuthenticationService + { + public Task AuthenticateAsync(HttpContext context, string scheme) + { + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(new ClaimsIdentity(scheme)), scheme))); + } + + public Task ChallengeAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task ForbidAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task SignInAsync(HttpContext context, string scheme, ClaimsPrincipal principal, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + } + + } +} \ No newline at end of file From 0b41dd12896c386802c2d72d234bf7eb91966815 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 25 May 2017 20:25:04 -0700 Subject: [PATCH 730/900] Disable api check to unblock build --- .../Microsoft.AspNetCore.Authorization.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 93673ef007..0022d27437 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -11,6 +11,7 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute $(NoWarn);CS1591 true aspnetcore;authorization + false From 348cdf9da9810b768f79dcce6bc39b3918b0863e Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 25 May 2017 23:31:09 -0700 Subject: [PATCH 731/900] Fix sln --- Security.sln | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/Security.sln b/Security.sln index 61ea7b0c31..7c34ff0701 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26510.0 +VisualStudioVersion = 15.0.26507.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -64,10 +64,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authorization.Policy", "src\Microsoft.AspNetCore.Authorization.Policy\Microsoft.AspNetCore.Authorization.Policy.csproj", "{58194599-F07D-47A3-9DF2-E21A22C5EF9E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Abstractions", "..\HttpAbstractions\src\Microsoft.AspNetCore.Authentication.Abstractions\Microsoft.AspNetCore.Authentication.Abstractions.csproj", "{97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Core", "..\HttpAbstractions\src\Microsoft.AspNetCore.Authentication.Core\Microsoft.AspNetCore.Authentication.Core.csproj", "{85545633-7E70-47EA-8CD2-30654C80112C}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -458,38 +454,6 @@ Global {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x64.Build.0 = Release|Any CPU {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.ActiveCfg = Release|Any CPU {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.Build.0 = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x64.ActiveCfg = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x64.Build.0 = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x86.ActiveCfg = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x86.Build.0 = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Any CPU.Build.0 = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x64.ActiveCfg = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x64.Build.0 = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x86.ActiveCfg = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x86.Build.0 = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x64.ActiveCfg = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x64.Build.0 = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x86.ActiveCfg = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x86.Build.0 = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Any CPU.Build.0 = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x64.ActiveCfg = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x64.Build.0 = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x86.ActiveCfg = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -519,7 +483,5 @@ Global {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {58194599-F07D-47A3-9DF2-E21A22C5EF9E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} - {85545633-7E70-47EA-8CD2-30654C80112C} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} EndGlobalSection EndGlobal From c5238390787afb31cc9be15f557ffd9dcc42b049 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 24 May 2017 17:04:14 -0700 Subject: [PATCH 732/900] Update default settings for SameSite - Need Lax policy for social authentication - Need None policy for OIDC --- .gitignore | 1 + .../OpenIdConnect.AzureAdSample/Program.cs | 1 + .../CookieAuthenticationOptions.cs | 18 +++--- .../OpenIdConnectHandler.cs | 6 +- .../TwitterHandler.cs | 2 +- .../RemoteAuthenticationHandler.cs | 8 +-- .../CookiePolicyOptions.cs | 2 +- .../CookiePolicyTests.cs | 56 +++++++++---------- 8 files changed, 49 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index bcc811de9a..d5717b3f3f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,5 @@ project.lock.json .build/ .testPublish/ /.vs/ +.vscode/ global.json diff --git a/samples/OpenIdConnect.AzureAdSample/Program.cs b/samples/OpenIdConnect.AzureAdSample/Program.cs index 9de0185a40..0e1285a9c6 100644 --- a/samples/OpenIdConnect.AzureAdSample/Program.cs +++ b/samples/OpenIdConnect.AzureAdSample/Program.cs @@ -15,6 +15,7 @@ namespace OpenIdConnect.AzureAdSample factory.AddFilter("Console", level => level >= LogLevel.Information); }) .UseKestrel() + .UseUrls("http://localhost:42023") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 02d0361b72..01a5ae9c9d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -22,7 +22,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; - CookieSameSite = SameSiteMode.Strict; + // To support OAuth authentication, a lax mode is required, see https://github.com/aspnet/Security/issues/1231. + CookieSameSite = SameSiteMode.Lax; CookieHttpOnly = true; CookieSecure = CookieSecurePolicy.SameAsRequest; Events = new CookieAuthenticationEvents(); @@ -59,7 +60,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Determines if the browser should allow the cookie to be attached to same-site or cross-site requests. The - /// default is Strict, which means the cookie is only allowed to be attached to same-site requests. + /// default is Lax, which means the cookie is only allowed to be attached to cross-site requests using safe + /// HTTP methods and same-site requests. /// public SameSiteMode CookieSameSite { get; set; } @@ -84,8 +86,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Controls how much time the cookie will remain valid from the point it is created. The expiration - /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored - /// even if it is passed to the server after the browser should have purged it + /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored + /// even if it is passed to the server after the browser should have purged it /// public TimeSpan ExpireTimeSpan { get; set; } @@ -99,7 +101,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// The LoginPath property informs the handler that it should change an outgoing 401 Unauthorized status /// code into a 302 redirection onto the given login path. The current url which generated the 401 is added /// to the LoginPath as a query string parameter named by the ReturnUrlParameter. Once a request to the - /// LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect the browser back + /// LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect the browser back /// to the url which caused the original unauthorized status code. /// public PathString LoginPath { get; set; } @@ -117,15 +119,15 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// The ReturnUrlParameter determines the name of the query string parameter which is appended by the handler - /// when a 401 Unauthorized status code is changed to a 302 redirect onto the login path. This is also the query - /// string parameter looked for when a request arrives on the login path or logout path, in order to return to the + /// when a 401 Unauthorized status code is changed to a 302 redirect onto the login path. This is also the query + /// string parameter looked for when a request arrives on the login path or logout path, in order to return to the /// original url after the action is performed. /// public string ReturnUrlParameter { get; set; } /// /// The Provider may be assigned to an instance of an object created by the application at startup time. The handler - /// calls methods on the provider which give the application control at certain points where processing is occurring. + /// calls methods on the provider which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// public new CookieAuthenticationEvents Events diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 9c8f4ecc6f..89d949a001 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } /// - /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// protected new OpenIdConnectEvents Events @@ -892,7 +892,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect new CookieOptions { HttpOnly = true, - SameSite = Http.SameSiteMode.Lax, + SameSite = Http.SameSiteMode.None, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) }); @@ -924,7 +924,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var cookieOptions = new CookieOptions { HttpOnly = true, - SameSite = Http.SameSiteMode.Lax, + SameSite = Http.SameSiteMode.None, Secure = Request.IsHttps }; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 63a18e83bc..0eab83e41a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter private HttpClient Backchannel => Options.Backchannel; /// - /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// protected new TwitterEvents Events diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 9394b75532..2ff06062de 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -12,7 +12,7 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication { - public abstract class RemoteAuthenticationHandler : AuthenticationHandler, IAuthenticationRequestHandler + public abstract class RemoteAuthenticationHandler : AuthenticationHandler, IAuthenticationRequestHandler where TOptions : RemoteAuthenticationOptions, new() { private const string CorrelationPrefix = ".AspNetCore.Correlation."; @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Authentication protected string SignInScheme => Options.SignInScheme; /// - /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// protected new RemoteAuthenticationEvents Events @@ -203,7 +203,7 @@ namespace Microsoft.AspNetCore.Authentication var cookieOptions = new CookieOptions { HttpOnly = true, - SameSite = SameSiteMode.Lax, + SameSite = SameSiteMode.None, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; @@ -243,7 +243,7 @@ namespace Microsoft.AspNetCore.Authentication var cookieOptions = new CookieOptions { HttpOnly = true, - SameSite = SameSiteMode.Lax, + SameSite = SameSiteMode.None, Secure = Request.IsHttps }; Response.Cookies.Delete(cookieName, cookieOptions); diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index 7203e73e69..1e474bfe22 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Builder /// /// Affects the cookie's same site attribute. /// - public SameSiteMode MinimumSameSitePolicy { get; set; } = SameSiteMode.Strict; + public SameSiteMode MinimumSameSitePolicy { get; set; } = SameSiteMode.Lax; /// /// Affects whether cookies must be HttpOnly. diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index 737c12dc39..b6b2776a8a 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -59,10 +59,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; secure; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; secure; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; secure; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; secure; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; secure; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; secure; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=lax", transaction.SetCookie[3]); })); } @@ -79,10 +79,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=lax", transaction.SetCookie[3]); })); } @@ -99,19 +99,19 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=lax", transaction.SetCookie[3]); }), new RequestTest("https://example.com/secureSame", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; secure; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; secure; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; secure; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; secure; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; secure; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; secure; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=lax", transaction.SetCookie[3]); })); } @@ -128,10 +128,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; samesite=strict; httponly", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; samesite=strict; httponly", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; samesite=strict; httponly", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; samesite=strict; httponly", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=lax; httponly", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=lax; httponly", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=lax; httponly", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=lax; httponly", transaction.SetCookie[3]); })); } @@ -148,10 +148,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; samesite=strict; httponly", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=lax; httponly", transaction.SetCookie[3]); })); } @@ -242,10 +242,10 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test var transaction = await server.SendAsync("http://example.com/login"); Assert.NotNull(transaction.SetCookie); - Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("Hao=Hao; path=/; secure; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("Hao=Hao; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("Hao=Hao; path=/; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("Hao=Hao; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("Hao=Hao; path=/; secure; samesite=lax", transaction.SetCookie[3]); } [Fact] From e65a67bb5c374512e9840f47ed1de2b2e1cc25e1 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Fri, 26 May 2017 12:44:31 -0700 Subject: [PATCH 733/900] Updated to use the latest shared runtime --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index f7e538a504..e804e1b397 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,6 +8,7 @@ 10.0.1 2.0.0-* 3.0.1 + 2.0.0-* 15.3.0-* 2.3.0-beta2-* From e573b8431016541f9ce3992020089af2593239b1 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 31 May 2017 19:37:21 -0700 Subject: [PATCH 734/900] Branching for rel/2.0.0-preview2 --- NuGet.config | 5 +++-- build/dependencies.props | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NuGet.config b/NuGet.config index 93f1ac47df..c4bc056c4d 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,8 +1,9 @@  - + + - + \ No newline at end of file diff --git a/build/dependencies.props b/build/dependencies.props index e804e1b397..02a36ec835 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 2.0.0-* + 2.0.0-preview2-* 4.4.0-* 3.13.8 2.1.3 From f8feee3783fc0220012e1db9d6af458674289611 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 31 May 2017 19:53:33 -0700 Subject: [PATCH 735/900] Updating build scripts to point to 2.0.0-preview2 KoreBuild --- build.ps1 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..3a2476b2b4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview2.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..a40bdb87b1 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview2.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 4034158c614ec1dfe2366afcc7763871a37cfda7 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Wed, 31 May 2017 22:11:21 -0700 Subject: [PATCH 736/900] Removed reference to System.Net.Http --- .../Microsoft.AspNetCore.Authentication.Test.csproj | 1 - .../Microsoft.Owin.Security.Interop.Test.csproj | 1 - 2 files changed, 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index c44069f437..1529dc8036 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -23,7 +23,6 @@ - diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index d6e9d16e5f..14c0aa2f1f 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -14,7 +14,6 @@ - From 8bfab2b3785a3f84e9733dd4ea7c5139ab3a5794 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 1 Jun 2017 10:47:46 -0700 Subject: [PATCH 737/900] Updating versions to preview3 --- NuGet.config | 1 + version.props | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index 93f1ac47df..4e8a1f6de1 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,6 +1,7 @@  + diff --git a/version.props b/version.props index 0b2b8e0010..90a2f5b5cc 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview2 + preview3 \ No newline at end of file From db9ae6263233e1d95245cb911614d0e20a12edfa Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 2 Jun 2017 14:28:03 -0700 Subject: [PATCH 738/900] IInitializeOptions => IPostConfigureOptions --- ...s => CookieAuthenticationPostConfigureOptions.cs} | 12 ++++++------ .../CookieExtensions.cs | 2 +- .../FacebookExtensions.cs | 1 + .../{ => Internal}/FacebookConfigureOptions.cs | 4 ++-- .../GoogleExtensions.cs | 1 + .../{ => Internal}/GoogleConfigureOptions.cs | 4 ++-- .../{ => Internal}/JwtBearerConfigureOptions.cs | 4 ++-- .../JwtBearerExtensions.cs | 3 ++- ...itializer.cs => JwtBearerPostConfigureOptions.cs} | 10 +++++----- .../MicrosoftAccountConfigureOptions.cs | 4 ++-- .../MicrosoftAccountExtensions.cs | 1 + .../OAuthExtensions.cs | 2 +- ...thInitializer.cs => OAuthPostConfigureOptions.cs} | 6 +++--- .../{ => Internal}/OpenIdConnectConfigureOptions.cs | 2 +- .../OpenIdConnectExtensions.cs | 3 ++- ...lizer.cs => OpenIdConnectPostConfigureOptions.cs} | 12 ++++++------ .../{ => Internal}/TwitterConfigureOptions.cs | 4 ++-- .../TwitterExtensions.cs | 3 ++- ...Initializer.cs => TwitterPostConfigureOptions.cs} | 12 ++++++------ .../AuthenticationSchemeOptions.cs | 9 --------- .../AuthenticationServiceCollectionExtensions.cs | 8 +++----- 21 files changed, 51 insertions(+), 56 deletions(-) rename src/Microsoft.AspNetCore.Authentication.Cookies/{CookieAuthenticationInitializer.cs => CookieAuthenticationPostConfigureOptions.cs} (81%) rename src/Microsoft.AspNetCore.Authentication.Facebook/{ => Internal}/FacebookConfigureOptions.cs (78%) rename src/Microsoft.AspNetCore.Authentication.Google/{ => Internal}/GoogleConfigureOptions.cs (79%) rename src/Microsoft.AspNetCore.Authentication.JwtBearer/{ => Internal}/JwtBearerConfigureOptions.cs (79%) rename src/Microsoft.AspNetCore.Authentication.JwtBearer/{JwtBearerInitializer.cs => JwtBearerPostConfigureOptions.cs} (89%) rename src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/{ => Internal}/MicrosoftAccountConfigureOptions.cs (78%) rename src/Microsoft.AspNetCore.Authentication.OAuth/{OAuthInitializer.cs => OAuthPostConfigureOptions.cs} (86%) rename src/Microsoft.AspNetCore.Authentication.OpenIdConnect/{ => Internal}/OpenIdConnectConfigureOptions.cs (91%) rename src/Microsoft.AspNetCore.Authentication.OpenIdConnect/{OpenIdConnectInitializer.cs => OpenIdConnectPostConfigureOptions.cs} (91%) rename src/Microsoft.AspNetCore.Authentication.Twitter/{ => Internal}/TwitterConfigureOptions.cs (80%) rename src/Microsoft.AspNetCore.Authentication.Twitter/{TwitterInitializer.cs => TwitterPostConfigureOptions.cs} (81%) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs similarity index 81% rename from src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs index af4a85b191..38211e0f19 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs @@ -10,21 +10,21 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Used to setup defaults for all . /// - public class CookieAuthenticationInitializer : IInitializeOptions + public class PostConfigureCookieAuthenticationOptions : IPostConfigureOptions { private readonly IDataProtectionProvider _dp; - public CookieAuthenticationInitializer(IDataProtectionProvider dataProtection) + public PostConfigureCookieAuthenticationOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } /// - /// Invoked to initialize a TOptions instance. + /// Invoked to post configure a TOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, CookieAuthenticationOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, CookieAuthenticationOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index b528dec9cb..6f23abcc4a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -21,7 +21,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, CookieAuthenticationInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); return services.AddScheme(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 1bb065414d..7d6fb84421 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Facebook; +using Microsoft.AspNetCore.Authentication.Facebook.Internal; using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs similarity index 78% rename from src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs index 887789ebf1..df1ab710bd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.Facebook +namespace Microsoft.AspNetCore.Authentication.Facebook.Internal { - internal class FacebookConfigureOptions : ConfigureDefaultOptions + public class FacebookConfigureOptions : ConfigureDefaultOptions { public FacebookConfigureOptions(IConfiguration config) : base(FacebookDefaults.AuthenticationScheme, diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index c11b155d9c..07d3e16d61 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Google; +using Microsoft.AspNetCore.Authentication.Google.Internal; using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs similarity index 79% rename from src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs index 1041f1eec5..bbc5e208a7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.Google +namespace Microsoft.AspNetCore.Authentication.Google.Internal { - internal class GoogleConfigureOptions : ConfigureDefaultOptions + public class GoogleConfigureOptions : ConfigureDefaultOptions { public GoogleConfigureOptions(IConfiguration config) : base(GoogleDefaults.AuthenticationScheme, diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs similarity index 79% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs index d26bf66711..5c1e931f40 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer.Internal { - internal class JwtBearerConfigureOptions : ConfigureDefaultOptions + public class JwtBearerConfigureOptions : ConfigureDefaultOptions { // Bind to "Bearer" section by default public JwtBearerConfigureOptions(IConfiguration config) : diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 0bd3a9400c..134e99920b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authentication.JwtBearer.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Infrastructure; @@ -19,7 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); services.AddSingleton, JwtBearerConfigureOptions>(); return services.AddScheme(authenticationScheme, configureOptions); } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs similarity index 89% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs index 0aeed11832..8829bfac0f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs @@ -12,14 +12,14 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// /// Used to setup defaults for all . /// - public class JwtBearerInitializer : IInitializeOptions + public class JwtBearerPostConfigureOptions : IPostConfigureOptions { /// - /// Invoked to initialize a JwtBearerOptions instance. + /// Invoked to post configure a JwtBearerOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, JwtBearerOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, JwtBearerOptions options) { if (string.IsNullOrEmpty(options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(options.Audience)) { diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs similarity index 78% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs index b0be3de977..60591e1e4a 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount +namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal { - internal class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions + public class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions { // Bind to "Microsoft" section by default public MicrosoftAccountConfigureOptions(IConfiguration config) : diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 1a7fee370f..ff743c9728 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; +using Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal; using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 257aed9cb1..4ad0a83362 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -19,7 +19,7 @@ namespace Microsoft.Extensions.DependencyInjection where TOptions : OAuthOptions, new() where THandler : OAuthHandler { - services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs similarity index 86% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs index 99f65253a8..e97346413c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs @@ -12,18 +12,18 @@ namespace Microsoft.Extensions.DependencyInjection /// /// Used to setup defaults for the OAuthOptions. /// - public class OAuthInitializer : IInitializeOptions + public class OAuthPostConfigureOptions : IPostConfigureOptions where TOptions : OAuthOptions, new() where THandler : OAuthHandler { private readonly IDataProtectionProvider _dp; - public OAuthInitializer(IDataProtectionProvider dataProtection) + public OAuthPostConfigureOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } - public void Initialize(string name, TOptions options) + public void PostConfigure(string name, TOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; if (options.Backchannel == null) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs similarity index 91% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs index 1a6450b7b2..c395185151 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal { internal class OpenIdConnectConfigureOptions : ConfigureDefaultOptions { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index b4ac4b9fb7..6c965f047c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Infrastructure; @@ -19,7 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); services.AddSingleton, OpenIdConnectConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs similarity index 91% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs index 7421af9c0a..b79f1d1edf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs @@ -14,21 +14,21 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Used to setup defaults for all . /// - public class OpenIdConnectInitializer : IInitializeOptions + public class OpenIdConnectPostConfigureOptions : IPostConfigureOptions { private readonly IDataProtectionProvider _dp; - public OpenIdConnectInitializer(IDataProtectionProvider dataProtection) + public OpenIdConnectPostConfigureOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } /// - /// Invoked to initialize a TOptions instance. + /// Invoked to post configure a TOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, OpenIdConnectOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, OpenIdConnectOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs similarity index 80% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs index 03d7ae8092..62982fa19a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter.Internal { - internal class TwitterConfigureOptions : ConfigureDefaultOptions + public class TwitterConfigureOptions : ConfigureDefaultOptions { // Bind to "Twitter" section by default public TwitterConfigureOptions(IConfiguration config) : diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index 11586f9844..dac9ee3512 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Twitter; +using Microsoft.AspNetCore.Authentication.Twitter.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Infrastructure; @@ -19,7 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); services.AddSingleton, TwitterConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs similarity index 81% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs index 08e9c5b832..09db5699f9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs @@ -10,21 +10,21 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Used to setup defaults for all . /// - public class TwitterInitializer : IInitializeOptions + public class TwitterPostConfigureOptions : IPostConfigureOptions { private readonly IDataProtectionProvider _dp; - public TwitterInitializer(IDataProtectionProvider dataProtection) + public TwitterPostConfigureOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } /// - /// Invoked to initialize a TOptions instance. + /// Invoked to post configure a TOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, TwitterOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, TwitterOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs index 55bc09d8ae..0e86b3a9ff 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -2,18 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication { - public class InitializeAuthenticationSchemeOptions : InitializeOptions - where TOptions : AuthenticationSchemeOptions - { - public InitializeAuthenticationSchemeOptions(string name) - : base(name, options => options.ClaimsIssuer = options.ClaimsIssuer ?? name) - { } - } - /// /// Contains the options used by the . /// diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index ff367f5557..7ebc979f1b 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -79,12 +77,12 @@ namespace Microsoft.Extensions.DependencyInjection where TOptions : RemoteAuthenticationOptions, new() where THandler : RemoteAuthenticationHandler { - services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); return services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); } // Used to ensure that there's always a default data protection provider - private class EnsureSignInScheme : IInitializeOptions where TOptions : RemoteAuthenticationOptions + private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { private readonly AuthenticationOptions _authOptions; @@ -93,7 +91,7 @@ namespace Microsoft.Extensions.DependencyInjection _authOptions = authOptions.Value; } - public void Initialize(string name, TOptions options) + public void PostConfigure(string name, TOptions options) { options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme; } From ae3dfcdb32647473e24f7c03aa6cb13e83bb7577 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 5 Jun 2017 11:34:35 -0700 Subject: [PATCH 739/900] Remote ConfigureDefaultOptions --- .../FacebookExtensions.cs | 7 +-- .../Internal/FacebookConfigureOptions.cs | 16 ----- ....AspNetCore.Authentication.Facebook.csproj | 1 - .../GoogleExtensions.cs | 7 +-- .../Internal/GoogleConfigureOptions.cs | 16 ----- ...ft.AspNetCore.Authentication.Google.csproj | 1 - .../Internal/JwtBearerConfigureOptions.cs | 17 ----- .../JwtBearerExtensions.cs | 3 - ...AspNetCore.Authentication.JwtBearer.csproj | 1 - .../MicrosoftAccountConfigureOptions.cs | 17 ----- ...ore.Authentication.MicrosoftAccount.csproj | 1 - .../MicrosoftAccountExtensions.cs | 7 +-- .../Internal/OpenIdConnectConfigureOptions.cs | 17 ----- ...etCore.Authentication.OpenIdConnect.csproj | 1 - .../OpenIdConnectExtensions.cs | 3 - .../Internal/TwitterConfigureOptions.cs | 17 ----- ...t.AspNetCore.Authentication.Twitter.csproj | 1 - .../TwitterExtensions.cs | 3 - .../FacebookTests.cs | 63 ------------------- .../GoogleTests.cs | 60 ------------------ .../JwtBearerTests.cs | 62 ------------------ .../MicrosoftAccountTests.cs | 60 ------------------ .../OpenIdConnect/OpenIdConnectTests.cs | 28 --------- .../TwitterTests.cs | 54 ---------------- 24 files changed, 3 insertions(+), 460 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 7d6fb84421..4f30b9ba9c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -3,8 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.Facebook; -using Microsoft.AspNetCore.Authentication.Facebook.Internal; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -17,9 +15,6 @@ namespace Microsoft.Extensions.DependencyInjection => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.AddSingleton, FacebookConfigureOptions>(); - return services.AddOAuthAuthentication(authenticationScheme, configureOptions); - } + => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs deleted file mode 100644 index df1ab710bd..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs +++ /dev/null @@ -1,16 +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.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.Facebook.Internal -{ - public class FacebookConfigureOptions : ConfigureDefaultOptions - { - public FacebookConfigureOptions(IConfiguration config) : - base(FacebookDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+FacebookDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index e39b31e904..a939958e27 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index 07d3e16d61..be40822c57 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -3,8 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.Google; -using Microsoft.AspNetCore.Authentication.Google.Internal; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -17,9 +15,6 @@ namespace Microsoft.Extensions.DependencyInjection => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.AddSingleton, GoogleConfigureOptions>(); - return services.AddOAuthAuthentication(authenticationScheme, configureOptions); - } + => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs deleted file mode 100644 index bbc5e208a7..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs +++ /dev/null @@ -1,16 +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.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.Google.Internal -{ - public class GoogleConfigureOptions : ConfigureDefaultOptions - { - public GoogleConfigureOptions(IConfiguration config) : - base(GoogleDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+GoogleDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index c4f1e7ad8f..9f4cee9d59 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs deleted file mode 100644 index 5c1e931f40..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs +++ /dev/null @@ -1,17 +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.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.JwtBearer.Internal -{ - public class JwtBearerConfigureOptions : ConfigureDefaultOptions - { - // Bind to "Bearer" section by default - public JwtBearerConfigureOptions(IConfiguration config) : - base(JwtBearerDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+JwtBearerDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 134e99920b..582eb6314d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -3,10 +3,8 @@ using System; using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Authentication.JwtBearer.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -21,7 +19,6 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); - services.AddSingleton, JwtBearerConfigureOptions>(); return services.AddScheme(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 5b25e00e86..73d8fdd008 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -11,7 +11,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs deleted file mode 100644 index 60591e1e4a..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs +++ /dev/null @@ -1,17 +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.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal -{ - public class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions - { - // Bind to "Microsoft" section by default - public MicrosoftAccountConfigureOptions(IConfiguration config) : - base(MicrosoftAccountDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+MicrosoftAccountDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 1a954c850a..1accdf8f14 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index ff743c9728..a4ad5692cd 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -3,8 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; -using Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -17,9 +15,6 @@ namespace Microsoft.Extensions.DependencyInjection => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.AddSingleton, MicrosoftAccountConfigureOptions>(); - return services.AddOAuthAuthentication(authenticationScheme, configureOptions); - } + => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs deleted file mode 100644 index c395185151..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs +++ /dev/null @@ -1,17 +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.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal -{ - internal class OpenIdConnectConfigureOptions : ConfigureDefaultOptions - { - // Bind to "OpenIdConnect" section by default - public OpenIdConnectConfigureOptions(IConfiguration config) : - base(OpenIdConnectDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+OpenIdConnectDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 0ce2fe34e0..8e4fb774db 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -12,6 +12,5 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index 6c965f047c..d576409047 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -3,10 +3,8 @@ using System; using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -21,7 +19,6 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); - services.AddSingleton, OpenIdConnectConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs deleted file mode 100644 index 62982fa19a..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs +++ /dev/null @@ -1,17 +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.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.Twitter.Internal -{ - public class TwitterConfigureOptions : ConfigureDefaultOptions - { - // Bind to "Twitter" section by default - public TwitterConfigureOptions(IConfiguration config) : - base(TwitterDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+TwitterDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index b78de6597f..6bf4a66d3f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index dac9ee3512..d8b78398fc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -3,10 +3,8 @@ using System; using Microsoft.AspNetCore.Authentication.Twitter; -using Microsoft.AspNetCore.Authentication.Twitter.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -21,7 +19,6 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); - services.AddSingleton, TwitterConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 657c957bfb..b463ef8911 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -20,7 +20,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -40,68 +39,6 @@ namespace Microsoft.AspNetCore.Authentication.Facebook Assert.Equal(FacebookDefaults.AuthenticationScheme, scheme.DisplayName); } - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AppId", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AppSecret", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AuthorizationEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:BackchannelTimeout", "0.0:0:30"}, - //{"Facebook:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:ClaimsIssuer", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SaveTokens", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SendAppSecretProof", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SignInScheme", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:TokenEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:UserInformationEndpoint", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddFacebookAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(FacebookDefaults.AuthenticationScheme); - Assert.Equal("", options.AppId); - Assert.Equal("", options.AppSecret); - Assert.Equal("", options.AuthorizationEndpoint); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); - //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert - Assert.Equal("", options.ClaimsIssuer); - Assert.Equal("", options.ClientId); - Assert.Equal("", options.ClientSecret); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); - Assert.True(options.SaveTokens); - Assert.True(options.SendAppSecretProof); - Assert.Equal("", options.SignInScheme); - Assert.Equal("", options.TokenEndpoint); - Assert.Equal("", options.UserInformationEndpoint); - } - - [Fact] - public void AddWithDelegateIgnoresConfig() - { - var dic = new Dictionary - { - {"Facebook:AppId", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddFacebookAuthentication(o => o.SaveTokens = false).AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(FacebookDefaults.AuthenticationScheme); - Assert.Null(options.AppId); - Assert.False(options.SaveTokens); - } - [Fact] public async Task ThrowsIfAppIdMissing() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index b316e62751..501fdf6035 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -19,7 +19,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -39,65 +38,6 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal(GoogleDefaults.AuthenticationScheme, scheme.DisplayName); } - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClientId", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClientSecret", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:AuthorizationEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:BackchannelTimeout", "0.0:0:30"}, - //{"Google:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClaimsIssuer", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:SaveTokens", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:SendAppSecretProof", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:SignInScheme", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:TokenEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:UserInformationEndpoint", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddGoogleAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(GoogleDefaults.AuthenticationScheme); - Assert.Equal("", options.AuthorizationEndpoint); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); - //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert - Assert.Equal("", options.ClaimsIssuer); - Assert.Equal("", options.ClientId); - Assert.Equal("", options.ClientSecret); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); - Assert.True(options.SaveTokens); - Assert.Equal("", options.SignInScheme); - Assert.Equal("", options.TokenEndpoint); - Assert.Equal("", options.UserInformationEndpoint); - } - - [Fact] - public void AddWithDelegateIgnoresConfig() - { - var dic = new Dictionary - { - {"Google:ClientId", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddGoogleAuthentication(o => o.SaveTokens = false).AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(GoogleDefaults.AuthenticationScheme); - Assert.Null(options.ClientId); - Assert.False(options.SaveTokens); - } - [Fact] public async Task ChallengeWillTriggerRedirection() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 6746f5c3f1..3149e9875b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -19,7 +19,6 @@ using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Microsoft.IdentityModel.Tokens; using Xunit; @@ -39,67 +38,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Null(scheme.DisplayName); } - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Audience", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Authority", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:BackchannelTimeout", "0.0:0:30"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Challenge", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:ClaimsIssuer", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:IncludeErrorDetails", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:MetadataAddress", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RefreshOnIssuerKeyNotFound", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RequireHttpsMetadata", "false"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:SaveToken", "true"}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddJwtBearerAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(JwtBearerDefaults.AuthenticationScheme); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); - Assert.Equal("", options.Audience); - Assert.Equal("", options.Authority); - Assert.Equal("", options.Challenge); - Assert.Equal("", options.ClaimsIssuer); - Assert.True(options.IncludeErrorDetails); - Assert.Equal("", options.MetadataAddress); - Assert.True(options.RefreshOnIssuerKeyNotFound); - Assert.False(options.RequireHttpsMetadata); - Assert.True(options.SaveToken); - } - - [Fact] - public void AddWithDelegateOverridesConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Audience", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Authority", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RequireHttpsMetadata", "false"} - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddJwtBearerAuthentication(o => o.Authority = "authority") - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(JwtBearerDefaults.AuthenticationScheme); - Assert.Equal("", options.Audience); - Assert.Equal("authority", options.Authority); - } - [ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/179 diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 0d49052f5b..bf15c91b00 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -20,7 +20,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -40,65 +39,6 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount Assert.Equal(MicrosoftAccountDefaults.AuthenticationScheme, scheme.DisplayName); } - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClientId", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClientSecret", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:AuthorizationEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:BackchannelTimeout", "0.0:0:30"}, - //{"Microsoft:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClaimsIssuer", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SaveTokens", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SendAppSecretProof", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SignInScheme", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:TokenEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:UserInformationEndpoint", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddMicrosoftAccountAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(MicrosoftAccountDefaults.AuthenticationScheme); - Assert.Equal("", options.AuthorizationEndpoint); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); - //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert - Assert.Equal("", options.ClaimsIssuer); - Assert.Equal("", options.ClientId); - Assert.Equal("", options.ClientSecret); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); - Assert.True(options.SaveTokens); - Assert.Equal("", options.SignInScheme); - Assert.Equal("", options.TokenEndpoint); - Assert.Equal("", options.UserInformationEndpoint); - } - - [Fact] - public void AddWithDelegateIgnoresConfig() - { - var dic = new Dictionary - { - {"Microsoft:ClientId", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddMicrosoftAccountAuthentication(o => o.SaveTokens = true).AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(MicrosoftAccountDefaults.AuthenticationScheme); - Assert.Null(options.ClientId); - Assert.True(options.SaveTokens); - } - [Fact] public async Task ChallengeWillTriggerApplyRedirectEvent() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 9dc597b856..1708e604ef 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -15,7 +15,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; @@ -30,33 +29,6 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect const string Signin = "/signin"; const string Signout = "/signout"; - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:ClientId", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:ClientSecret", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:RequireHttpsMetadata", "false"}, - {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:Authority", ""} - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddOpenIdConnectAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(OpenIdConnectDefaults.AuthenticationScheme); - Assert.Equal("", options.ClientId); - Assert.Equal("", options.ClientSecret); - Assert.Equal("", options.Authority); - Assert.False(options.RequireHttpsMetadata); - } - - /// /// Tests RedirectForSignOutContext replaces the OpenIdConnectMesssage correctly. /// summary> diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index b8af66cdfb..8fcc0780d2 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -14,7 +14,6 @@ using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -33,59 +32,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter Assert.Equal(TwitterDefaults.AuthenticationScheme, scheme.DisplayName); } - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ConsumerKey", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ConsumerSecret", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:BackchannelTimeout", "0.0:0:30"}, - //{"Twitter:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ClaimsIssuer", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SaveTokens", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SendAppSecretProof", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SignInScheme", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddTwitterAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(TwitterDefaults.AuthenticationScheme); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); - //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert - Assert.Equal("", options.ClaimsIssuer); - Assert.Equal("", options.ConsumerKey); - Assert.Equal("", options.ConsumerSecret); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); - Assert.True(options.SaveTokens); - Assert.Equal("", options.SignInScheme); - } - - [Fact] - public void AddWithDelegateIgnoresConfig() - { - var dic = new Dictionary - { - {"Twitter:ConsumerKey", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddTwitterAuthentication(o => o.SaveTokens = true).AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(TwitterDefaults.AuthenticationScheme); - Assert.Null(options.ConsumerKey); - Assert.True(options.SaveTokens); - } - [Fact] public async Task ChallengeWillTriggerApplyRedirectEvent() { From b7958935429487f04e28b729d3214ddebc36a0eb Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 5 Jun 2017 14:04:33 -0700 Subject: [PATCH 740/900] Remove rogue using --- .../GoogleAppBuilderExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs index d2687239bb..ec7e8a7aab 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -3,7 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.Google; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; From a561da0b3f86b8b242768f47d3283319311ddc2c Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 6 Jun 2017 15:41:17 -0700 Subject: [PATCH 741/900] Remove itemgroup from csproj with unreachable code --- .../Microsoft.AspNetCore.Authorization.Policy.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index 5123b70699..b8447e4154 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -20,8 +20,4 @@ - - - - From 4a258b4565aedd084df05243f679e7dc81e3919b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 8 Jun 2017 08:43:38 -0700 Subject: [PATCH 742/900] Remove usage of TaskCache --- .../CookieAuthenticationHandler.cs | 5 +---- .../Events/CookieAuthenticationEvents.cs | 17 ++++++++--------- ...t.AspNetCore.Authentication.Cookies.csproj | 1 - .../Events/JwtBearerEvents.cs | 9 ++++----- .../JwtBearerAppBuilderExtensions.cs | 1 - ...AspNetCore.Authentication.JwtBearer.csproj | 1 - .../Events/OAuthEvents.cs | 5 ++--- ...oft.AspNetCore.Authentication.OAuth.csproj | 1 - .../Events/OpenIdConnectEvents.cs | 19 +++++++++---------- ...etCore.Authentication.OpenIdConnect.csproj | 1 - .../Events/TwitterEvents.cs | 5 ++--- ...t.AspNetCore.Authentication.Twitter.csproj | 1 - .../AuthenticationHandler.cs | 11 +++++------ .../Events/RemoteAuthenticationEvents.cs | 5 ++--- ...Microsoft.AspNetCore.Authentication.csproj | 1 - ...oft.AspNetCore.Authorization.Policy.csproj | 1 - .../ClaimsAuthorizationRequirement.cs | 3 +-- .../DenyAnonymousAuthorizationRequirement.cs | 3 +-- .../NameAuthorizationRequirement.cs | 3 +-- .../RolesAuthorizationRequirement.cs | 3 +-- .../Microsoft.AspNetCore.Authorization.csproj | 1 - 21 files changed, 37 insertions(+), 60 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index bb2c10fee5..9b04026cd1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -6,11 +6,8 @@ using System.Linq; using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Net.Http.Headers; @@ -50,7 +47,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { // Cookies needs to finish the response Context.Response.OnStarting(FinishResponseAsync); - return TaskCache.CompletedTask; + return Task.CompletedTask; } /// diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs index 5cb933ce1d..c7c375de23 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs @@ -4,7 +4,6 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -18,22 +17,22 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnValidatePrincipal { get; set; } = context => TaskCache.CompletedTask; + public Func OnValidatePrincipal { get; set; } = context => Task.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnSigningIn { get; set; } = context => TaskCache.CompletedTask; + public Func OnSigningIn { get; set; } = context => Task.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnSignedIn { get; set; } = context => TaskCache.CompletedTask; + public Func OnSignedIn { get; set; } = context => Task.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnSigningOut { get; set; } = context => TaskCache.CompletedTask; + public Func OnSigningOut { get; set; } = context => Task.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. @@ -49,7 +48,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// @@ -66,7 +65,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// @@ -82,7 +81,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// @@ -98,7 +97,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; private static bool IsAjaxRequest(HttpRequest request) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 41c4ff7905..95aebf38bc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -18,7 +18,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs index c4e2e7b5a9..a9b35c310f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.JwtBearer { @@ -15,22 +14,22 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. /// - public Func OnAuthenticationFailed { get; set; } = context => TaskCache.CompletedTask; + public Func OnAuthenticationFailed { get; set; } = context => Task.CompletedTask; /// /// Invoked when a protocol message is first received. /// - public Func OnMessageReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnMessageReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. /// - public Func OnTokenValidated { get; set; } = context => TaskCache.CompletedTask; + public Func OnTokenValidated { get; set; } = context => Task.CompletedTask; /// /// Invoked before a challenge is sent back to the caller. /// - public Func OnChallenge { get; set; } = context => TaskCache.CompletedTask; + public Func OnChallenge { get; set; } = context => Task.CompletedTask; public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index 6b1b1afd4a..9755c5cb7d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -3,7 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 73d8fdd008..3c55004a47 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -11,6 +11,5 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs index 4e94a15bc6..b3572cab4c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.OAuth { @@ -15,7 +14,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// Gets or sets the function that is invoked when the CreatingTicket method is invoked. /// - public Func OnCreatingTicket { get; set; } = context => TaskCache.CompletedTask; + public Func OnCreatingTicket { get; set; } = context => Task.CompletedTask; /// /// Gets or sets the delegate that is invoked when the RedirectToAuthorizationEndpoint method is invoked. @@ -23,7 +22,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth public Func OnRedirectToAuthorizationEndpoint { get; set; } = context => { context.Response.Redirect(context.RedirectUri); - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 508c815fe8..88d6794e9d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index f6386aeec8..660eba0b33 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { @@ -15,47 +14,47 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. /// - public Func OnAuthenticationFailed { get; set; } = context => TaskCache.CompletedTask; + public Func OnAuthenticationFailed { get; set; } = context => Task.CompletedTask; /// /// Invoked after security token validation if an authorization code is present in the protocol message. /// - public Func OnAuthorizationCodeReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnAuthorizationCodeReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked when a protocol message is first received. /// - public Func OnMessageReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnMessageReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked before redirecting to the identity provider to authenticate. /// - public Func OnRedirectToIdentityProvider { get; set; } = context => TaskCache.CompletedTask; + public Func OnRedirectToIdentityProvider { get; set; } = context => Task.CompletedTask; /// /// Invoked before redirecting to the identity provider to sign out. /// - public Func OnRedirectToIdentityProviderForSignOut { get; set; } = context => TaskCache.CompletedTask; + public Func OnRedirectToIdentityProviderForSignOut { get; set; } = context => Task.CompletedTask; /// /// Invoked when a request is received on the RemoteSignOutPath. /// - public Func OnRemoteSignOut { get; set; } = context => TaskCache.CompletedTask; + public Func OnRemoteSignOut { get; set; } = context => Task.CompletedTask; /// /// Invoked after "authorization code" is redeemed for tokens at the token endpoint. /// - public Func OnTokenResponseReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnTokenResponseReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked when an IdToken has been validated and produced an AuthenticationTicket. /// - public Func OnTokenValidated { get; set; } = context => TaskCache.CompletedTask; + public Func OnTokenValidated { get; set; } = context => Task.CompletedTask; /// /// Invoked when user information is retrieved from the UserInfoEndpoint. /// - public Func OnUserInformationReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnUserInformationReceived { get; set; } = context => Task.CompletedTask; public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 8e4fb774db..d3789cd507 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -10,7 +10,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs index 2c8b30e9fc..c079ebb14f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.Twitter { @@ -15,7 +14,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Gets or sets the function that is invoked when the Authenticated method is invoked. /// - public Func OnCreatingTicket { get; set; } = context => TaskCache.CompletedTask; + public Func OnCreatingTicket { get; set; } = context => Task.CompletedTask; /// /// Gets or sets the delegate that is invoked when the ApplyRedirect method is invoked. @@ -23,7 +22,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter public Func OnRedirectToAuthorizationEndpoint { get; set; } = context => { context.Response.Redirect(context.RedirectUri); - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 6bf4a66d3f..8d834ee8d1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index b094709196..788df7e19c 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -7,7 +7,6 @@ using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -119,7 +118,7 @@ namespace Microsoft.AspNetCore.Authentication /// A task protected virtual Task InitializeHandlerAsync() { - return TaskCache.CompletedTask; + return Task.CompletedTask; } protected string BuildRedirectUri(string targetPath) @@ -193,7 +192,7 @@ namespace Microsoft.AspNetCore.Authentication protected virtual Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } public async Task SignOutAsync(AuthenticationProperties properties) @@ -205,7 +204,7 @@ namespace Microsoft.AspNetCore.Authentication protected virtual Task HandleSignOutAsync(AuthenticationProperties properties) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } /// @@ -216,7 +215,7 @@ namespace Microsoft.AspNetCore.Authentication protected virtual Task HandleForbiddenAsync(AuthenticationProperties properties) { Response.StatusCode = 403; - return TaskCache.CompletedTask; + return Task.CompletedTask; } /// @@ -229,7 +228,7 @@ namespace Microsoft.AspNetCore.Authentication protected virtual Task HandleChallengeAsync(AuthenticationProperties properties) { Response.StatusCode = 401; - return TaskCache.CompletedTask; + return Task.CompletedTask; } public async Task ChallengeAsync(AuthenticationProperties properties) diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs index a130c1b14c..83a6507d42 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs @@ -3,15 +3,14 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication { public class RemoteAuthenticationEvents { - public Func OnRemoteFailure { get; set; } = context => TaskCache.CompletedTask; + public Func OnRemoteFailure { get; set; } = context => Task.CompletedTask; - public Func OnTicketReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnTicketReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked when there is a remote failure diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index cbdb05b58a..adbd5b3f16 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -19,7 +19,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index b8447e4154..83530a2bed 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -17,7 +17,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs index 4248e4813d..93b1deea6d 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -68,7 +67,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure context.Succeed(requirement); } } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs index 5bae319b3e..e88cce7aac 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -28,7 +27,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure { context.Succeed(requirement); } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs index 9fb295082b..02ab946fad 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -47,7 +46,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure context.Succeed(requirement); } } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs index 44e2b9a220..811e17aacd 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -62,7 +61,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure context.Succeed(requirement); } } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 0022d27437..15100fbbcc 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -17,7 +17,6 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute - From d6f2767d1aefde024279a3bcb6774f8f2b46e7c1 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 9 Jun 2017 15:45:35 -0700 Subject: [PATCH 743/900] Update Microsoft.IdentityModel.Clients.ActiveDirectory version to 3.13.9 --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 02a36ec835..1fd0f3155f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,7 +2,7 @@ 2.0.0-preview2-* 4.4.0-* - 3.13.8 + 3.13.9 2.1.3 2.1.0-* 10.0.1 From bc3c4e9f12f432f69abc5a9d6ee42573cef5818e Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 9 Jun 2017 16:23:47 -0700 Subject: [PATCH 744/900] #1200 Doc comments for OnRedirectToIdentityProvider --- .../Events/OpenIdConnectEvents.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index 660eba0b33..d8467be8d7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -27,7 +27,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect public Func OnMessageReceived { get; set; } = context => Task.CompletedTask; /// - /// Invoked before redirecting to the identity provider to authenticate. + /// Invoked before redirecting to the identity provider to authenticate. This can be used to set ProtocolMessage.State + /// that will be persisted through the authentication process. The ProtocolMessage can also be used to add or customize + /// parameters sent to the identity provider. /// public Func OnRedirectToIdentityProvider { get; set; } = context => Task.CompletedTask; From 9797d4bc5f3e54ffca3487c038044990585e278c Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 12 Jun 2017 14:58:11 -0700 Subject: [PATCH 745/900] Reenable API check --- ...t.AspNetCore.Authentication.Cookies.csproj | 1 - .../breakingchanges.netcore.json | 87 ++++++++++++ ....AspNetCore.Authentication.Facebook.csproj | 1 - .../breakingchanges.netcore.json | 19 +++ ...ft.AspNetCore.Authentication.Google.csproj | 1 - .../breakingchanges.netcore.json | 40 ++++++ ...AspNetCore.Authentication.JwtBearer.csproj | 1 - .../breakingchanges.netcore.json | 58 ++++++++ ...ore.Authentication.MicrosoftAccount.csproj | 1 - .../breakingchanges.netcore.json | 19 +++ ...oft.AspNetCore.Authentication.OAuth.csproj | 1 - .../breakingchanges.netcore.json | 46 +++++++ ...etCore.Authentication.OpenIdConnect.csproj | 1 - .../breakingchanges.netcore.json | 117 ++++++++++++++++ ...t.AspNetCore.Authentication.Twitter.csproj | 1 - .../breakingchanges.netcore.json | 62 +++++++++ ...Microsoft.AspNetCore.Authentication.csproj | 1 - .../breakingchanges.netcore.json | 126 ++++++++++++++++++ 18 files changed, 574 insertions(+), 9 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 95aebf38bc..712aa81772 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -9,7 +9,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json new file mode 100644 index 0000000000..c223c035c4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json @@ -0,0 +1,87 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext : Microsoft.AspNetCore.Authentication.BaseContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents : Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.CookieAuthenticationOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions, Microsoft.Extensions.Options.IOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Authentication.AuthenticationTicket ticket, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, Microsoft.AspNetCore.Http.CookieOptions cookieOptions)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String authenticationScheme, System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String authenticationScheme, System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, Microsoft.AspNetCore.Http.CookieOptions cookieOptions)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String redirectUri, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseCookieAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index a939958e27..a9ec571996 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json new file mode 100644 index 0000000000..f64e6b8342 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json @@ -0,0 +1,19 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.FacebookOptions : Microsoft.AspNetCore.Builder.OAuthOptions", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Facebook.FacebookHelper", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseFacebookAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.FacebookOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index 9f4cee9d59..805de682fd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json new file mode 100644 index 0000000000..db3d1fcf0c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json @@ -0,0 +1,40 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Google.GoogleMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.GoogleOptions : Microsoft.AspNetCore.Builder.OAuthOptions", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.GoogleAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseGoogleAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.GoogleOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "MemberId": "public static System.String GetFamilyName(Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "MemberId": "public static System.String GetGivenName(Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "MemberId": "public static System.String GetId(Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "MemberId": "public static System.String GetName(Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "MemberId": "public static System.String GetProfile(Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 3c55004a47..fe0bda1647 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -6,7 +6,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json new file mode 100644 index 0000000000..d810a2bb90 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json @@ -0,0 +1,58 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents : Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.JwtBearerOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public Microsoft.AspNetCore.Builder.JwtBearerOptions get_Options()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJwtBearerAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 1accdf8f14..9437b57276 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json new file mode 100644 index 0000000000..66f2a77b4e --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json @@ -0,0 +1,19 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.MicrosoftAccountOptions : Microsoft.AspNetCore.Builder.OAuthOptions", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.MicrosoftAccountAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseMicrosoftAccountAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.MicrosoftAccountOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 88d6794e9d..a15a75ee6f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json new file mode 100644 index 0000000000..96fd03e985 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json @@ -0,0 +1,46 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext : Microsoft.AspNetCore.Authentication.BaseContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler : Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.OAuthOptions", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware where T0 : Microsoft.AspNetCore.Builder.OAuthOptions, new()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.OAuthOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OAuthOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, System.String redirectUri)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", + "MemberId": "public Microsoft.AspNetCore.Builder.OAuthOptions get_Options()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOAuthAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OAuthOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index d3789cd507..ae8ffd8d59 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -6,7 +6,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json new file mode 100644 index 0000000000..4ba3fb756a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json @@ -0,0 +1,117 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler : Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.OpenIdConnectOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public Microsoft.AspNetCore.Builder.OpenIdConnectOptions get_Options()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage message)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOpenIdConnectAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 8d834ee8d1..d9c5cd0b37 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json new file mode 100644 index 0000000000..2023eb0b7a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json @@ -0,0 +1,62 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext : Microsoft.AspNetCore.Authentication.BaseContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.TwitterOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.TwitterOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, System.String redirectUri)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.TwitterOptions options, System.String userId, System.String screenName, System.String accessToken, System.String accessTokenSecret, Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseTwitterAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.TwitterOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index adbd5b3f16..8a1f970423 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json new file mode 100644 index 0000000000..0eb0bfaf5f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json @@ -0,0 +1,126 @@ + [ + { + "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.AuthenticationHandler : Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.AuthenticationMiddleware where T0 : Microsoft.AspNetCore.Builder.AuthenticationOptions, new()", + "Kind": "Removal" + }, + { + "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public abstract class Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticationToken", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler : Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformer : Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.PropertiesDataFormat : Microsoft.AspNetCore.Authentication.SecureDataFormat", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.PropertiesSerializer : Microsoft.AspNetCore.Authentication.IDataSerializer", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions options, Microsoft.AspNetCore.Authentication.AuthenticationTicket ticket)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions get_Options()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public System.Void set_Options(Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configureOptions)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", + "MemberId": "public System.Boolean CheckEventResult(out Microsoft.AspNetCore.Authentication.AuthenticateResult result)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", + "MemberId": "public System.Void SkipToNextMiddleware()", + "Kind": "Removal" + } + ] \ No newline at end of file From 200ce723120a9e5672aa9d2ee07ce5422bcb0a5e Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 13 Jun 2017 11:51:00 -0700 Subject: [PATCH 746/900] Rename PostLogoutRedirectUri to avoid spec confusion --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- .../OpenIdConnectHandler.cs | 2 +- .../OpenIdConnectOptions.cs | 5 +++-- .../OpenIdConnect/OpenIdConnectTests.cs | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index ebb59c0604..e6ad7804d3 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -58,7 +58,7 @@ namespace OpenIdConnect.AzureAdSample o.ClientSecret = ClientSecret; // for code flow o.Authority = Authority; o.ResponseType = OpenIdConnectResponseType.CodeIdToken; - o.PostLogoutRedirectUri = "/signed-out"; + o.SignedOutRedirectUri = "/signed-out"; // GetClaimsFromUserInfoEndpoint = true, o.Events = new OpenIdConnectEvents() { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 89d949a001..f4dcea4c84 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -182,7 +182,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // Get the post redirect URI. if (string.IsNullOrEmpty(properties.RedirectUri)) { - properties.RedirectUri = BuildRedirectUriIfRelative(Options.PostLogoutRedirectUri); + properties.RedirectUri = BuildRedirectUriIfRelative(Options.SignedOutRedirectUri); if (string.IsNullOrWhiteSpace(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index b2d69d5249..a199016ddf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -167,15 +167,16 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// The request path within the application's base path where the user agent will be returned after sign out from the identity provider. + /// See post_logout_redirect_uri from http://openid.net/specs/openid-connect-session-1_0.html#RedirectionAfterLogout. /// public PathString SignedOutCallbackPath { get; set; } /// - /// The uri where the user agent will be returned to after application is signed out from the identity provider. + /// The uri where the user agent will be redirected to after application is signed out from the identity provider. /// The redirect will happen after the SignedOutCallbackPath is invoked. /// /// This URI can be out of the application's domain. By default it points to the root. - public string PostLogoutRedirectUri { get; set; } = "/"; + public string SignedOutRedirectUri { get; set; } = "/"; /// /// Gets or sets if a metadata refresh should be attempted after a SecurityTokenSignatureKeyNotFoundException. This allows for automatic diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 1708e604ef..99bc1ec8c8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect o.Configuration = configuration; o.StateDataFormat = stateFormat; o.SignedOutCallbackPath = "/thelogout"; - o.PostLogoutRedirectUri = "https://example.com/postlogout"; + o.SignedOutRedirectUri = "https://example.com/postlogout"; }); var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); @@ -150,7 +150,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect o.StateDataFormat = stateFormat; o.ClientId = "Test Id"; o.Configuration = configuration; - o.PostLogoutRedirectUri = "https://example.com/postlogout"; + o.SignedOutRedirectUri = "https://example.com/postlogout"; }); var transaction = await server.SendAsync("https://example.com/signout_with_specific_redirect_uri"); From 879f0b7f4053a34b44e34bd22c788c6129115175 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Tue, 13 Jun 2017 09:10:14 -0700 Subject: [PATCH 747/900] [Fixes #1133] Limit the path on the nonce and correlation id cookies --- .../OpenIdConnectHandler.cs | 22 ++-- .../OpenIdConnectOptions.cs | 6 + .../TwitterHandler.cs | 4 + .../TwitterOptions.cs | 6 + .../RemoteAuthenticationHandler.cs | 7 ++ .../RemoteAuthenticationOptions.cs | 6 + .../OAuthTests.cs | 65 +++++++++++ .../OpenIdConnect/OpenIdConnectTests.cs | 105 +++++++++++++++++- 8 files changed, 213 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index f4dcea4c84..1dec541970 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -886,16 +886,21 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect throw new ArgumentNullException(nameof(nonce)); } + var options = new CookieOptions + { + HttpOnly = true, + SameSite = Http.SameSiteMode.None, + Path = OriginalPathBase + Options.CallbackPath, + Secure = Request.IsHttps, + Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) + }; + + Options.ConfigureNonceCookie?.Invoke(Context, options); + Response.Cookies.Append( OpenIdConnectDefaults.CookieNoncePrefix + Options.StringDataFormat.Protect(nonce), NonceProperty, - new CookieOptions - { - HttpOnly = true, - SameSite = Http.SameSiteMode.None, - Secure = Request.IsHttps, - Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) - }); + options); } /// @@ -924,10 +929,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var cookieOptions = new CookieOptions { HttpOnly = true, + Path = OriginalPathBase + Options.CallbackPath, SameSite = Http.SameSiteMode.None, Secure = Request.IsHttps }; + Options.ConfigureNonceCookie?.Invoke(Context, cookieOptions); + Response.Cookies.Delete(nonceKey, cookieOptions); return nonce; } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index a199016ddf..a42f0eba33 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -262,5 +262,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// remote OpenID Connect provider as an authorization/logout request parameter. /// public bool DisableTelemetry { get; set; } + + /// + /// Gets or sets an action that can override the nonce cookie options before the + /// cookie gets added to the response. + /// + public Action ConfigureNonceCookie { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 0eab83e41a..baa4320d1b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -87,6 +87,8 @@ namespace Microsoft.AspNetCore.Authentication.Twitter Secure = Request.IsHttps }; + Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); + Response.Cookies.Delete(StateCookie, cookieOptions); var accessToken = await ObtainAccessTokenAsync(requestToken, oauthVerifier); @@ -159,6 +161,8 @@ namespace Microsoft.AspNetCore.Authentication.Twitter Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; + Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); + Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions); var redirectContext = new TwitterRedirectToAuthorizationEndpointContext(Context, Scheme, Options, properties, twitterAuthenticationEndpoint); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index cf1bf48566..8b57f2502f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -58,6 +58,12 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// public ISecureDataFormat StateDataFormat { get; set; } + /// + /// Gets or sets an action that can override the state cookie options before the + /// cookie gets added to the response. + /// + public Action ConfigureStateCookie { get; set; } + /// /// Gets or sets the used to handle authentication events. /// diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 2ff06062de..69c926cc0f 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -205,9 +205,12 @@ namespace Microsoft.AspNetCore.Authentication HttpOnly = true, SameSite = SameSiteMode.None, Secure = Request.IsHttps, + Path = OriginalPathBase + Options.CallbackPath, Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; + Options.ConfigureCorrelationIdCookie?.Invoke(Context, cookieOptions); + properties.Items[CorrelationProperty] = correlationId; var cookieName = CorrelationPrefix + Scheme.Name + "." + correlationId; @@ -243,9 +246,13 @@ namespace Microsoft.AspNetCore.Authentication var cookieOptions = new CookieOptions { HttpOnly = true, + Path = OriginalPathBase + Options.CallbackPath, SameSite = SameSiteMode.None, Secure = Request.IsHttps }; + + Options.ConfigureCorrelationIdCookie?.Invoke(Context, cookieOptions); + Response.Cookies.Delete(cookieName, cookieOptions); if (!string.Equals(correlationCookie, CorrelationMarker, StringComparison.Ordinal)) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 65cf6f2ec7..066ca963a3 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -87,5 +87,11 @@ namespace Microsoft.AspNetCore.Authentication /// the size of the final authentication cookie. /// public bool SaveTokens { get; set; } + + /// + /// Gets or sets an action that can override the correlation id cookie options before the + /// cookie gets added to the response. + /// + public Action ConfigureCorrelationIdCookie { get; set; } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 2381fd6cd7..dcc96c0942 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -4,6 +4,7 @@ using System; using System.Net; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -165,6 +166,70 @@ namespace Microsoft.AspNetCore.Authentication.OAuth Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } + [Fact] + public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallBackPath() + { + var server = CreateServer( + app => { }, + s => s.AddOAuthAuthentication( + "Weblie", + opt => + { + opt.ClientId = "Test Id"; + opt.ClientSecret = "secret"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.AuthorizationEndpoint = "https://example.com/provider/login"; + opt.TokenEndpoint = "https://example.com/provider/token"; + opt.CallbackPath = "/oauth-callback"; + }), + ctx => + { + ctx.ChallengeAsync("Weblie").ConfigureAwait(false).GetAwaiter().GetResult(); + return true; + }); + + var transaction = await server.SendAsync("https://www.example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var correlation = Assert.Single(setCookie.Value, v => v.StartsWith(".AspNetCore.Correlation.")); + Assert.Contains("path=/oauth-callback", correlation); + } + + [Fact] + public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOverriden() + { + var server = CreateServer( + app => { }, + s => s.AddOAuthAuthentication( + "Weblie", + opt => + { + opt.ClientId = "Test Id"; + opt.ClientSecret = "secret"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.AuthorizationEndpoint = "https://example.com/provider/login"; + opt.TokenEndpoint = "https://example.com/provider/token"; + opt.CallbackPath = "/oauth-callback"; + opt.ConfigureCorrelationIdCookie = (ctx, options) => options.Path = "/"; + }), + ctx => + { + ctx.ChallengeAsync("Weblie").ConfigureAwait(false).GetAwaiter().GetResult(); + return true; + }); + + var transaction = await server.SendAsync("https://www.example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var correlation = Assert.Single(setCookie.Value, v => v.StartsWith(".AspNetCore.Correlation.")); + Assert.Contains("path=/", correlation); + } private static TestServer CreateServer(Action configure, Action configureServices, Func handler) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 99bc1ec8c8..6cfda3b85a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -60,6 +60,108 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OpenIdConnectParameterNames.VersionTelemetry); } + [Fact] + public async Task RedirectToIdentityProvider_SetsNonceCookiePath_ToCallBackPath() + { + var setting = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.Configuration = new OpenIdConnectConfiguration + { + AuthorizationEndpoint = "https://example.com/provider/login" + }; + }); + + var server = setting.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Challenge); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var nonce = Assert.Single(setCookie.Value, v => v.StartsWith(OpenIdConnectDefaults.CookieNoncePrefix)); + Assert.Contains("path=/signin-oidc", nonce); + } + + [Fact] + public async Task RedirectToIdentityProvider_NonceCookieOptions_CanBeOverriden() + { + var setting = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.Configuration = new OpenIdConnectConfiguration + { + AuthorizationEndpoint = "https://example.com/provider/login" + }; + opt.ConfigureNonceCookie = (ctx, options) => options.Path = "/"; + }); + + var server = setting.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Challenge); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var nonce = Assert.Single(setCookie.Value, v => v.StartsWith(OpenIdConnectDefaults.CookieNoncePrefix)); + Assert.Contains("path=/", nonce); + } + + [Fact] + public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallBackPath() + { + var setting = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.Configuration = new OpenIdConnectConfiguration + { + AuthorizationEndpoint = "https://example.com/provider/login" + }; + }); + + var server = setting.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Challenge); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var correlation = Assert.Single(setCookie.Value, v => v.StartsWith(".AspNetCore.Correlation.")); + Assert.Contains("path=/signin-oidc", correlation); + } + + [Fact] + public async Task RedirectToIdentityProvider_CorrelationIdCookieOptions_CanBeOverriden() + { + var setting = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.Configuration = new OpenIdConnectConfiguration + { + AuthorizationEndpoint = "https://example.com/provider/login" + }; + opt.ConfigureCorrelationIdCookie = (ctx, options) => options.Path = "/"; + }); + + var server = setting.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Challenge); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var correlation = Assert.Single(setCookie.Value, v => v.StartsWith(".AspNetCore.Correlation.")); + Assert.Contains("path=/", correlation); + } + [Fact] public async Task EndSessionRequestDoesNotIncludeTelemetryParametersWhenDisabled() { @@ -173,7 +275,8 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect [Fact] public async Task SignOut_WithMissingConfig_Throws() { - var setting = new TestSettings(opt => { + var setting = new TestSettings(opt => + { opt.ClientId = "Test Id"; opt.Configuration = new OpenIdConnectConfiguration(); }); From 05c6cbe46697ff298aa7e416f7c2873791a03063 Mon Sep 17 00:00:00 2001 From: Gerardo Saca Date: Fri, 23 Jun 2017 09:00:31 -0700 Subject: [PATCH 748/900] Fix documentation for JwtBearerOptions.Events (#1249) --- .../JwtBearerOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs index 9a480763d4..0d0a88e247 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// /// The object provided by the application to process events raised by the bearer authentication handler. - /// 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 JwtBearerEvents /// and assign delegates only to the events it wants to process. /// public new JwtBearerEvents Events From 717625c948a7b333b1a4aeda8d5a092d7ba5eca0 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 26 Jun 2017 09:42:10 -0700 Subject: [PATCH 749/900] Adding libunwind8 to .travis.yml [skip appveyor] --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2a46104677..b10be14215 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ os: - linux - osx osx_image: xcode8.2 +addons: + apt: + packages: + - libunwind8 branches: only: - master From 80383606d3988095abb74ff726439261f168ce43 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 27 Jun 2017 10:31:08 -0700 Subject: [PATCH 750/900] AuthZ: Eliminate extra ToArray() --- .../AuthorizationServiceExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs index c128152326..866b5dbc51 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Authorization throw new ArgumentNullException(nameof(policy)); } - return service.AuthorizeAsync(user, resource, policy.Requirements.ToArray()); + return service.AuthorizeAsync(user, resource, policy.Requirements); } /// From e1cd8c9bc4ae33704bc8fd44bfdacd12618e172a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 29 Jun 2017 08:50:23 -0700 Subject: [PATCH 751/900] Add NETStandardImplicitPackageVersion --- build/dependencies.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 8f40044d1d..f00799700a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,4 +1,4 @@ - + 2.0.0-* 4.4.0-* @@ -6,6 +6,7 @@ 2.1.3 2.1.0-* 10.0.1 + 2.0.0-* 2.0.0-* 3.0.1 2.0.0-* From ff9f145a8e89c9756ea12ff10c6d47f2f7eb345f Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 29 Jun 2017 16:27:03 -0700 Subject: [PATCH 752/900] Refactor Events + Add IAuthenticationBuilder --- samples/CookieSample/Startup.cs | 4 +- samples/CookieSessionSample/Startup.cs | 4 +- samples/JwtBearerSample/Startup.cs | 6 +- .../OpenIdConnect.AzureAdSample/Startup.cs | 8 +- samples/OpenIdConnectSample/Startup.cs | 8 +- samples/SocialSample/Startup.cs | 83 ++- .../CookieAuthenticationHandler.cs | 40 +- .../CookieExtensions.cs | 24 +- .../Events/BaseCookieContext.cs | 30 -- .../Events/CookieAuthenticationEvents.cs | 16 +- .../Events/CookieSignedInContext.cs | 15 +- .../Events/CookieSigningInContext.cs | 14 +- .../Events/CookieSigningOutContext.cs | 8 +- .../Events/CookieValidatePrincipalContext.cs | 30 +- .../LoggingExtensions.cs | 35 ++ ...stConfigureCookieAuthenticationOptions.cs} | 1 - .../breakingchanges.netcore.json | 80 +-- .../FacebookExtensions.cs | 12 + .../FacebookHandler.cs | 6 +- .../GoogleExtensions.cs | 13 + .../GoogleHandler.cs | 7 +- .../Events/AuthenticationFailedContext.cs | 11 +- .../Events/BaseJwtBearerContext.cs | 32 -- .../Events/JwtBearerChallengeContext.cs | 25 +- .../Events/MessageReceivedContext.cs | 11 +- .../Events/TokenValidatedContext.cs | 11 +- .../JwtBearerExtensions.cs | 15 + .../JwtBearerHandler.cs | 46 +- .../breakingchanges.netcore.json | 27 +- .../MicrosoftAccountExtensions.cs | 13 + .../MicrosoftAccountHandler.cs | 5 +- .../Events/OAuthCreatingTicketContext.cs | 61 +-- .../Events/OAuthEvents.cs | 6 +- .../OAuthRedirectToAuthorizationContext.cs | 41 -- .../OAuthExtensions.cs | 13 + .../OAuthHandler.cs | 27 +- .../breakingchanges.netcore.json | 19 +- .../Events/AuthenticationFailedContext.cs | 11 +- .../AuthorizationCodeReceivedContext.cs | 16 +- .../Events/BaseOpenIdConnectContext.cs | 25 - .../Events/MessageReceivedContext.cs | 17 +- .../Events/RedirectContext.cs | 26 +- .../Events/RemoteSignoutContext.cs | 16 +- .../Events/TokenResponseReceivedContext.cs | 13 +- .../Events/TokenValidatedContext.cs | 17 +- .../Events/UserInformationReceivedContext.cs | 13 +- .../LoggingExtensions.cs | 30 +- .../OpenIdConnectExtensions.cs | 14 + .../OpenIdConnectHandler.cs | 314 ++++++------ .../OpenIdConnectOptions.cs | 5 - .../breakingchanges.netcore.json | 128 ++--- .../Events/BaseTwitterContext.cs | 30 -- .../Events/TwitterCreatingTicketContext.cs | 15 +- .../Events/TwitterEvents.cs | 4 +- ...rRedirectToAuthorizationEndpointContext.cs | 35 -- .../TwitterExtensions.cs | 14 + .../TwitterHandler.cs | 25 +- .../breakingchanges.netcore.json | 33 +- .../AuthenticationBuilder.cs | 103 ++++ .../AuthenticationHandler.cs | 29 -- ...thenticationServiceCollectionExtensions.cs | 11 +- .../Events/BaseAuthenticationContext.cs | 41 -- .../Events/BaseContext.cs | 38 +- .../Events/BaseControlContext.cs | 78 --- .../Events/EventResultState.cs | 23 - .../Events/HandleRequestContext.cs | 32 ++ .../Events/PrincipalContext.cs | 30 ++ .../Events/PropertiesContext.cs | 31 ++ .../Events/RedirectContext.cs} | 18 +- .../Events/RemoteAuthenticationContext.cs | 49 ++ .../Events/RemoteAuthenticationEvents.cs | 4 +- ...lureContext.cs => RemoteFailureContext.cs} | 10 +- .../Events/ResultContext.cs | 65 +++ .../Events/TicketReceivedContext.cs | 25 +- .../LoggingExtensions.cs | 60 --- .../RemoteAuthenticationHandler.cs | 73 ++- .../RemoteAuthenticationOptions.cs | 5 - .../RemoteAuthenticationResult.cs | 78 +++ .../breakingchanges.netcore.json | 46 +- .../PolicyEvaluator.cs | 4 +- .../CookieTests.cs | 45 +- .../FacebookTests.cs | 35 +- .../GoogleTests.cs | 26 +- .../JwtBearerTests.cs | 83 ++- .../MicrosoftAccountTests.cs | 14 +- .../OAuthTests.cs | 23 - .../OpenIdConnectChallengeTests.cs | 4 +- .../OpenIdConnectConfigurationTests.cs | 23 +- .../OpenIdConnect/OpenIdConnectEventTests.cs | 484 ++++++++++++++++-- .../OpenIdConnect/OpenIdConnectTests.cs | 4 - .../OpenIdConnect/TestServerBuilder.cs | 6 +- .../TokenExtensionTests.cs | 6 +- .../TwitterTests.cs | 13 +- .../CookiePolicyTests.cs | 4 +- .../CookieInteropTests.cs | 8 +- 95 files changed, 1746 insertions(+), 1493 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs rename src/Microsoft.AspNetCore.Authentication.Cookies/{CookieAuthenticationPostConfigureOptions.cs => PostConfigureCookieAuthenticationOptions.cs} (99%) delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs rename src/{Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs => Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs} (62%) create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs rename src/Microsoft.AspNetCore.Authentication/Events/{FailureContext.cs => RemoteFailureContext.cs} (64%) create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 79d1b3c3fe..a91791070a 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -18,9 +18,7 @@ namespace CookieSample { options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - - services.AddCookieAuthentication(); + }).AddCookie(); } public void Configure(IApplicationBuilder app) diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index c35dfd9998..f7b8f2bb88 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -19,9 +19,7 @@ namespace CookieSessionSample { options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - - services.AddCookieAuthentication(o => o.SessionStore = new MemoryCacheTicketStore()); + }).AddCookie(o => o.SessionStore = new MemoryCacheTicketStore()); } public void Configure(IApplicationBuilder app) diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 030e640c99..6f2c5e2ecd 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -48,9 +48,7 @@ namespace JwtBearerSample { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - }); - - services.AddJwtBearerAuthentication(o => + }).AddJwtBearer(o => { // You also need to update /wwwroot/app/scripts/app.js o.Authority = Configuration["jwt:authority"]; @@ -59,7 +57,7 @@ namespace JwtBearerSample { OnAuthenticationFailed = c => { - c.HandleResponse(); + c.NoResult(); c.Response.StatusCode = 500; c.Response.ContentType = "text/plain"; diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index e6ad7804d3..aab6e60df8 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -48,11 +48,9 @@ namespace OpenIdConnect.AzureAdSample sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; - }); - - services.AddCookieAuthentication(); - - services.AddOpenIdConnectAuthentication(o => + }) + .AddCookie() + .AddOpenIdConnect(o => { o.ClientId = ClientId; o.ClientSecret = ClientSecret; // for code flow diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index af1406289d..bc5af750d3 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -45,11 +45,9 @@ namespace OpenIdConnectSample sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; - }); - - services.AddCookieAuthentication(); - - services.AddOpenIdConnectAuthentication(o => + }) + .AddCookie() + .AddOpenIdConnect(o => { o.ClientId = Configuration["oidc:clientid"]; o.ClientSecret = Configuration["oidc:clientsecret"]; // for code flow diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 0039720096..dcf76263d5 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -55,13 +55,11 @@ namespace SocialSample options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - - services.AddCookieAuthentication(o => o.LoginPath = new PathString("/login")); - - // You must first create an app with Facebook and add its ID and Secret to your user-secrets. - // https://developers.facebook.com/apps/ - services.AddFacebookAuthentication(o => + }) + .AddCookie(o => o.LoginPath = new PathString("/login")) + // You must first create an app with Facebook and add its ID and Secret to your user-secrets. + // https://developers.facebook.com/apps/ + .AddFacebook(o => { o.AppId = Configuration["facebook:appid"]; o.AppSecret = Configuration["facebook:appsecret"]; @@ -69,11 +67,10 @@ namespace SocialSample o.Fields.Add("name"); o.Fields.Add("email"); o.SaveTokens = true; - }); - - // You must first create an app with Google and add its ID and Secret to your user-secrets. - // https://console.developers.google.com/project - services.AddOAuthAuthentication("Google-AccessToken", o => + }) + // You must first create an app with Google and add its ID and Secret to your user-secrets. + // https://console.developers.google.com/project + .AddOAuth("Google-AccessToken", o => { o.ClientId = Configuration["google:clientid"]; o.ClientSecret = Configuration["google:clientsecret"]; @@ -84,11 +81,10 @@ namespace SocialSample o.Scope.Add("profile"); o.Scope.Add("email"); o.SaveTokens = true; - }); - - // You must first create an app with Google and add its ID and Secret to your user-secrets. - // https://console.developers.google.com/project - services.AddGoogleAuthentication(o => + }) + // You must first create an app with Google and add its ID and Secret to your user-secrets. + // https://console.developers.google.com/project + .AddGoogle(o => { o.ClientId = Configuration["google:clientid"]; o.ClientSecret = Configuration["google:clientsecret"]; @@ -104,11 +100,10 @@ namespace SocialSample }; o.ClaimActions.MapJsonSubKey("urn:google:image", "image", "url"); o.ClaimActions.Remove(ClaimTypes.GivenName); - }); - - // You must first create an app with Twitter and add its key and Secret to your user-secrets. - // https://apps.twitter.com/ - services.AddTwitterAuthentication(o => + }) + // You must first create an app with Twitter and add its key and Secret to your user-secrets. + // https://apps.twitter.com/ + .AddTwitter(o => { o.ConsumerKey = Configuration["twitter:consumerkey"]; o.ConsumerSecret = Configuration["twitter:consumersecret"]; @@ -126,15 +121,14 @@ namespace SocialSample return Task.FromResult(0); } }; - }); - - /* Azure AD app model v2 has restrictions that prevent the use of plain HTTP for redirect URLs. - Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL: - https://localhost:44318/ - */ - // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. - // https://apps.dev.microsoft.com/ - services.AddOAuthAuthentication("Microsoft-AccessToken", o => + }) + /* Azure AD app model v2 has restrictions that prevent the use of plain HTTP for redirect URLs. + Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL: + https://localhost:44318/ + */ + // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. + // https://apps.dev.microsoft.com/ + .AddOAuth("Microsoft-AccessToken", o => { o.ClientId = Configuration["microsoftaccount:clientid"]; o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; @@ -143,20 +137,18 @@ namespace SocialSample o.TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; o.Scope.Add("https://graph.microsoft.com/user.read"); o.SaveTokens = true; - }); - - // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. - // https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/ - services.AddMicrosoftAccountAuthentication(o => + }) + // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. + // https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/ + .AddMicrosoftAccount(o => { o.ClientId = Configuration["microsoftaccount:clientid"]; o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; o.SaveTokens = true; - }); - - // You must first create an app with GitHub and add its ID and Secret to your user-secrets. - // https://github.com/settings/applications/ - services.AddOAuthAuthentication("GitHub-AccessToken", o => + }) + // You must first create an app with GitHub and add its ID and Secret to your user-secrets. + // https://github.com/settings/applications/ + .AddOAuth("GitHub-AccessToken", o => { o.ClientId = Configuration["github-token:clientid"]; o.ClientSecret = Configuration["github-token:clientsecret"]; @@ -164,11 +156,10 @@ namespace SocialSample o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; o.TokenEndpoint = "https://github.com/login/oauth/access_token"; o.SaveTokens = true; - }); - - // You must first create an app with GitHub and add its ID and Secret to your user-secrets. - // https://github.com/settings/applications/ - services.AddOAuthAuthentication("GitHub", o => + }) + // You must first create an app with GitHub and add its ID and Secret to your user-secrets. + // https://github.com/settings/applications/ + .AddOAuth("GitHub", o => { o.ClientId = Configuration["github:clientid"]; o.ClientSecret = Configuration["github:clientsecret"]; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 9b04026cd1..4751c6f857 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -14,7 +14,10 @@ using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Authentication.Cookies { - public class CookieAuthenticationHandler : AuthenticationHandler + public class CookieAuthenticationHandler : + AuthenticationHandler, + IAuthenticationSignInHandler, + IAuthenticationSignOutHandler { private const string HeaderValueNoCache = "no-cache"; private const string HeaderValueMinusOne = "-1"; @@ -104,7 +107,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var cookie = Options.CookieManager.GetRequestCookie(Context, Options.CookieName); if (string.IsNullOrEmpty(cookie)) { - return AuthenticateResult.None(); + return AuthenticateResult.NoResult(); } var ticket = Options.TicketDataFormat.Unprotect(cookie, GetTlsTokenBinding()); @@ -155,7 +158,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies return result; } - var context = new CookieValidatePrincipalContext(Context, Scheme, result.Ticket, Options); + var context = new CookieValidatePrincipalContext(Context, Scheme, Options, result.Ticket); await Events.ValidatePrincipal(context); if (context.Principal == null) @@ -244,8 +247,15 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } } - protected override async Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + + properties = properties ?? new AuthenticationProperties(); + _signInCalled = true; // Process the request cookie to initialize members like _sessionKey. @@ -284,7 +294,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies signInContext.CookieOptions.Expires = expiresUtc.ToUniversalTime(); } - var ticket = new AuthenticationTicket(signInContext.Principal, signInContext.Properties, signInContext.AuthenticationScheme); + var ticket = new AuthenticationTicket(signInContext.Principal, signInContext.Properties, signInContext.Scheme.Name); + if (Options.SessionStore != null) { if (_sessionKey != null) @@ -310,20 +321,23 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var signedInContext = new CookieSignedInContext( Context, Scheme, - Options, - Scheme.Name, signInContext.Principal, - signInContext.Properties); + signInContext.Properties, + Options); await Events.SignedIn(signedInContext); // Only redirect on the login path var shouldRedirect = Options.LoginPath.HasValue && OriginalPath == Options.LoginPath; await ApplyHeaders(shouldRedirect, signedInContext.Properties); + + Logger.SignedIn(Scheme.Name); } - protected override async Task HandleSignOutAsync(AuthenticationProperties properties) + public async virtual Task SignOutAsync(AuthenticationProperties properties) { + properties = properties ?? new AuthenticationProperties(); + _signOutCalled = true; // Process the request cookie to initialize members like _sessionKey. @@ -351,6 +365,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies // Only redirect on the logout path var shouldRedirect = Options.LogoutPath.HasValue && OriginalPath == Options.LogoutPath; await ApplyHeaders(shouldRedirect, context.Properties); + + Logger.SignedOut(Scheme.Name); } private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationProperties properties) @@ -380,7 +396,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (redirectUri != null) { await Events.RedirectToReturnUrl( - new CookieRedirectContext(Context, Scheme, Options, redirectUri, properties)); + new RedirectContext(Context, Scheme, Options, properties, redirectUri)); } } } @@ -406,7 +422,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies returnUrl = OriginalPathBase + Request.Path + Request.QueryString; } var accessDeniedUri = Options.AccessDeniedPath + QueryString.Create(Options.ReturnUrlParameter, returnUrl); - var redirectContext = new CookieRedirectContext(Context, Scheme, Options, BuildRedirectUri(accessDeniedUri), properties); + var redirectContext = new RedirectContext(Context, Scheme, Options, properties, BuildRedirectUri(accessDeniedUri)); await Events.RedirectToAccessDenied(redirectContext); } @@ -419,7 +435,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } var loginUri = Options.LoginPath + QueryString.Create(Options.ReturnUrlParameter, redirectUri); - var redirectContext = new CookieRedirectContext(Context, Scheme, Options, BuildRedirectUri(loginUri), properties); + var redirectContext = new RedirectContext(Context, Scheme, Options, properties, BuildRedirectUri(loginUri)); await Events.RedirectToLogin(redirectContext); } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index 6f23abcc4a..67c4416ebb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -2,16 +2,32 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection { public static class CookieExtensions { + public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder) + => builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme); + + public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme) + => builder.AddCookie(authenticationScheme, configureOptions: null); + + public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); + return builder.AddScheme(authenticationScheme, configureOptions); + } + + + // REMOVE below once callers have been updated public static IServiceCollection AddCookieAuthentication(this IServiceCollection services) => services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme); public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme) => services.AddCookieAuthentication(authenticationScheme, configureOptions: null); diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs deleted file mode 100644 index 4c949bb089..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.Cookies -{ - public class BaseCookieContext : BaseAuthenticationContext - { - public BaseCookieContext( - HttpContext context, - AuthenticationScheme scheme, - CookieAuthenticationOptions options, - AuthenticationProperties properties) - : base(context, scheme.Name, properties) - { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - Options = options; - } - - public CookieAuthenticationOptions Options { get; } - - public AuthenticationScheme Scheme { get; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs index c7c375de23..2b8b0416b3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnRedirectToLogin { get; set; } = context => + public Func, Task> OnRedirectToLogin { get; set; } = context => { if (IsAjaxRequest(context.Request)) { @@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnRedirectToAccessDenied { get; set; } = context => + public Func, Task> OnRedirectToAccessDenied { get; set; } = context => { if (IsAjaxRequest(context.Request)) { @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnRedirectToLogout { get; set; } = context => + public Func, Task> OnRedirectToLogout { get; set; } = context => { if (IsAjaxRequest(context.Request)) { @@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnRedirectToReturnUrl { get; set; } = context => + public Func, Task> OnRedirectToReturnUrl { get; set; } = context => { if (IsAjaxRequest(context.Request)) { @@ -135,24 +135,24 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToLogout(CookieRedirectContext context) => OnRedirectToLogout(context); + public virtual Task RedirectToLogout(RedirectContext context) => OnRedirectToLogout(context); /// /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToLogin(CookieRedirectContext context) => OnRedirectToLogin(context); + public virtual Task RedirectToLogin(RedirectContext context) => OnRedirectToLogin(context); /// /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToReturnUrl(CookieRedirectContext context) => OnRedirectToReturnUrl(context); + public virtual Task RedirectToReturnUrl(RedirectContext context) => OnRedirectToReturnUrl(context); /// /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToAccessDenied(CookieRedirectContext context) => OnRedirectToAccessDenied(context); + public virtual Task RedirectToAccessDenied(RedirectContext context) => OnRedirectToAccessDenied(context); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs index 0e610c8b2d..98c31dd190 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs @@ -9,32 +9,25 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Context object passed to the ICookieAuthenticationEvents method SignedIn. /// - public class CookieSignedInContext : BaseCookieContext + public class CookieSignedInContext : PrincipalContext { /// /// Creates a new instance of the context object. /// /// The HTTP request context /// The scheme data - /// The handler options - /// Initializes AuthenticationScheme property /// Initializes Principal property /// Initializes Properties property + /// The handler options public CookieSignedInContext( HttpContext context, AuthenticationScheme scheme, - CookieAuthenticationOptions options, - string authenticationScheme, ClaimsPrincipal principal, - AuthenticationProperties properties) + AuthenticationProperties properties, + CookieAuthenticationOptions options) : base(context, scheme, options, properties) { Principal = principal; } - - /// - /// Contains the claims that were converted into the outgoing cookie. - /// - public ClaimsPrincipal Principal { get; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs index b91cb7e184..41d7b4f6ae 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs @@ -7,9 +7,9 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.Cookies { /// - /// Context object passed to the ICookieAuthenticationEvents method SigningIn. + /// Context object passed to the . /// - public class CookieSigningInContext : BaseCookieContext + public class CookieSigningInContext : PrincipalContext { /// /// Creates a new instance of the context object. @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// The scheme data /// The handler options /// Initializes Principal property - /// Initializes Extra property + /// The authentication properties. /// Initializes options for the authentication cookie. public CookieSigningInContext( HttpContext context, @@ -29,16 +29,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies CookieOptions cookieOptions) : base(context, scheme, options, properties) { - Principal = principal; CookieOptions = cookieOptions; + Principal = principal; } - /// - /// Contains the claims about to be converted into the outgoing cookie. - /// May be replaced or altered during the SigningIn call. - /// - public ClaimsPrincipal Principal { get; set; } - /// /// The options for creating the outgoing cookie. /// May be replace or altered during the SigningIn call. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs index 0f4f4c7dcf..34f6e49ab6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs @@ -6,9 +6,9 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.Cookies { /// - /// Context object passed to the ICookieAuthenticationEvents method SigningOut + /// Context object passed to the /// - public class CookieSigningOutContext : BaseCookieContext + public class CookieSigningOutContext : PropertiesContext { /// /// @@ -25,9 +25,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies AuthenticationProperties properties, CookieOptions cookieOptions) : base(context, scheme, options, properties) - { - CookieOptions = cookieOptions; - } + => CookieOptions = cookieOptions; /// /// The options for creating the outgoing cookie. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs index 3232ba52ff..d2161e42a1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Context object passed to the CookieAuthenticationEvents ValidatePrincipal method. /// - public class CookieValidatePrincipalContext : BaseCookieContext + public class CookieValidatePrincipalContext : PrincipalContext { /// /// Creates a new instance of the context object. @@ -19,33 +19,17 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Contains the initial values for identity and extra data /// - public CookieValidatePrincipalContext(HttpContext context, AuthenticationScheme scheme, AuthenticationTicket ticket, CookieAuthenticationOptions options) + public CookieValidatePrincipalContext(HttpContext context, AuthenticationScheme scheme, CookieAuthenticationOptions options, AuthenticationTicket ticket) : base(context, scheme, options, ticket?.Properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - if (ticket == null) { throw new ArgumentNullException(nameof(ticket)); } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - Principal = ticket.Principal; } - /// - /// Contains the claims principal arriving with the request. May be altered to change the - /// details of the authenticated user. - /// - public ClaimsPrincipal Principal { get; private set; } - /// /// If true, the cookie will be renewed /// @@ -56,18 +40,12 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// Principal property, which determines the identity of the authenticated request. /// /// The used as the replacement - public void ReplacePrincipal(ClaimsPrincipal principal) - { - Principal = principal; - } + public void ReplacePrincipal(ClaimsPrincipal principal) => Principal = principal; /// /// Called to reject the incoming principal. This may be done if the application has determined the /// account is no longer active, and the request should be treated as if it was anonymous. /// - public void RejectPrincipal() - { - Principal = null; - } + public void RejectPrincipal() => Principal = null; } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs new file mode 100644 index 0000000000..d12735443f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs @@ -0,0 +1,35 @@ +// 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.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _authSchemeSignedIn; + private static Action _authSchemeSignedOut; + + static LoggingExtensions() + { + _authSchemeSignedIn = LoggerMessage.Define( + eventId: 10, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} signed in."); + _authSchemeSignedOut = LoggerMessage.Define( + eventId: 11, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); + } + + public static void SignedIn(this ILogger logger, string authenticationScheme) + { + _authSchemeSignedIn(logger, authenticationScheme, null); + } + + public static void SignedOut(this ILogger logger, string authenticationScheme) + { + _authSchemeSignedOut(logger, authenticationScheme, null); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs similarity index 99% rename from src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs index 38211e0f19..e6a62d1b68 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs @@ -55,6 +55,5 @@ namespace Microsoft.AspNetCore.Authentication.Cookies options.AccessDeniedPath = CookieAuthenticationDefaults.AccessDeniedPath; } } - } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json index c223c035c4..91781d2dd2 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json @@ -19,69 +19,29 @@ "TypeId": "public interface Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Kind": "Removal" }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Authentication.AuthenticationTicket ticket, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, Microsoft.AspNetCore.Http.CookieOptions cookieOptions)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String authenticationScheme, System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String authenticationScheme, System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, Microsoft.AspNetCore.Http.CookieOptions cookieOptions)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String redirectUri, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, { "TypeId": "public static class Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseCookieAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 4f30b9ba9c..e4dcbfee8b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -2,12 +2,24 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Facebook; namespace Microsoft.Extensions.DependencyInjection { public static class FacebookAuthenticationOptionsExtensions { + public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder) + => builder.AddFacebook(FacebookDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddFacebook(FacebookDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddOAuth(authenticationScheme, configureOptions); + + + // REMOVE below once callers have been updated public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services) => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index c94048f9b9..8a1f29bbe5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -42,13 +42,13 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Scheme.Name); - var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens, payload); + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens, payload); context.RunClaimActions(); await Events.CreatingTicket(context); - return context.Ticket; + return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + } private string GenerateAppSecretProof(string accessToken) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index be40822c57..ee42c5564c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -2,12 +2,25 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Google; namespace Microsoft.Extensions.DependencyInjection { public static class GoogleExtensions { + public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder) + => builder.AddGoogle(GoogleDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddGoogle(GoogleDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddOAuth(authenticationScheme, configureOptions); + + + // REMOVE below once callers have been updated + public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services) => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 3a93c5cbf7..aa5e596494 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -39,14 +39,11 @@ namespace Microsoft.AspNetCore.Authentication.Google var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var principal = new ClaimsPrincipal(identity); - var ticket = new AuthenticationTicket(principal, properties, Scheme.Name); - var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens, payload); + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens, payload); context.RunClaimActions(); await Events.CreatingTicket(context); - - return context.Ticket; + return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } // TODO: Abstract this properties override pattern into the base class? diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs index b47a9bab0f..1c2efd6c73 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs @@ -6,12 +6,13 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class AuthenticationFailedContext : BaseJwtBearerContext + public class AuthenticationFailedContext : ResultContext { - public AuthenticationFailedContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) - : base(context, scheme, options) - { - } + public AuthenticationFailedContext( + HttpContext context, + AuthenticationScheme scheme, + JwtBearerOptions options) + : base(context, scheme, options) { } public Exception Exception { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs deleted file mode 100644 index 313e999d0d..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.JwtBearer -{ - public class BaseJwtBearerContext : BaseControlContext - { - public BaseJwtBearerContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) - : base(context) - { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - if (scheme == null) - { - throw new ArgumentNullException(nameof(scheme)); - } - - Options = options; - Scheme = scheme; - } - - public JwtBearerOptions Options { get; } - - public AuthenticationScheme Scheme { get; } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs index e6f931f6db..6500e1e3f7 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs @@ -6,15 +6,14 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class JwtBearerChallengeContext : BaseJwtBearerContext + public class JwtBearerChallengeContext : PropertiesContext { - public JwtBearerChallengeContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options, AuthenticationProperties properties) - : base(context, scheme, options) - { - Properties = properties; - } - - public AuthenticationProperties Properties { get; } + public JwtBearerChallengeContext( + HttpContext context, + AuthenticationScheme scheme, + JwtBearerOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } /// /// Any failures encountered during the authentication process. @@ -40,5 +39,15 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// WWW-Authenticate header. This property is always null unless explicitly set. /// public string ErrorUri { get; set; } + + /// + /// If true, will skip any default logic for this challenge. + /// + public bool Handled { get; private set; } + + /// + /// Skips any default logic for this challenge. + /// + public void HandleResponse() => Handled = true; } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs index 530a945cab..3c263f6b24 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs @@ -5,12 +5,13 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class MessageReceivedContext : BaseJwtBearerContext + public class MessageReceivedContext : ResultContext { - public MessageReceivedContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) - : base(context, scheme, options) - { - } + public MessageReceivedContext( + HttpContext context, + AuthenticationScheme scheme, + JwtBearerOptions options) + : base(context, scheme, options) { } /// /// Bearer Token. This will give application an opportunity to retrieve token from an alternation location. diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs index 3667865da1..39b677b96d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs @@ -6,12 +6,13 @@ using Microsoft.IdentityModel.Tokens; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class TokenValidatedContext : BaseJwtBearerContext + public class TokenValidatedContext : ResultContext { - public TokenValidatedContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) - : base(context, scheme, options) - { - } + public TokenValidatedContext( + HttpContext context, + AuthenticationScheme scheme, + JwtBearerOptions options) + : base(context, scheme, options) { } public SecurityToken SecurityToken { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 582eb6314d..4f051bd39a 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -10,6 +11,20 @@ namespace Microsoft.Extensions.DependencyInjection { public static class JwtBearerExtensions { + public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder) + => builder.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); + return builder.AddScheme(authenticationScheme, configureOptions); + } + + + // REMOVE once callers updated public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services) => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 0087d38d0f..999d323e11 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Net.Http; using System.Security.Claims; using System.Text; using System.Text.Encodings.Web; @@ -13,7 +12,6 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; @@ -47,7 +45,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer protected override async Task HandleAuthenticateAsync() { string token = null; - AuthenticateResult result = null; try { // Give application opportunity to find from a different location, adjust, or reject token @@ -55,9 +52,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer // event can set the token await Events.MessageReceived(messageReceivedContext); - if (messageReceivedContext.IsProcessingComplete(out result)) + if (messageReceivedContext.Result != null) { - return result; + return messageReceivedContext.Result; } // If application retrieved token from somewhere else, use that. @@ -70,7 +67,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer // If no authorization header found, nothing to process further if (string.IsNullOrEmpty(authorization)) { - return AuthenticateResult.None(); + return AuthenticateResult.NoResult(); } if (authorization.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase)) @@ -81,7 +78,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer // If no token found, no further work possible if (string.IsNullOrEmpty(token)) { - return AuthenticateResult.None(); + return AuthenticateResult.NoResult(); } } @@ -138,29 +135,28 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Logger.TokenValidationSucceeded(); - var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name); var tokenValidatedContext = new TokenValidatedContext(Context, Scheme, Options) { - Ticket = ticket, - SecurityToken = validatedToken, + Principal = principal, + SecurityToken = validatedToken }; await Events.TokenValidated(tokenValidatedContext); - if (tokenValidatedContext.IsProcessingComplete(out result)) + if (tokenValidatedContext.Result != null) { - return result; + return tokenValidatedContext.Result; } - ticket = tokenValidatedContext.Ticket; if (Options.SaveToken) { - ticket.Properties.StoreTokens(new[] + tokenValidatedContext.Properties.StoreTokens(new[] { new AuthenticationToken { Name = "access_token", Value = token } }); } - return AuthenticateResult.Success(ticket); + tokenValidatedContext.Success(); + return tokenValidatedContext.Result; } } @@ -172,9 +168,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer }; await Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.IsProcessingComplete(out result)) + if (authenticationFailedContext.Result != null) { - return result; + return authenticationFailedContext.Result; } return AuthenticateResult.Fail(authenticationFailedContext.Exception); @@ -192,9 +188,9 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer }; await Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.IsProcessingComplete(out result)) + if (authenticationFailedContext.Result != null) { - return result; + return authenticationFailedContext.Result; } throw; @@ -217,7 +213,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } await Events.Challenge(eventContext); - if (eventContext.IsProcessingComplete(out var ignored)) + if (eventContext.Handled) { return; } @@ -329,15 +325,5 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer return string.Join("; ", messages); } - - protected override Task HandleSignOutAsync(AuthenticationProperties properties) - { - throw new NotSupportedException(); - } - - protected override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) - { - throw new NotSupportedException(); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json index d810a2bb90..223ff401b4 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json @@ -15,44 +15,29 @@ "TypeId": "public interface Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", "Kind": "Removal" }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJwtBearerAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", "Kind": "Removal" }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public Microsoft.AspNetCore.Builder.JwtBearerOptions get_Options()", + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", "Kind": "Removal" }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", "Kind": "Removal" }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJwtBearerAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index a4ad5692cd..9a53fd7700 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -2,12 +2,25 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; namespace Microsoft.Extensions.DependencyInjection { public static class MicrosoftAccountExtensions { + public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder) + => builder.AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddOAuth(authenticationScheme, configureOptions); + + + // REMOVE below once callers have been updated + public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services) => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 815b94bf40..45fae3d0ea 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -32,12 +32,11 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Scheme.Name); - var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens, payload); + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens, payload); context.RunClaimActions(); await Events.CreatingTicket(context); - return context.Ticket; + return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs index 6e31056392..f660dd2247 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -13,32 +13,34 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// Contains information about the login session as well as the user . /// - public class OAuthCreatingTicketContext : BaseAuthenticationContext + public class OAuthCreatingTicketContext : ResultContext { /// /// Initializes a new . /// - /// The . + /// The . + /// The . /// The HTTP environment. /// The authentication scheme. /// The options used by the authentication middleware. /// The HTTP client used by the authentication middleware /// The tokens returned from the token endpoint. public OAuthCreatingTicketContext( - AuthenticationTicket ticket, + ClaimsPrincipal principal, + AuthenticationProperties properties, HttpContext context, AuthenticationScheme scheme, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens) - : this(ticket, context, scheme, options, backchannel, tokens, user: new JObject()) - { - } + : this(principal, properties, context, scheme, options, backchannel, tokens, user: new JObject()) + { } /// /// Initializes a new . /// - /// The . + /// The . + /// The . /// The HTTP environment. /// The authentication scheme. /// The options used by the authentication middleware. @@ -46,25 +48,16 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// The tokens returned from the token endpoint. /// The JSON-serialized user. public OAuthCreatingTicketContext( - AuthenticationTicket ticket, + ClaimsPrincipal principal, + AuthenticationProperties properties, HttpContext context, AuthenticationScheme scheme, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens, JObject user) - : base(context, scheme.Name, ticket.Properties) + : base(context, scheme, options) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - if (backchannel == null) { throw new ArgumentNullException(nameof(backchannel)); @@ -80,23 +73,13 @@ namespace Microsoft.AspNetCore.Authentication.OAuth throw new ArgumentNullException(nameof(user)); } - if (scheme == null) - { - throw new ArgumentNullException(nameof(scheme)); - } - TokenResponse = tokens; Backchannel = backchannel; User = user; - Options = options; - Scheme = scheme; - Ticket = ticket; + Principal = principal; + Properties = properties; } - public OAuthOptions Options { get; } - - public AuthenticationScheme Scheme { get; } - /// /// Gets the JSON-serialized user or an empty /// if it is not available. @@ -146,20 +129,12 @@ namespace Microsoft.AspNetCore.Authentication.OAuth public HttpClient Backchannel { get; } /// - /// The that will be created. + /// Gets the main identity exposed by the authentication ticket. + /// This property returns null when the ticket is null. /// - public AuthenticationTicket Ticket { get; set; } + public ClaimsIdentity Identity => Principal?.Identity as ClaimsIdentity; - /// - /// Gets the main identity exposed by . - /// This property returns null when is null. - /// - public ClaimsIdentity Identity => Ticket?.Principal.Identity as ClaimsIdentity; - - public void RunClaimActions() - { - RunClaimActions(User); - } + public void RunClaimActions() => RunClaimActions(User); public void RunClaimActions(JObject userData) { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs index b3572cab4c..9e194491b9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// Gets or sets the delegate that is invoked when the RedirectToAuthorizationEndpoint method is invoked. /// - public Func OnRedirectToAuthorizationEndpoint { get; set; } = context => + public Func, Task> OnRedirectToAuthorizationEndpoint { get; set; } = context => { context.Response.Redirect(context.RedirectUri); return Task.CompletedTask; @@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// Called when a Challenge causes a redirect to authorize endpoint in the OAuth handler. /// - /// Contains redirect URI and of the challenge. - public virtual Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context) => OnRedirectToAuthorizationEndpoint(context); + /// Contains redirect URI and of the challenge. + public virtual Task RedirectToAuthorizationEndpoint(RedirectContext context) => OnRedirectToAuthorizationEndpoint(context); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs deleted file mode 100644 index 5d5e0e701a..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs +++ /dev/null @@ -1,41 +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.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.OAuth -{ - /// - /// Context passed when a Challenge causes a redirect to authorize endpoint in the handler. - /// - public class OAuthRedirectToAuthorizationContext : BaseContext - { - /// - /// Creates a new context object. - /// - /// The HTTP request context. - /// The . - /// The authentication properties of the challenge. - /// The initial redirect URI. - public OAuthRedirectToAuthorizationContext(HttpContext context, OAuthOptions options, AuthenticationProperties properties, string redirectUri) - : base(context) - { - RedirectUri = redirectUri; - Properties = properties; - Options = options; - } - - public OAuthOptions Options { get; } - - /// - /// Gets the URI used for the redirect operation. - /// - public string RedirectUri { get; private set; } - - /// - /// Gets the authentication properties of the challenge. - /// - public AuthenticationProperties Properties { get; private set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 4ad0a83362..5720d8e4f4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -10,6 +11,18 @@ namespace Microsoft.Extensions.DependencyInjection { public static class OAuthExtensions { + public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddOAuth>(authenticationScheme, configureOptions); + + public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + where TOptions : OAuthOptions, new() + where THandler : OAuthHandler + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); + return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + } + + // REMOVE below once callers have been updated public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { return services.AddOAuthAuthentication>(authenticationScheme, configureOptions); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index bbe4f4038b..b61d575375 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// A new instance of the events instance. protected override Task CreateEventsAsync() => Task.FromResult(new OAuthEvents()); - protected override async Task HandleRemoteAuthenticateAsync() + protected override async Task HandleRemoteAuthenticateAsync() { AuthenticationProperties properties = null; var query = Request.Query; @@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth failureMessage.Append(";Uri=").Append(errorUri); } - return AuthenticateResult.Fail(failureMessage.ToString()); + return HandleRequestResult.Fail(failureMessage.ToString()); } var code = query["code"]; @@ -72,30 +72,30 @@ namespace Microsoft.AspNetCore.Authentication.OAuth properties = Options.StateDataFormat.Unprotect(state); if (properties == null) { - return AuthenticateResult.Fail("The oauth state was missing or invalid."); + return HandleRequestResult.Fail("The oauth state was missing or invalid."); } // OAuth2 10.12 CSRF if (!ValidateCorrelationId(properties)) { - return AuthenticateResult.Fail("Correlation failed."); + return HandleRequestResult.Fail("Correlation failed."); } if (StringValues.IsNullOrEmpty(code)) { - return AuthenticateResult.Fail("Code was not found."); + return HandleRequestResult.Fail("Code was not found."); } var tokens = await ExchangeCodeAsync(code, BuildRedirectUri(Options.CallbackPath)); if (tokens.Error != null) { - return AuthenticateResult.Fail(tokens.Error); + return HandleRequestResult.Fail(tokens.Error); } if (string.IsNullOrEmpty(tokens.AccessToken)) { - return AuthenticateResult.Fail("Failed to retrieve access token."); + return HandleRequestResult.Fail("Failed to retrieve access token."); } var identity = new ClaimsIdentity(ClaimsIssuer); @@ -137,11 +137,11 @@ namespace Microsoft.AspNetCore.Authentication.OAuth var ticket = await CreateTicketAsync(identity, properties, tokens); if (ticket != null) { - return AuthenticateResult.Success(ticket); + return HandleRequestResult.Success(ticket); } else { - return AuthenticateResult.Fail("Failed to retrieve user information from remote server."); + return HandleRequestResult.Fail("Failed to retrieve user information from remote server."); } } @@ -185,10 +185,9 @@ namespace Microsoft.AspNetCore.Authentication.OAuth protected virtual async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) { - var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Scheme.Name); - var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens); + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens); await Events.CreatingTicket(context); - return context.Ticket; + return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } protected override async Task HandleChallengeAsync(AuthenticationProperties properties) @@ -202,8 +201,8 @@ namespace Microsoft.AspNetCore.Authentication.OAuth GenerateCorrelationId(properties); var authorizationEndpoint = BuildChallengeUrl(properties, BuildRedirectUri(Options.CallbackPath)); - var redirectContext = new OAuthRedirectToAuthorizationContext( - Context, Options, + var redirectContext = new RedirectContext( + Context, Scheme, Options, properties, authorizationEndpoint); await Events.RedirectToAuthorizationEndpoint(redirectContext); } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json index 96fd03e985..3124d7fe70 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json @@ -23,24 +23,13 @@ "TypeId": "public interface Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", "Kind": "Removal" }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OAuthOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, System.String redirectUri)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public Microsoft.AspNetCore.Builder.OAuthOptions get_Options()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, { "TypeId": "public static class Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOAuthAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OAuthOptions options)", "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", + "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs index 0c7d968638..203da93c53 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs @@ -2,17 +2,18 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class AuthenticationFailedContext : BaseOpenIdConnectContext + public class AuthenticationFailedContext : RemoteAuthenticationContext { public AuthenticationFailedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context, scheme, options) - { - } + : base(context, scheme, options, new AuthenticationProperties()) + { } + + public OpenIdConnectMessage ProtocolMessage { get; set; } public Exception Exception { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs index 0ccfc3ab71..bdf6e4a7ff 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs @@ -3,9 +3,7 @@ using System.IdentityModel.Tokens.Jwt; using System.Net.Http; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect @@ -13,17 +11,19 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// This Context can be used to be informed when an 'AuthorizationCode' is received over the OpenIdConnect protocol. /// - public class AuthorizationCodeReceivedContext : BaseOpenIdConnectContext + public class AuthorizationCodeReceivedContext : RemoteAuthenticationContext { /// /// Creates a /// - public AuthorizationCodeReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context, scheme, options) - { - } + public AuthorizationCodeReceivedContext( + HttpContext context, + AuthenticationScheme scheme, + OpenIdConnectOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } - public AuthenticationProperties Properties { get; set; } + public OpenIdConnectMessage ProtocolMessage { get; set; } /// /// Gets or sets the that was received in the authentication response, if any. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs deleted file mode 100644 index 63f815d9ee..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.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 System; -using Microsoft.AspNetCore.Http; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; - -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect -{ - public class BaseOpenIdConnectContext : BaseControlContext - { - public BaseOpenIdConnectContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context) - { - Options = options ?? throw new ArgumentNullException(nameof(options)); - Scheme = scheme ?? throw new ArgumentNullException(nameof(scheme)); - } - - public OpenIdConnectOptions Options { get; } - - public AuthenticationScheme Scheme { get; } - - public OpenIdConnectMessage ProtocolMessage { get; set; } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs index f0298ed055..106ecb8c03 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs @@ -2,21 +2,24 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class MessageReceivedContext : BaseOpenIdConnectContext + public class MessageReceivedContext : RemoteAuthenticationContext { - public MessageReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context, scheme, options) - { - } + public MessageReceivedContext( + HttpContext context, + AuthenticationScheme scheme, + OpenIdConnectOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } + + public OpenIdConnectMessage ProtocolMessage { get; set; } /// /// Bearer Token. This will give application an opportunity to retrieve token from an alternation location. /// public string Token { get; set; } - - public AuthenticationProperties Properties { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs index 59b00827a3..9961c237d4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { @@ -9,14 +10,25 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// When a user configures the to be notified prior to redirecting to an IdentityProvider /// an instance of is passed to the 'RedirectToAuthenticationEndpoint' or 'RedirectToEndSessionEndpoint' events. /// - public class RedirectContext : BaseOpenIdConnectContext + public class RedirectContext : PropertiesContext { - public RedirectContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, AuthenticationProperties properties) - : base(context, scheme, options) - { - Properties = properties; - } + public RedirectContext( + HttpContext context, + AuthenticationScheme scheme, + OpenIdConnectOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } - public AuthenticationProperties Properties { get; } + public OpenIdConnectMessage ProtocolMessage { get; set; } + + /// + /// If true, will skip any default logic for this redirect. + /// + public bool Handled { get; private set; } + + /// + /// Skips any default logic for this redirect. + /// + public void HandleResponse() => Handled = true; } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs index 5c0172673c..26720a58f8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs @@ -6,16 +6,12 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class RemoteSignOutContext : BaseOpenIdConnectContext + public class RemoteSignOutContext : RemoteAuthenticationContext { - public RemoteSignOutContext( - HttpContext context, - AuthenticationScheme scheme, - OpenIdConnectOptions options, - OpenIdConnectMessage message) - : base(context, scheme, options) - { - ProtocolMessage = message; - } + public RemoteSignOutContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, OpenIdConnectMessage message) + : base(context, scheme, options, new AuthenticationProperties()) + => ProtocolMessage = message; + + public OpenIdConnectMessage ProtocolMessage { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs index 7c0d51fbbd..2bebdb8dc5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.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.Security.Claims; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -9,18 +10,16 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// This Context can be used to be informed when an 'AuthorizationCode' is redeemed for tokens at the token endpoint. /// - public class TokenResponseReceivedContext : BaseOpenIdConnectContext + public class TokenResponseReceivedContext : RemoteAuthenticationContext { /// /// Creates a /// - public TokenResponseReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, AuthenticationProperties properties) - : base(context, scheme, options) - { - Properties = properties; - } + public TokenResponseReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, ClaimsPrincipal user, AuthenticationProperties properties) + : base(context, scheme, options, properties) + => Principal = user; - public AuthenticationProperties Properties { get; } + public OpenIdConnectMessage ProtocolMessage { get; set; } /// /// Gets or sets the that contains the tokens received after redeeming the code at the token endpoint. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs index fea89298ce..853857dc7b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs @@ -2,26 +2,23 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.IdentityModel.Tokens.Jwt; -using System.Net.Http; -using Microsoft.AspNetCore.Builder; +using System.Security.Claims; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class TokenValidatedContext : BaseOpenIdConnectContext + public class TokenValidatedContext : RemoteAuthenticationContext { /// /// Creates a /// - public TokenValidatedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context, scheme, options) - { - } + public TokenValidatedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, ClaimsPrincipal principal, AuthenticationProperties properties) + : base(context, scheme, options, properties) + => Principal = principal; + + public OpenIdConnectMessage ProtocolMessage { get; set; } - public AuthenticationProperties Properties { get; set; } - public JwtSecurityToken SecurityToken { get; set; } public OpenIdConnectMessage TokenEndpointResponse { get; set; } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs index ee80cb71fe..0b855eaf39 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs @@ -1,17 +1,20 @@ // 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.Security.Claims; using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class UserInformationReceivedContext : BaseOpenIdConnectContext + public class UserInformationReceivedContext : RemoteAuthenticationContext { - public UserInformationReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context, scheme, options) - { - } + public UserInformationReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, ClaimsPrincipal principal, AuthenticationProperties properties) + : base(context, scheme, options, properties) + => Principal = principal; + + public OpenIdConnectMessage ProtocolMessage { get; set; } public JObject User { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs index aa6d0cbaa7..458cfd73ee 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -8,9 +8,7 @@ namespace Microsoft.Extensions.Logging internal static class LoggingExtensions { private static Action _redirectToIdentityProviderForSignOutHandledResponse; - private static Action _redirectToIdentityProviderForSignOutSkipped; private static Action _redirectToIdentityProviderHandledResponse; - private static Action _redirectToIdentityProviderSkipped; private static Action _updatingConfiguration; private static Action _receivedIdToken; private static Action _redeemingCodeForTokens; @@ -55,6 +53,7 @@ namespace Microsoft.Extensions.Logging private static Action _remoteSignOut; private static Action _remoteSignOutSessionIdMissing; private static Action _remoteSignOutSessionIdInvalid; + private static Action _signOut; static LoggingExtensions() { @@ -63,10 +62,6 @@ namespace Microsoft.Extensions.Logging eventId: 1, logLevel: LogLevel.Debug, formatString: "RedirectToIdentityProviderForSignOut.HandledResponse"); - _redirectToIdentityProviderForSignOutSkipped = LoggerMessage.Define( - eventId: 2, - logLevel: LogLevel.Debug, - formatString: "RedirectToIdentityProviderForSignOut.Skipped"); _invalidLogoutQueryStringRedirectUrl = LoggerMessage.Define( eventId: 3, logLevel: LogLevel.Warning, @@ -87,10 +82,6 @@ namespace Microsoft.Extensions.Logging eventId: 6, logLevel: LogLevel.Debug, formatString: "RedirectToIdentityProvider.HandledResponse"); - _redirectToIdentityProviderSkipped = LoggerMessage.Define( - eventId: 7, - logLevel: LogLevel.Debug, - formatString: "RedirectToIdentityProvider.Skipped"); _invalidAuthenticationRequestUrl = LoggerMessage.Define( eventId: 8, logLevel: LogLevel.Warning, @@ -253,6 +244,10 @@ namespace Microsoft.Extensions.Logging logLevel: LogLevel.Error, formatString: "The remote signout request was ignored because the 'sid' parameter didn't match " + "the expected value, which may indicate an unsolicited logout."); + _signOut = LoggerMessage.Define( + eventId: 49, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); } public static void UpdatingConfiguration(this ILogger logger) @@ -345,21 +340,11 @@ namespace Microsoft.Extensions.Logging _redirectToIdentityProviderForSignOutHandledResponse(logger, null); } - public static void RedirectToIdentityProviderForSignOutSkipped(this ILogger logger) - { - _redirectToIdentityProviderForSignOutSkipped(logger, null); - } - public static void RedirectToIdentityProviderHandledResponse(this ILogger logger) { _redirectToIdentityProviderHandledResponse(logger, null); } - public static void RedirectToIdentityProviderSkipped(this ILogger logger) - { - _redirectToIdentityProviderSkipped(logger, null); - } - public static void UserInformationReceivedHandledResponse(this ILogger logger) { _userInformationReceivedHandledResponse(logger, null); @@ -494,5 +479,10 @@ namespace Microsoft.Extensions.Logging { _remoteSignOutSessionIdInvalid(logger, null); } + + public static void SignedOut(this ILogger logger, string authenticationScheme) + { + _signOut(logger, authenticationScheme, null); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index d576409047..7ba262bf39 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -10,6 +11,19 @@ namespace Microsoft.Extensions.DependencyInjection { public static class OpenIdConnectExtensions { + public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder) + => builder.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); + return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + } + + // REMOVE once callers have been updated public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services) => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 1dec541970..341abbf5a2 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// A per-request authentication handler for the OpenIdConnectAuthenticationMiddleware. /// - public class OpenIdConnectHandler : RemoteAuthenticationHandler + public class OpenIdConnectHandler : RemoteAuthenticationHandler, IAuthenticationSignOutHandler { private const string NonceProperty = "N"; private const string UriSchemeDelimiter = "://"; @@ -110,15 +110,18 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect var remoteSignOutContext = new RemoteSignOutContext(Context, Scheme, Options, message); await Events.RemoteSignOut(remoteSignOutContext); - if (remoteSignOutContext.HandledResponse) + if (remoteSignOutContext.Result != null) { - Logger.RemoteSignOutHandledResponse(); - return true; - } - if (remoteSignOutContext.Skipped) - { - Logger.RemoteSignOutSkipped(); - return false; + if (remoteSignOutContext.Result.Handled) + { + Logger.RemoteSignOutHandledResponse(); + return true; + } + if (remoteSignOutContext.Result.Skipped) + { + Logger.RemoteSignOutSkipped(); + return false; + } } if (message == null) @@ -161,8 +164,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Redirect user to the identity provider for sign out /// /// A task executing the sign out procedure - protected override async Task HandleSignOutAsync(AuthenticationProperties properties) + public async virtual Task SignOutAsync(AuthenticationProperties properties) { + properties = properties ?? new AuthenticationProperties(); + Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); if (_configuration == null && Options.ConfigurationManager != null) @@ -199,16 +204,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect }; await Events.RedirectToIdentityProviderForSignOut(redirectContext); - if (redirectContext.HandledResponse) + if (redirectContext.Handled) { Logger.RedirectToIdentityProviderForSignOutHandledResponse(); return; } - else if (redirectContext.Skipped) - { - Logger.RedirectToIdentityProviderForSignOutSkipped(); - return; - } message = redirectContext.ProtocolMessage; @@ -221,8 +221,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (string.IsNullOrEmpty(message.IssuerAddress)) { - throw new InvalidOperationException( - "Cannot redirect to the end session endpoint, the configuration may be missing or invalid."); + throw new InvalidOperationException("Cannot redirect to the end session endpoint, the configuration may be missing or invalid."); } if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet) @@ -266,6 +265,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { throw new NotImplementedException($"An unsupported authentication method has been configured: {Options.AuthenticationMethod}"); } + + Logger.SignedOut(Scheme.Name); } /// @@ -343,16 +344,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect }; await Events.RedirectToIdentityProvider(redirectContext); - if (redirectContext.HandledResponse) + if (redirectContext.Handled) { Logger.RedirectToIdentityProviderHandledResponse(); return; } - else if (redirectContext.Skipped) - { - Logger.RedirectToIdentityProviderSkipped(); - return; - } message = redirectContext.ProtocolMessage; @@ -418,8 +414,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Invoked to process incoming OpenIdConnect messages. /// - /// An if successful. - protected override async Task HandleRemoteAuthenticateAsync() + /// An . + protected override async Task HandleRemoteAuthenticateAsync() { Logger.EnteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync(GetType().FullName); @@ -437,9 +433,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.None(); + return HandleRequestResult.SkipHandler(); } - return AuthenticateResult.Fail("An OpenID Connect response cannot contain an " + + return HandleRequestResult.Fail("An OpenID Connect response cannot contain an " + "identity token or an access token when using response_mode=query"); } } @@ -459,13 +455,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.None(); + return HandleRequestResult.SkipHandler(); } - return AuthenticateResult.Fail("No message."); + return HandleRequestResult.Fail("No message."); } - AuthenticateResult result; - try { AuthenticationProperties properties = null; @@ -475,9 +469,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } var messageReceivedContext = await RunMessageReceivedEventAsync(authorizationResponse, properties); - if (messageReceivedContext.IsProcessingComplete(out result)) + if (messageReceivedContext.Result != null) { - return result; + return messageReceivedContext.Result; } authorizationResponse = messageReceivedContext.ProtocolMessage; properties = messageReceivedContext.Properties; @@ -491,9 +485,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Logger.NullOrEmptyAuthorizationResponseState(); if (Options.SkipUnrecognizedRequests) { - return AuthenticateResult.None(); + return HandleRequestResult.SkipHandler(); } - return AuthenticateResult.Fail(Resources.MessageStateIsNullOrEmpty); + return HandleRequestResult.Fail(Resources.MessageStateIsNullOrEmpty); } // if state exists and we failed to 'unprotect' this is not a message we should process. @@ -506,9 +500,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.None(); + return HandleRequestResult.SkipHandler(); } - return AuthenticateResult.Fail(Resources.MessageStateIsInvalid); + return HandleRequestResult.Fail(Resources.MessageStateIsInvalid); } string userstate = null; @@ -517,13 +511,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (!ValidateCorrelationId(properties)) { - return AuthenticateResult.Fail("Correlation failed."); + return HandleRequestResult.Fail("Correlation failed."); } // if any of the error fields are set, throw error null if (!string.IsNullOrEmpty(authorizationResponse.Error)) { - return AuthenticateResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null)); + return HandleRequestResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null)); } if (_configuration == null && Options.ConfigurationManager != null) @@ -534,7 +528,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect PopulateSessionProperties(authorizationResponse, properties); - AuthenticationTicket ticket = null; + ClaimsPrincipal user = null; JwtSecurityToken jwt = null; string nonce = null; var validationParameters = Options.TokenValidationParameters.Clone(); @@ -543,7 +537,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (!string.IsNullOrEmpty(authorizationResponse.IdToken)) { Logger.ReceivedIdToken(); - ticket = ValidateToken(authorizationResponse.IdToken, properties, validationParameters, out jwt); + user = ValidateToken(authorizationResponse.IdToken, properties, validationParameters, out jwt); nonce = jwt.Payload.Nonce; if (!string.IsNullOrEmpty(nonce)) @@ -551,14 +545,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect nonce = ReadNonceCookie(nonce); } - var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, null, properties, ticket, jwt, nonce); - if (tokenValidatedContext.IsProcessingComplete(out result)) + var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, null, user, properties, jwt, nonce); + if (tokenValidatedContext.Result != null) { - return result; + return tokenValidatedContext.Result; } authorizationResponse = tokenValidatedContext.ProtocolMessage; + user = tokenValidatedContext.Principal; properties = tokenValidatedContext.Properties; - ticket = tokenValidatedContext.Ticket; jwt = tokenValidatedContext.SecurityToken; nonce = tokenValidatedContext.Nonce; } @@ -576,17 +570,17 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // Authorization Code or Hybrid flow if (!string.IsNullOrEmpty(authorizationResponse.Code)) { - var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(authorizationResponse, properties, ticket, jwt); - if (authorizationCodeReceivedContext.IsProcessingComplete(out result)) + var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(authorizationResponse, user, properties, jwt); + if (authorizationCodeReceivedContext.Result != null) { - return result; + return authorizationCodeReceivedContext.Result; } authorizationResponse = authorizationCodeReceivedContext.ProtocolMessage; + user = authorizationCodeReceivedContext.Principal; properties = authorizationCodeReceivedContext.Properties; var tokenEndpointRequest = authorizationCodeReceivedContext.TokenEndpointRequest; // If the developer redeemed the code themselves... tokenEndpointResponse = authorizationCodeReceivedContext.TokenEndpointResponse; - ticket = authorizationCodeReceivedContext.Ticket; jwt = authorizationCodeReceivedContext.JwtSecurityToken; if (!authorizationCodeReceivedContext.HandledCodeRedemption) @@ -594,14 +588,16 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect tokenEndpointResponse = await RedeemAuthorizationCodeAsync(tokenEndpointRequest); } - var tokenResponseReceivedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties, ticket); - if (tokenResponseReceivedContext.IsProcessingComplete(out result)) + var tokenResponseReceivedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, user, properties); + if (tokenResponseReceivedContext.Result != null) { - return result; + return tokenResponseReceivedContext.Result; } authorizationResponse = tokenResponseReceivedContext.ProtocolMessage; tokenEndpointResponse = tokenResponseReceivedContext.TokenEndpointResponse; + user = tokenResponseReceivedContext.Principal; + properties = tokenResponseReceivedContext.Properties; // no need to validate signature when token is received using "code flow" as per spec // [http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation]. @@ -610,10 +606,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // At least a cursory validation is required on the new IdToken, even if we've already validated the one from the authorization response. // And we'll want to validate the new JWT in ValidateTokenResponse. JwtSecurityToken tokenEndpointJwt; - var tokenEndpointTicket = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out tokenEndpointJwt); + var tokenEndpointUser = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out tokenEndpointJwt); // Avoid reading & deleting the nonce cookie, running the event, etc, if it was already done as part of the authorization response validation. - if (ticket == null) + if (user == null) { nonce = tokenEndpointJwt.Payload.Nonce; if (!string.IsNullOrEmpty(nonce)) @@ -621,15 +617,15 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect nonce = ReadNonceCookie(nonce); } - var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, tokenEndpointResponse, properties, tokenEndpointTicket, tokenEndpointJwt, nonce); - if (tokenValidatedContext.IsProcessingComplete(out result)) + var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, tokenEndpointResponse, tokenEndpointUser, properties, tokenEndpointJwt, nonce); + if (tokenValidatedContext.Result != null) { - return result; + return tokenValidatedContext.Result; } authorizationResponse = tokenValidatedContext.ProtocolMessage; tokenEndpointResponse = tokenValidatedContext.TokenEndpointResponse; + user = tokenValidatedContext.Principal; properties = tokenValidatedContext.Properties; - ticket = tokenValidatedContext.Ticket; jwt = tokenValidatedContext.SecurityToken; nonce = tokenValidatedContext.Nonce; } @@ -658,23 +654,23 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (Options.SaveTokens) { - SaveTokens(ticket.Properties, tokenEndpointResponse ?? authorizationResponse); + SaveTokens(properties, tokenEndpointResponse ?? authorizationResponse); } if (Options.GetClaimsFromUserInfoEndpoint) { - return await GetUserInformationAsync(tokenEndpointResponse ?? authorizationResponse, jwt, ticket); + return await GetUserInformationAsync(tokenEndpointResponse ?? authorizationResponse, jwt, user, properties); } else { - var identity = (ClaimsIdentity)ticket.Principal.Identity; + var identity = (ClaimsIdentity)user.Identity; foreach (var action in Options.ClaimActions) { action.Run(null, identity, ClaimsIssuer); } } - return AuthenticateResult.Success(ticket); + return HandleRequestResult.Success(new AuthenticationTicket(user, properties, Scheme.Name)); } catch (Exception exception) { @@ -691,12 +687,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } var authenticationFailedContext = await RunAuthenticationFailedEventAsync(authorizationResponse, exception); - if (authenticationFailedContext.IsProcessingComplete(out result)) + if (authenticationFailedContext.Result != null) { - return result; + return authenticationFailedContext.Result; } - return AuthenticateResult.Fail(exception); + return HandleRequestResult.Fail(exception); } } @@ -765,21 +761,24 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// message that is being processed /// The . - /// authentication ticket with claims principal and identities - /// Authentication ticket with identity with additional claims, if any. - protected virtual async Task GetUserInformationAsync(OpenIdConnectMessage message, JwtSecurityToken jwt, AuthenticationTicket ticket) + /// The claims principal and identities. + /// The authentication properties. + /// which is used to determine if the remote authentication was successful. + protected virtual async Task GetUserInformationAsync( + OpenIdConnectMessage message, JwtSecurityToken jwt, + ClaimsPrincipal principal, AuthenticationProperties properties) { var userInfoEndpoint = _configuration?.UserInfoEndpoint; if (string.IsNullOrEmpty(userInfoEndpoint)) { Logger.UserInfoEndpointNotSet(); - return AuthenticateResult.Success(ticket); + return HandleRequestResult.Success(new AuthenticationTicket(principal, properties, Scheme.Name)); } if (string.IsNullOrEmpty(message.AccessToken)) { Logger.AccessTokenNotAvailable(); - return AuthenticateResult.Success(ticket); + return HandleRequestResult.Success(new AuthenticationTicket(principal, properties, Scheme.Name)); } Logger.RetrievingClaims(); var requestMessage = new HttpRequestMessage(HttpMethod.Get, userInfoEndpoint); @@ -801,16 +800,16 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } else { - return AuthenticateResult.Fail("Unknown response type: " + contentType.MediaType); + return HandleRequestResult.Fail("Unknown response type: " + contentType.MediaType); } - var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(ticket, message, user); - AuthenticateResult result; - if (userInformationReceivedContext.IsProcessingComplete(out result)) + var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(principal, properties, message, user); + if (userInformationReceivedContext.Result != null) { - return result; + return userInformationReceivedContext.Result; } - ticket = userInformationReceivedContext.Ticket; + principal = userInformationReceivedContext.Principal; + properties = userInformationReceivedContext.Properties; user = userInformationReceivedContext.User; Options.ProtocolValidator.ValidateUserInfoResponse(new OpenIdConnectProtocolValidationContext() @@ -819,14 +818,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect ValidatedIdToken = jwt, }); - var identity = (ClaimsIdentity)ticket.Principal.Identity; + var identity = (ClaimsIdentity)principal.Identity; foreach (var action in Options.ClaimActions) { action.Run(user, identity, ClaimsIssuer); } - return AuthenticateResult.Success(ticket); + return HandleRequestResult.Success(new AuthenticationTicket(principal, properties, Scheme.Name)); } /// @@ -983,51 +982,54 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private async Task RunMessageReceivedEventAsync(OpenIdConnectMessage message, AuthenticationProperties properties) { Logger.MessageReceived(message.BuildRedirectUrl()); - var messageReceivedContext = new MessageReceivedContext(Context, Scheme, Options) + var context = new MessageReceivedContext(Context, Scheme, Options, properties) { ProtocolMessage = message, - Properties = properties, }; - await Events.MessageReceived(messageReceivedContext); - if (messageReceivedContext.HandledResponse) + await Events.MessageReceived(context); + if (context.Result != null) { - Logger.MessageReceivedContextHandledResponse(); - } - else if (messageReceivedContext.Skipped) - { - Logger.MessageReceivedContextSkipped(); + if (context.Result.Handled) + { + Logger.MessageReceivedContextHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.MessageReceivedContextSkipped(); + } } - return messageReceivedContext; + return context; } - private async Task RunTokenValidatedEventAsync(OpenIdConnectMessage authorizationResponse, OpenIdConnectMessage tokenEndpointResponse, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt, string nonce) + private async Task RunTokenValidatedEventAsync(OpenIdConnectMessage authorizationResponse, OpenIdConnectMessage tokenEndpointResponse, ClaimsPrincipal user, AuthenticationProperties properties, JwtSecurityToken jwt, string nonce) { - var tokenValidatedContext = new TokenValidatedContext(Context, Scheme, Options) + var context = new TokenValidatedContext(Context, Scheme, Options, user, properties) { ProtocolMessage = authorizationResponse, TokenEndpointResponse = tokenEndpointResponse, - Properties = properties, - Ticket = ticket, SecurityToken = jwt, Nonce = nonce, }; - await Events.TokenValidated(tokenValidatedContext); - if (tokenValidatedContext.HandledResponse) + await Events.TokenValidated(context); + if (context.Result != null) { - Logger.TokenValidatedHandledResponse(); - } - else if (tokenValidatedContext.Skipped) - { - Logger.TokenValidatedSkipped(); + if (context.Result.Handled) + { + Logger.TokenValidatedHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.TokenValidatedSkipped(); + } } - return tokenValidatedContext; + return context; } - private async Task RunAuthorizationCodeReceivedEventAsync(OpenIdConnectMessage authorizationResponse, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt) + private async Task RunAuthorizationCodeReceivedEventAsync(OpenIdConnectMessage authorizationResponse, ClaimsPrincipal user, AuthenticationProperties properties, JwtSecurityToken jwt) { Logger.AuthorizationCodeReceived(); @@ -1041,102 +1043,112 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect RedirectUri = properties.Items[OpenIdConnectDefaults.RedirectUriForCodePropertiesKey] }; - var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Scheme, Options) + var context = new AuthorizationCodeReceivedContext(Context, Scheme, Options, properties) { ProtocolMessage = authorizationResponse, - Properties = properties, TokenEndpointRequest = tokenEndpointRequest, - Ticket = ticket, + Principal = user, JwtSecurityToken = jwt, - Backchannel = Backchannel, + Backchannel = Backchannel }; - await Events.AuthorizationCodeReceived(authorizationCodeReceivedContext); - if (authorizationCodeReceivedContext.HandledResponse) + await Events.AuthorizationCodeReceived(context); + if (context.Result != null) { - Logger.AuthorizationCodeReceivedContextHandledResponse(); - } - else if (authorizationCodeReceivedContext.Skipped) - { - Logger.AuthorizationCodeReceivedContextSkipped(); + if (context.Result.Handled) + { + Logger.AuthorizationCodeReceivedContextHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.AuthorizationCodeReceivedContextSkipped(); + } } - return authorizationCodeReceivedContext; + return context; } private async Task RunTokenResponseReceivedEventAsync( OpenIdConnectMessage message, OpenIdConnectMessage tokenEndpointResponse, - AuthenticationProperties properties, - AuthenticationTicket ticket) + ClaimsPrincipal user, + AuthenticationProperties properties) { Logger.TokenResponseReceived(); - var eventContext = new TokenResponseReceivedContext(Context, Scheme, Options, properties) + var context = new TokenResponseReceivedContext(Context, Scheme, Options, user, properties) { ProtocolMessage = message, TokenEndpointResponse = tokenEndpointResponse, - Ticket = ticket }; - await Events.TokenResponseReceived(eventContext); - if (eventContext.HandledResponse) + await Events.TokenResponseReceived(context); + if (context.Result != null) { - Logger.TokenResponseReceivedHandledResponse(); - } - else if (eventContext.Skipped) - { - Logger.TokenResponseReceivedSkipped(); + if (context.Result.Handled) + { + Logger.TokenResponseReceivedHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.TokenResponseReceivedSkipped(); + } } - return eventContext; + return context; } - private async Task RunUserInformationReceivedEventAsync(AuthenticationTicket ticket, OpenIdConnectMessage message, JObject user) + private async Task RunUserInformationReceivedEventAsync(ClaimsPrincipal principal, AuthenticationProperties properties, OpenIdConnectMessage message, JObject user) { Logger.UserInformationReceived(user.ToString()); - var userInformationReceivedContext = new UserInformationReceivedContext(Context, Scheme, Options) + var context = new UserInformationReceivedContext(Context, Scheme, Options, principal, properties) { - Ticket = ticket, ProtocolMessage = message, User = user, }; - await Events.UserInformationReceived(userInformationReceivedContext); - if (userInformationReceivedContext.HandledResponse) + await Events.UserInformationReceived(context); + if (context.Result != null) { - Logger.UserInformationReceivedHandledResponse(); - } - else if (userInformationReceivedContext.Skipped) - { - Logger.UserInformationReceivedSkipped(); + if (context.Result.Handled) + { + Logger.UserInformationReceivedHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.UserInformationReceivedSkipped(); + } } - return userInformationReceivedContext; + return context; } private async Task RunAuthenticationFailedEventAsync(OpenIdConnectMessage message, Exception exception) { - var authenticationFailedContext = new AuthenticationFailedContext(Context, Scheme, Options) + var context = new AuthenticationFailedContext(Context, Scheme, Options) { ProtocolMessage = message, Exception = exception }; - await Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.HandledResponse) + await Events.AuthenticationFailed(context); + if (context.Result != null) { - Logger.AuthenticationFailedContextHandledResponse(); - } - else if (authenticationFailedContext.Skipped) - { - Logger.AuthenticationFailedContextSkipped(); + if (context.Result.Handled) + { + Logger.AuthenticationFailedContextHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.AuthenticationFailedContextSkipped(); + } } - return authenticationFailedContext; + return context; } - private AuthenticationTicket ValidateToken(string idToken, AuthenticationProperties properties, TokenValidationParameters validationParameters, out JwtSecurityToken jwt) + // Note this modifies properties if Options.UseTokenLifetime + private ClaimsPrincipal ValidateToken(string idToken, AuthenticationProperties properties, TokenValidationParameters validationParameters, out JwtSecurityToken jwt) { if (!Options.SecurityTokenValidator.CanReadToken(idToken)) { @@ -1173,24 +1185,22 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.UnableToValidateToken, idToken)); } - var ticket = new AuthenticationTicket(principal, properties, Scheme.Name); - if (Options.UseTokenLifetime) { var issued = validatedToken.ValidFrom; if (issued != DateTime.MinValue) { - ticket.Properties.IssuedUtc = issued; + properties.IssuedUtc = issued; } var expires = validatedToken.ValidTo; if (expires != DateTime.MinValue) { - ticket.Properties.ExpiresUtc = expires; + properties.ExpiresUtc = expires; } } - return ticket; + return principal; } /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index a42f0eba33..8bcedaec27 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -4,13 +4,8 @@ using System; using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; -using System.Security.Claims; -using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth.Claims; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json index 4ba3fb756a..0f50b12103 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json @@ -19,99 +19,45 @@ "TypeId": "public interface Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", "Kind": "Removal" }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public Microsoft.AspNetCore.Builder.OpenIdConnectOptions get_Options()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage message)", - "Kind": "Removal" - }, { "TypeId": "public static class Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOpenIdConnectAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", "Kind": "Removal" - } + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs deleted file mode 100644 index b71b8655b7..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs +++ /dev/null @@ -1,30 +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.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.Twitter -{ - /// - /// Base class for other Twitter contexts. - /// - public class BaseTwitterContext : BaseAuthenticationContext - { - /// - /// Initializes a - /// - /// The HTTP environment - /// The scheme data - /// The options for Twitter - /// The AuthenticationProperties - public BaseTwitterContext(HttpContext context, AuthenticationScheme scheme, TwitterOptions options, AuthenticationProperties properties) - : base(context, scheme.Name, properties) - { - Options = options; - } - - public TwitterOptions Options { get; } - - public AuthenticationScheme Scheme { get; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs index eaf704bcb9..67f28d5297 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Contains information about the login session as well as the user . /// - public class TwitterCreatingTicketContext : BaseTwitterContext + public class TwitterCreatingTicketContext : ResultContext { /// /// Initializes a @@ -19,29 +19,33 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// The HTTP environment /// The scheme data /// The options for Twitter + /// The . + /// The . /// Twitter user ID /// Twitter screen name /// Twitter access token /// Twitter access token secret /// User details - /// AuthenticationProperties. public TwitterCreatingTicketContext( HttpContext context, AuthenticationScheme scheme, TwitterOptions options, + ClaimsPrincipal principal, AuthenticationProperties properties, string userId, string screenName, string accessToken, string accessTokenSecret, JObject user) - : base(context, scheme, options, properties) + : base(context, scheme, options) { UserId = userId; ScreenName = screenName; AccessToken = accessToken; AccessTokenSecret = accessTokenSecret; User = user ?? new JObject(); + Principal = principal; + Properties = properties; } /// @@ -69,10 +73,5 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// if it is not available. /// public JObject User { get; } - - /// - /// Gets the representing the user - /// - public ClaimsPrincipal Principal { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs index c079ebb14f..744c48c5fc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Gets or sets the delegate that is invoked when the ApplyRedirect method is invoked. /// - public Func OnRedirectToAuthorizationEndpoint { get; set; } = context => + public Func, Task> OnRedirectToAuthorizationEndpoint { get; set; } = context => { context.Response.Redirect(context.RedirectUri); return Task.CompletedTask; @@ -36,6 +36,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// Called when a Challenge causes a redirect to authorize endpoint in the Twitter handler /// /// Contains redirect URI and of the challenge - public virtual Task RedirectToAuthorizationEndpoint(TwitterRedirectToAuthorizationEndpointContext context) => OnRedirectToAuthorizationEndpoint(context); + public virtual Task RedirectToAuthorizationEndpoint(RedirectContext context) => OnRedirectToAuthorizationEndpoint(context); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs deleted file mode 100644 index fe181fe7b4..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs +++ /dev/null @@ -1,35 +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.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.Twitter -{ - /// - /// The Context passed when a Challenge causes a redirect to authorize endpoint in the Twitter handler. - /// - public class TwitterRedirectToAuthorizationEndpointContext : BaseTwitterContext - { - /// - /// Creates a new context object. - /// - /// The HTTP request context. - /// The scheme data - /// The Twitter handler options. - /// The authentication properties of the challenge. - /// The initial redirect URI. - public TwitterRedirectToAuthorizationEndpointContext(HttpContext context, AuthenticationScheme scheme, - - TwitterOptions options, AuthenticationProperties properties, string redirectUri) - : base(context, scheme, options, properties) - { - RedirectUri = redirectUri; - Properties = properties; - } - - /// - /// Gets the URI used for the redirect operation. - /// - public string RedirectUri { get; private set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index d8b78398fc..e49244920e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -10,6 +11,19 @@ namespace Microsoft.Extensions.DependencyInjection { public static class TwitterExtensions { + public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder) + => builder.AddTwitter(TwitterDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddTwitter(TwitterDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); + return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + } + + // REMOVE below once callers have been updated. public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services) => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index baa4320d1b..7fcc01eee1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter protected override Task CreateEventsAsync() => Task.FromResult(new TwitterEvents()); - protected override async Task HandleRemoteAuthenticateAsync() + protected override async Task HandleRemoteAuthenticateAsync() { AuthenticationProperties properties = null; var query = Request.Query; @@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter if (requestToken == null) { - return AuthenticateResult.Fail("Invalid state cookie."); + return HandleRequestResult.Fail("Invalid state cookie."); } properties = requestToken.Properties; @@ -66,18 +66,18 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var returnedToken = query["oauth_token"]; if (StringValues.IsNullOrEmpty(returnedToken)) { - return AuthenticateResult.Fail("Missing oauth_token"); + return HandleRequestResult.Fail("Missing oauth_token"); } if (!string.Equals(returnedToken, requestToken.Token, StringComparison.Ordinal)) { - return AuthenticateResult.Fail("Unmatched token"); + return HandleRequestResult.Fail("Unmatched token"); } var oauthVerifier = query["oauth_verifier"]; if (StringValues.IsNullOrEmpty(oauthVerifier)) { - return AuthenticateResult.Fail("Missing or blank oauth_verifier"); + return HandleRequestResult.Fail("Missing or blank oauth_verifier"); } var cookieOptions = new CookieOptions @@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter }); } - return AuthenticateResult.Success(await CreateTicketAsync(identity, properties, accessToken, user)); + return HandleRequestResult.Success(await CreateTicketAsync(identity, properties, accessToken, user)); } protected virtual async Task CreateTicketAsync( @@ -127,18 +127,9 @@ namespace Microsoft.AspNetCore.Authentication.Twitter action.Run(user, identity, ClaimsIssuer); } - var context = new TwitterCreatingTicketContext(Context, Scheme, Options, properties, token.UserId, token.ScreenName, token.Token, token.TokenSecret, user) - { - Principal = new ClaimsPrincipal(identity) - }; - + var context = new TwitterCreatingTicketContext(Context, Scheme, Options, new ClaimsPrincipal(identity), properties, token.UserId, token.ScreenName, token.Token, token.TokenSecret, user); await Events.CreatingTicket(context); - if (context.Principal?.Identity == null) - { - return null; - } - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } @@ -165,7 +156,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions); - var redirectContext = new TwitterRedirectToAuthorizationEndpointContext(Context, Scheme, Options, properties, twitterAuthenticationEndpoint); + var redirectContext = new RedirectContext(Context, Scheme, Options, properties, twitterAuthenticationEndpoint); await Events.RedirectToAuthorizationEndpoint(redirectContext); } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json index 2023eb0b7a..6b84409111 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json @@ -19,31 +19,6 @@ "TypeId": "public interface Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", "Kind": "Removal" }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.TwitterOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, System.String redirectUri)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.TwitterOptions options, System.String userId, System.String screenName, System.String accessToken, System.String accessTokenSecret, Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", @@ -58,5 +33,13 @@ "TypeId": "public static class Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseTwitterAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.TwitterOptions options)", "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs new file mode 100644 index 0000000000..c29bdeae29 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -0,0 +1,103 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Used to configure authentication + /// + public class AuthenticationBuilder + { + /// + /// Constructor. + /// + /// The services being configured. + public AuthenticationBuilder(IServiceCollection services) + => Services = services; + + /// + /// The services being configured. + /// + public virtual IServiceCollection Services { get; } + + /// + /// Adds a which can be used by . + /// + /// The type to configure the handler."/>. + /// The used to handle this scheme. + /// The name of this scheme. + /// The display name of this scheme. + /// Used to configure the scheme options. + /// The builder. + public virtual AuthenticationBuilder AddScheme(string authenticationScheme, string displayName, Action configureOptions) + where TOptions : AuthenticationSchemeOptions, new() + where THandler : AuthenticationHandler + { + Services.Configure(o => + { + o.AddScheme(authenticationScheme, scheme => { + scheme.HandlerType = typeof(THandler); + scheme.DisplayName = displayName; + }); + }); + if (configureOptions != null) + { + Services.Configure(authenticationScheme, configureOptions); + } + Services.AddTransient(); + return this; + } + + /// + /// Adds a which can be used by . + /// + /// The type to configure the handler."/>. + /// The used to handle this scheme. + /// The name of this scheme. + /// Used to configure the scheme options. + /// The builder. + public virtual AuthenticationBuilder AddScheme(string authenticationScheme, Action configureOptions) + where TOptions : AuthenticationSchemeOptions, new() + where THandler : AuthenticationHandler + => AddScheme(authenticationScheme, displayName: null, configureOptions: configureOptions); + + /// + /// Adds a based that supports remote authentication + /// which can be used by . + /// + /// The type to configure the handler."/>. + /// The used to handle this scheme. + /// The name of this scheme. + /// The display name of this scheme. + /// Used to configure the scheme options. + /// The builder. + public virtual AuthenticationBuilder AddRemoteScheme(string authenticationScheme, string displayName, Action configureOptions) + where TOptions : RemoteAuthenticationOptions, new() + where THandler : RemoteAuthenticationHandler + { + Services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); + return AddScheme(authenticationScheme, displayName, configureOptions: configureOptions); + } + + // Used to ensure that there's always a default data protection provider + private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions + { + private readonly AuthenticationOptions _authOptions; + + public EnsureSignInScheme(IOptions authOptions) + { + _authOptions = authOptions.Value; + } + + public void PostConfigure(string name, TOptions options) + { + options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme; + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 788df7e19c..aeb70cb0de 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -178,35 +178,6 @@ namespace Microsoft.AspNetCore.Authentication protected abstract Task HandleAuthenticateAsync(); - public async Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - properties = properties ?? new AuthenticationProperties(); - await HandleSignInAsync(user, properties); - Logger.AuthenticationSchemeSignedIn(Scheme.Name); - } - - protected virtual Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) - { - return Task.CompletedTask; - } - - public async Task SignOutAsync(AuthenticationProperties properties) - { - properties = properties ?? new AuthenticationProperties(); - await HandleSignOutAsync(properties); - Logger.AuthenticationSchemeSignedOut(Scheme.Name); - } - - protected virtual Task HandleSignOutAsync(AuthenticationProperties properties) - { - return Task.CompletedTask; - } - /// /// Override this method to handle Forbid. /// diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 7ebc979f1b..28291f4196 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -13,7 +13,7 @@ namespace Microsoft.Extensions.DependencyInjection /// public static class AuthenticationServiceCollectionExtensions { - public static IServiceCollection AddAuthentication(this IServiceCollection services) + public static AuthenticationBuilder AddAuthentication(this IServiceCollection services) { if (services == null) { @@ -24,10 +24,10 @@ namespace Microsoft.Extensions.DependencyInjection services.AddDataProtection(); services.AddWebEncoders(); services.TryAddSingleton(); - return services; + return new AuthenticationBuilder(services); } - public static IServiceCollection AddAuthentication(this IServiceCollection services, Action configureOptions) { + public static AuthenticationBuilder AddAuthentication(this IServiceCollection services, Action configureOptions) { if (services == null) { throw new ArgumentNullException(nameof(services)); @@ -38,11 +38,12 @@ namespace Microsoft.Extensions.DependencyInjection throw new ArgumentNullException(nameof(configureOptions)); } - services.AddAuthentication(); + var builder = services.AddAuthentication(); services.Configure(configureOptions); - return services; + return builder; } + // REMOVE below once callers have been updated public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureScheme, Action configureOptions) where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs deleted file mode 100644 index cfe5809c5a..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Base context for authentication. - /// - public abstract class BaseAuthenticationContext : BaseContext - { - /// - /// Constructor. - /// - /// The context. - /// The name of the scheme. - /// The properties. - protected BaseAuthenticationContext(HttpContext context, string authenticationScheme, AuthenticationProperties properties) : base(context) - { - if (string.IsNullOrEmpty(authenticationScheme)) - { - throw new ArgumentException(nameof(authenticationScheme)); - } - - AuthenticationScheme = authenticationScheme; - Properties = properties ?? new AuthenticationProperties(); - } - - /// - /// The name of the scheme. - /// - public string AuthenticationScheme { get; } - - /// - /// Contains the extra meta-data arriving with the authentication. May be altered. - /// - public AuthenticationProperties Properties { get; protected set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs index 3d65f0dd75..915fc2377f 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs @@ -9,22 +9,44 @@ namespace Microsoft.AspNetCore.Authentication /// /// Base class used by other context classes. /// - public abstract class BaseContext + public abstract class BaseContext where TOptions : AuthenticationSchemeOptions { /// /// Constructor. /// - /// The request context. - protected BaseContext(HttpContext context) + /// The context. + /// The authentication scheme. + /// The authentication options associated with the scheme. + protected BaseContext(HttpContext context, AuthenticationScheme scheme, TOptions options) { if (context == null) { throw new ArgumentNullException(nameof(context)); } + if (scheme == null) + { + throw new ArgumentNullException(nameof(scheme)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } HttpContext = context; + Scheme = scheme; + Options = options; } + /// + /// The authentication scheme. + /// + public AuthenticationScheme Scheme { get; } + + /// + /// Gets the authentication options associated with the scheme. + /// + public TOptions Options { get; } + /// /// The context. /// @@ -33,17 +55,11 @@ namespace Microsoft.AspNetCore.Authentication /// /// The request. /// - public HttpRequest Request - { - get { return HttpContext.Request; } - } + public HttpRequest Request => HttpContext.Request; /// /// The response. /// - public HttpResponse Response - { - get { return HttpContext.Response; } - } + public HttpResponse Response => HttpContext.Response; } } diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs deleted file mode 100644 index fa582a3040..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs +++ /dev/null @@ -1,78 +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.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication -{ - public class BaseControlContext : BaseContext - { - protected BaseControlContext(HttpContext context) : base(context) - { - } - - public EventResultState State { get; set; } - - public bool HandledResponse - { - get { return State == EventResultState.HandledResponse; } - } - - public bool Skipped - { - get { return State == EventResultState.Skipped; } - } - - /// - /// Discontinue all processing for this request and return to the client. - /// The caller is responsible for generating the full response. - /// Set the to trigger SignIn. - /// - public void HandleResponse() - { - State = EventResultState.HandledResponse; - } - - /// - /// Discontinue processing the request in the current handler. - /// SignIn will not be called. - /// - public void Skip() - { - State = EventResultState.Skipped; - } - - /// - /// Gets or set the to return if this event signals it handled the event. - /// - public AuthenticationTicket Ticket { get; set; } - - /// - /// Returns true if the handler should be done processing. - /// - /// The result. - /// Whether the handler should be done processing. - public bool IsProcessingComplete(out AuthenticateResult result) - { - if (HandledResponse) - { - if (Ticket == null) - { - result = AuthenticateResult.Handle(); - } - else - { - result = AuthenticateResult.Success(Ticket); - } - return true; - } - else if (Skipped) - { - result = AuthenticateResult.None(); - return true; - } - result = null; - return false; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs b/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs deleted file mode 100644 index dad4c40fec..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs +++ /dev/null @@ -1,23 +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.AspNetCore.Authentication -{ - public enum EventResultState - { - /// - /// Continue with normal processing. - /// - Continue, - - /// - /// Discontinue processing the request. - /// - Skipped, - - /// - /// Discontinue all processing for this request. - /// - HandledResponse - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs new file mode 100644 index 0000000000..52dd9ce12f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs @@ -0,0 +1,32 @@ +// 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.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + public class HandleRequestContext : BaseContext where TOptions : AuthenticationSchemeOptions + { + protected HandleRequestContext( + HttpContext context, + AuthenticationScheme scheme, + TOptions options) + : base(context, scheme, options) { } + + /// + /// The which is used by the handler. + /// + public HandleRequestResult Result { get; protected set; } + + /// + /// Discontinue all processing for this request and return to the client. + /// The caller is responsible for generating the full response. + /// + public void HandleResponse() => Result = HandleRequestResult.Handle(); + + /// + /// Discontinue processing the request in the current handler. + /// + public void SkipHandler() => Result = HandleRequestResult.SkipHandler(); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs new file mode 100644 index 0000000000..8bf40760a1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs @@ -0,0 +1,30 @@ +// 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.Security.Claims; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base context for authentication events which deal with a ClaimsPrincipal. + /// + public abstract class PrincipalContext : PropertiesContext where TOptions : AuthenticationSchemeOptions + { + /// + /// Constructor. + /// + /// The context. + /// The authentication scheme. + /// The authentication options associated with the scheme. + /// The authentication properties. + protected PrincipalContext(HttpContext context, AuthenticationScheme scheme, TOptions options, AuthenticationProperties properties) + : base(context, scheme, options, properties) { } + + /// + /// Gets the containing the user claims. + /// + public virtual ClaimsPrincipal Principal { get; set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs new file mode 100644 index 0000000000..f1730d0d7f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs @@ -0,0 +1,31 @@ +// 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.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base context for authentication events which contain . + /// + public abstract class PropertiesContext : BaseContext where TOptions : AuthenticationSchemeOptions + { + /// + /// Constructor. + /// + /// The context. + /// The authentication scheme. + /// The authentication options associated with the scheme. + /// The authentication properties. + protected PropertiesContext(HttpContext context, AuthenticationScheme scheme, TOptions options, AuthenticationProperties properties) + : base(context, scheme, options) + { + Properties = properties ?? new AuthenticationProperties(); + } + + /// + /// Gets or sets the . + /// + public virtual AuthenticationProperties Properties { get; protected set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs similarity index 62% rename from src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs rename to src/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs index e4259d181e..dac24cafa6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs @@ -1,28 +1,32 @@ // 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.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNetCore.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication { /// - /// Context passed when a Challenge, SignIn, or SignOut causes a redirect in the cookie handler + /// Context passed for redirect events. /// - public class CookieRedirectContext : BaseCookieContext + public class RedirectContext : PropertiesContext where TOptions : AuthenticationSchemeOptions { /// /// Creates a new context object. /// /// The HTTP request context /// The scheme data - /// The cookie handler options + /// The handler options /// The initial redirect URI /// The . - public CookieRedirectContext(HttpContext context, AuthenticationScheme scheme, CookieAuthenticationOptions options, string redirectUri, AuthenticationProperties properties) + public RedirectContext( + HttpContext context, + AuthenticationScheme scheme, + TOptions options, + AuthenticationProperties properties, + string redirectUri) : base(context, scheme, options, properties) { + Properties = properties; RedirectUri = redirectUri; } diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs new file mode 100644 index 0000000000..b7a0168798 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs @@ -0,0 +1,49 @@ +// 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.Security.Claims; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base context for remote authentication. + /// + public abstract class RemoteAuthenticationContext : HandleRequestContext where TOptions : AuthenticationSchemeOptions + { + /// + /// Constructor. + /// + /// The context. + /// The authentication scheme. + /// The authentication options associated with the scheme. + /// The authentication properties. + protected RemoteAuthenticationContext( + HttpContext context, + AuthenticationScheme scheme, + TOptions options, + AuthenticationProperties properties) + : base(context, scheme, options) + => Properties = properties ?? new AuthenticationProperties(); + + /// + /// Gets the containing the user claims. + /// + public ClaimsPrincipal Principal { get; set; } + + /// + /// Gets or sets the . + /// + public virtual AuthenticationProperties Properties { get; set; } + + /// + /// Calls success creating a ticket with the and . + /// + public void Success() => Result = HandleRequestResult.Success(new AuthenticationTicket(Principal, Properties, Scheme.Name)); + + public void Fail(Exception failure) => Result = HandleRequestResult.Fail(failure); + + public void Fail(string failureMessage) => Result = HandleRequestResult.Fail(failureMessage); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs index 83a6507d42..ca0f4a5c01 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs @@ -8,14 +8,14 @@ namespace Microsoft.AspNetCore.Authentication { public class RemoteAuthenticationEvents { - public Func OnRemoteFailure { get; set; } = context => Task.CompletedTask; + public Func OnRemoteFailure { get; set; } = context => Task.CompletedTask; public Func OnTicketReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked when there is a remote failure /// - public virtual Task RemoteFailure(FailureContext context) => OnRemoteFailure(context); + public virtual Task RemoteFailure(RemoteFailureContext context) => OnRemoteFailure(context); /// /// Invoked after the remote ticket has been received. diff --git a/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs similarity index 64% rename from src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs rename to src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs index 5d2b30f130..becdfb5439 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs @@ -9,10 +9,14 @@ namespace Microsoft.AspNetCore.Authentication /// /// Provides failure context information to handler providers. /// - public class FailureContext : BaseControlContext + public class RemoteFailureContext : HandleRequestContext { - public FailureContext(HttpContext context, Exception failure) - : base(context) + public RemoteFailureContext( + HttpContext context, + AuthenticationScheme scheme, + RemoteAuthenticationOptions options, + Exception failure) + : base(context, scheme, options) { Failure = failure; } diff --git a/src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs new file mode 100644 index 0000000000..12b21f4bf6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs @@ -0,0 +1,65 @@ +// 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.Security.Claims; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base context for events that produce AuthenticateResults. + /// + public abstract class ResultContext : BaseContext where TOptions : AuthenticationSchemeOptions + { + /// + /// Constructor. + /// + /// The context. + /// The authentication scheme. + /// The authentication options associated with the scheme. + protected ResultContext(HttpContext context, AuthenticationScheme scheme, TOptions options) + : base(context, scheme, options) { } + + /// + /// Gets or sets the containing the user claims. + /// + public ClaimsPrincipal Principal { get; set; } + + private AuthenticationProperties _properties; + /// + /// Gets or sets the . + /// + public AuthenticationProperties Properties { + get => _properties ?? (_properties = new AuthenticationProperties()); + set => _properties = value; + } + + /// + /// Gets the result. + /// + public AuthenticateResult Result { get; private set; } + + /// + /// Calls success creating a ticket with the and . + /// + public void Success() => Result = HandleRequestResult.Success(new AuthenticationTicket(Principal, Properties, Scheme.Name)); + + /// + /// Indicates that there was no information returned for this authentication scheme. + /// + public void NoResult() => Result = AuthenticateResult.NoResult(); + + /// + /// Indicates that there was a failure during authentication. + /// + /// + public void Fail(Exception failure) => Result = AuthenticateResult.Fail(failure); + + /// + /// Indicates that there was a failure during authentication. + /// + /// + public void Fail(string failureMessage) => Result = AuthenticateResult.Fail(failureMessage); + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs index c0797ea9cc..51b77a37fa 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs @@ -3,30 +3,21 @@ using System.Security.Claims; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication { /// /// Provides context information to handler providers. /// - public class TicketReceivedContext : BaseControlContext + public class TicketReceivedContext : RemoteAuthenticationContext { - public TicketReceivedContext(HttpContext context, RemoteAuthenticationOptions options, AuthenticationTicket ticket) - : base(context) - { - Options = options; - Ticket = ticket; - if (ticket != null) - { - Principal = ticket.Principal; - Properties = ticket.Properties; - } - } - - public ClaimsPrincipal Principal { get; set; } - public AuthenticationProperties Properties { get; set; } - public RemoteAuthenticationOptions Options { get; set; } + public TicketReceivedContext( + HttpContext context, + AuthenticationScheme scheme, + RemoteAuthenticationOptions options, + AuthenticationTicket ticket) + : base(context, scheme, options, ticket?.Properties) + => Principal = ticket?.Principal; public string ReturnUri { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs index 49fc8db050..ed15e61904 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -9,14 +9,8 @@ namespace Microsoft.Extensions.Logging { private static Action _authSchemeAuthenticated; private static Action _authSchemeNotAuthenticated; - private static Action _authSchemeNotAuthenticatedWithFailure; - private static Action _authSchemeSignedIn; - private static Action _authSchemeSignedOut; private static Action _authSchemeChallenged; private static Action _authSchemeForbidden; - private static Action _userAuthorizationFailed; - private static Action _userAuthorizationSucceeded; - private static Action _userPrincipalMerged; private static Action _remoteAuthenticationError; private static Action _signInHandled; private static Action _signInSkipped; @@ -26,18 +20,6 @@ namespace Microsoft.Extensions.Logging static LoggingExtensions() { - _userAuthorizationSucceeded = LoggerMessage.Define( - eventId: 1, - logLevel: LogLevel.Information, - formatString: "Authorization was successful for user: {UserName}."); - _userAuthorizationFailed = LoggerMessage.Define( - eventId: 2, - logLevel: LogLevel.Information, - formatString: "Authorization failed for user: {UserName}."); - _userPrincipalMerged = LoggerMessage.Define( - eventId: 3, - logLevel: LogLevel.Information, - formatString: "HttpContext.User merged via AutomaticAuthentication from authenticationScheme: {AuthenticationScheme}."); _remoteAuthenticationError = LoggerMessage.Define( eventId: 4, logLevel: LogLevel.Information, @@ -50,10 +32,6 @@ namespace Microsoft.Extensions.Logging eventId: 6, logLevel: LogLevel.Debug, formatString: "The SigningIn event returned Skipped."); - _authSchemeNotAuthenticatedWithFailure = LoggerMessage.Define( - eventId: 7, - logLevel: LogLevel.Information, - formatString: "{AuthenticationScheme} was not authenticated. Failure message: {FailureMessage}"); _authSchemeAuthenticated = LoggerMessage.Define( eventId: 8, logLevel: LogLevel.Information, @@ -62,14 +40,6 @@ namespace Microsoft.Extensions.Logging eventId: 9, logLevel: LogLevel.Debug, formatString: "AuthenticationScheme: {AuthenticationScheme} was not authenticated."); - _authSchemeSignedIn = LoggerMessage.Define( - eventId: 10, - logLevel: LogLevel.Information, - formatString: "AuthenticationScheme: {AuthenticationScheme} signed in."); - _authSchemeSignedOut = LoggerMessage.Define( - eventId: 11, - logLevel: LogLevel.Information, - formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); _authSchemeChallenged = LoggerMessage.Define( eventId: 12, logLevel: LogLevel.Information, @@ -102,21 +72,6 @@ namespace Microsoft.Extensions.Logging _authSchemeNotAuthenticated(logger, authenticationScheme, null); } - public static void AuthenticationSchemeNotAuthenticatedWithFailure(this ILogger logger, string authenticationScheme, string failureMessage) - { - _authSchemeNotAuthenticatedWithFailure(logger, authenticationScheme, failureMessage, null); - } - - public static void AuthenticationSchemeSignedIn(this ILogger logger, string authenticationScheme) - { - _authSchemeSignedIn(logger, authenticationScheme, null); - } - - public static void AuthenticationSchemeSignedOut(this ILogger logger, string authenticationScheme) - { - _authSchemeSignedOut(logger, authenticationScheme, null); - } - public static void AuthenticationSchemeChallenged(this ILogger logger, string authenticationScheme) { _authSchemeChallenged(logger, authenticationScheme, null); @@ -127,21 +82,6 @@ namespace Microsoft.Extensions.Logging _authSchemeForbidden(logger, authenticationScheme, null); } - public static void UserAuthorizationSucceeded(this ILogger logger, string userName) - { - _userAuthorizationSucceeded(logger, userName, null); - } - - public static void UserAuthorizationFailed(this ILogger logger, string userName) - { - _userAuthorizationFailed(logger, userName, null); - } - - public static void UserPrinicpalMerged(this ILogger logger, string authenticationScheme) - { - _userPrincipalMerged(logger, authenticationScheme, null); - } - public static void RemoteAuthenticationError(this ILogger logger, string errorMessage) { _remoteAuthenticationError(logger, errorMessage, null); diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 69c926cc0f..62213a171b 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Security.Claims; using System.Security.Cryptography; using System.Text.Encodings.Web; using System.Threading.Tasks; @@ -35,19 +34,13 @@ namespace Microsoft.AspNetCore.Authentication } protected RemoteAuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) - : base(options, logger, encoder, clock) - { - } + : base(options, logger, encoder, clock) { } protected override Task CreateEventsAsync() - { - return Task.FromResult(new RemoteAuthenticationEvents()); - } + => Task.FromResult(new RemoteAuthenticationEvents()); public virtual Task ShouldHandleRequestAsync() - { - return Task.FromResult(Options.CallbackPath == Request.Path); - } + => Task.FromResult(Options.CallbackPath == Request.Path); public virtual async Task HandleRequestAsync() { @@ -69,7 +62,7 @@ namespace Microsoft.AspNetCore.Authentication { return true; } - else if (authResult.Nothing) + else if (authResult.Skipped || authResult.None) { return false; } @@ -89,25 +82,28 @@ namespace Microsoft.AspNetCore.Authentication if (exception != null) { Logger.RemoteAuthenticationError(exception.Message); - var errorContext = new FailureContext(Context, exception); + var errorContext = new RemoteFailureContext(Context, Scheme, Options, exception); await Events.RemoteFailure(errorContext); - if (errorContext.HandledResponse) + if (errorContext.Result != null) { - return true; - } - else if (errorContext.Skipped) - { - return false; + if (errorContext.Result.Handled) + { + return true; + } + else if (errorContext.Result.Skipped) + { + return false; + } } - throw new AggregateException("Unhandled remote failure.", exception); + throw exception; } // We have a ticket if we get here - var ticketContext = new TicketReceivedContext(Context, Options, ticket) + var ticketContext = new TicketReceivedContext(Context, Scheme, Options, ticket) { - ReturnUri = ticket.Properties.RedirectUri, + ReturnUri = ticket.Properties.RedirectUri }; // REVIEW: is this safe or good? ticket.Properties.RedirectUri = null; @@ -117,15 +113,18 @@ namespace Microsoft.AspNetCore.Authentication await Events.TicketReceived(ticketContext); - if (ticketContext.HandledResponse) + if (ticketContext.Result != null) { - Logger.SigninHandled(); - return true; - } - else if (ticketContext.Skipped) - { - Logger.SigninSkipped(); - return false; + if (ticketContext.Result.Handled) + { + Logger.SigninHandled(); + return true; + } + else if (ticketContext.Result.Skipped) + { + Logger.SigninSkipped(); + return false; + } } await Context.SignInAsync(SignInScheme, ticketContext.Principal, ticketContext.Properties); @@ -145,7 +144,7 @@ namespace Microsoft.AspNetCore.Authentication /// /// The method process the request on the endpoint defined by CallbackPath. /// - protected abstract Task HandleRemoteAuthenticateAsync(); + protected abstract Task HandleRemoteAuthenticateAsync(); protected override async Task HandleAuthenticateAsync() { @@ -174,20 +173,8 @@ namespace Microsoft.AspNetCore.Authentication return AuthenticateResult.Fail("Remote authentication does not directly support AuthenticateAsync"); } - protected override Task HandleSignOutAsync(AuthenticationProperties properties) - { - throw new NotSupportedException(); - } - - protected override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) - { - throw new NotSupportedException(); - } - protected override Task HandleForbiddenAsync(AuthenticationProperties properties) - { - return Context.ForbidAsync(SignInScheme); - } + => Context.ForbidAsync(SignInScheme); protected virtual void GenerateCorrelationId(AuthenticationProperties properties) { diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 066ca963a3..a5f0bb44b4 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -23,11 +23,6 @@ namespace Microsoft.AspNetCore.Authentication { throw new ArgumentException(Resources.FormatException_OptionMustBeProvided(nameof(CallbackPath)), nameof(CallbackPath)); } - - if (string.IsNullOrEmpty(SignInScheme)) - { - throw new ArgumentException(Resources.FormatException_OptionMustBeProvided(nameof(SignInScheme)), nameof(SignInScheme)); - } } /// diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs new file mode 100644 index 0000000000..8bcd2be01d --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs @@ -0,0 +1,78 @@ +// 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.AspNetCore.Authentication +{ + /// + /// Contains the result of an Authenticate call + /// + public class HandleRequestResult : AuthenticateResult + { + /// + /// Indicates that stage of authentication was directly handled by + /// user intervention and no further processing should be attempted. + /// + public bool Handled { get; private set; } + + /// + /// Indicates that the default authentication logic should be + /// skipped and that the rest of the pipeline should be invoked. + /// + public bool Skipped { get; private set; } + + /// + /// Indicates that authentication was successful. + /// + /// The ticket representing the authentication result. + /// The result. + public static new HandleRequestResult Success(AuthenticationTicket ticket) + { + if (ticket == null) + { + throw new ArgumentNullException(nameof(ticket)); + } + return new HandleRequestResult() { Ticket = ticket }; + } + + /// + /// Indicates that there was a failure during authentication. + /// + /// The failure exception. + /// The result. + public static new HandleRequestResult Fail(Exception failure) + { + return new HandleRequestResult() { Failure = failure }; + } + + /// + /// Indicates that there was a failure during authentication. + /// + /// The failure message. + /// The result. + public static new HandleRequestResult Fail(string failureMessage) + { + return new HandleRequestResult() { Failure = new Exception(failureMessage) }; + } + + /// + /// Discontinue all processing for this request and return to the client. + /// The caller is responsible for generating the full response. + /// + /// The result. + public static HandleRequestResult Handle() + { + return new HandleRequestResult() { Handled = true }; + } + + /// + /// Discontinue processing the request in the current handler. + /// + /// The result. + public static HandleRequestResult SkipHandler() + { + return new HandleRequestResult() { Skipped = true }; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json index 0eb0bfaf5f..81dc1133e2 100644 --- a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json @@ -83,44 +83,34 @@ "TypeId": "public static class Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", "Kind": "Removal" }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions options, Microsoft.AspNetCore.Authentication.AuthenticationTicket ticket)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions get_Options()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public System.Void set_Options(Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions value)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, { "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configureOptions)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public System.Boolean CheckEventResult(out Microsoft.AspNetCore.Authentication.AuthenticateResult result)", + "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.BaseContext", "Kind": "Removal" }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public System.Void SkipToNextMiddleware()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.FailureContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)", + "Kind": "Removal" + }, + { + "TypeId": "public enum Microsoft.AspNetCore.Authentication.EventResultState", "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs index 60f291f671..f93c2d92a3 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs @@ -52,13 +52,13 @@ namespace Microsoft.AspNetCore.Authorization.Policy else { context.User = new ClaimsPrincipal(new ClaimsIdentity()); - return AuthenticateResult.None(); + return AuthenticateResult.NoResult(); } } return (context.User?.Identity?.IsAuthenticated ?? false) ? AuthenticateResult.Success(new AuthenticationTicket(context.User, "context.User")) - : AuthenticateResult.None(); + : AuthenticateResult.NoResult(); } /// diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 677120e4be..7dade96eec 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics; using System.Linq; using System.Net; using System.Net.Http; @@ -29,7 +30,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddCookieAuthentication(); + var services = new ServiceCollection(); + services.AddAuthentication().AddCookie(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(CookieAuthenticationDefaults.AuthenticationScheme); @@ -124,7 +126,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies [Fact] public async Task SignInCausesDefaultCookieToBeCreated() { - var server = CreateServerWithServices(s => s.AddCookieAuthentication(o => + var server = CreateServerWithServices(s => s.AddAuthentication().AddCookie(o => { o.LoginPath = new PathString("/login"); o.CookieName = "TestCookie"; @@ -772,7 +774,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } app.Map("/login", signoutApp => signoutApp.Run(context => context.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); }) - .ConfigureServices(s => s.AddCookieAuthentication(o => o.LoginPath = new PathString("/page"))); + .ConfigureServices(s => s.AddAuthentication().AddCookie(o => o.LoginPath = new PathString("/page"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/login"); @@ -803,7 +805,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies await Assert.ThrowsAsync(() => context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme)); }); }) - .ConfigureServices(services => services.AddCookieAuthentication()); + .ConfigureServices(services => services.AddAuthentication().AddCookie()); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com"); @@ -821,7 +823,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies }) .ConfigureServices(services => { - services.AddCookieAuthentication(); + services.AddAuthentication().AddCookie(); services.Configure(CookieAuthenticationDefaults.AuthenticationScheme, o => o.CookieName = "One"); }); @@ -844,7 +846,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies }) .ConfigureServices(services => { - services.AddCookieAuthentication("Cookie1"); + services.AddAuthentication().AddCookie("Cookie1"); services.Configure("Cookie1", o => o.CookieName = "One"); }); @@ -866,7 +868,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies app.Map("/notlogin", signoutApp => signoutApp.Run(context => context.SignInAsync("Cookies", new ClaimsPrincipal()))); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.LoginPath = new PathString("/login"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.LoginPath = new PathString("/login"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/notlogin?ReturnUrl=%2Fpage"); @@ -883,7 +885,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies app.UseAuthentication(); app.Map("/login", signoutApp => signoutApp.Run(context => context.SignInAsync("Cookies", new ClaimsPrincipal()))); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.LoginPath = new PathString("/login"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.LoginPath = new PathString("/login"))); var server = new TestServer(builder); @@ -905,7 +907,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies app.UseAuthentication(); app.Map("/notlogout", signoutApp => signoutApp.Run(context => context.SignOutAsync("Cookies"))); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.LogoutPath = new PathString("/logout"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.LogoutPath = new PathString("/logout"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/notlogout?ReturnUrl=%2Fpage"); @@ -922,7 +924,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies app.UseAuthentication(); app.Map("/logout", signoutApp => signoutApp.Run(context => context.SignOutAsync("Cookies"))); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.LogoutPath = new PathString("/logout"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.LogoutPath = new PathString("/logout"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/logout?ReturnUrl=%2Fpage"); @@ -943,7 +945,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies app.UseAuthentication(); app.Map("/forbid", signoutApp => signoutApp.Run(context => context.ForbidAsync("Cookies"))); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.AccessDeniedPath = new PathString("/denied"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.AccessDeniedPath = new PathString("/denied"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/forbid"); @@ -963,7 +965,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies map.UseAuthentication(); map.Map("/login", signoutApp => signoutApp.Run(context => context.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); })) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.LoginPath = new PathString("/page"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.LoginPath = new PathString("/page"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/base/login"); @@ -1073,7 +1075,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies map.UseAuthentication(); map.Map("/forbid", signoutApp => signoutApp.Run(context => context.ForbidAsync("Cookies"))); })) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.AccessDeniedPath = new PathString("/denied"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.AccessDeniedPath = new PathString("/denied"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/base/forbid"); @@ -1097,7 +1099,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), new AuthenticationProperties())); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => { o.TicketDataFormat = new TicketDataFormat(dp); o.CookieName = "Cookie"; @@ -1117,7 +1119,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Describe(context.Response, result); }); }) - .ConfigureServices(services => services.AddCookieAuthentication("Cookies", o => + .ConfigureServices(services => services.AddAuthentication().AddCookie("Cookies", o => { o.CookieName = "Cookie"; o.TicketDataFormat = new TicketDataFormat(dp); @@ -1132,7 +1134,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies public async Task NullExpiresUtcPropertyIsGuarded() { var builder = new WebHostBuilder() - .ConfigureServices(services => services.AddCookieAuthentication(o => + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => { o.Events = new CookieAuthenticationEvents { @@ -1229,7 +1231,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies => CreateServerWithServices(s => { s.AddSingleton(_clock); - s.AddCookieAuthentication(configureOptions); + s.AddAuthentication().AddCookie(configureOptions); s.AddSingleton(); }, testpath, baseAddress); @@ -1281,6 +1283,15 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { await testpath(context); } + else if (req.Path == new PathString("/checkforerrors")) + { + var result = await context.AuthenticateAsync(CookieAuthenticationDefaults.AuthenticationScheme); // this used to be "Automatic" + if (result.Failure != null) + { + throw new Exception("Failed to authenticate", result.Failure); + } + return; + } else { await next(); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index b463ef8911..e6b5574df1 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -85,9 +85,9 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { options.DefaultSignInScheme = "External"; options.DefaultAuthenticateScheme = "External"; - }); - services.AddCookieAuthentication("External", o => { }); - services.AddFacebookAuthentication(o => + }) + .AddCookie("External", o => { }) + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; @@ -123,12 +123,12 @@ namespace Microsoft.AspNetCore.Authentication.Facebook }), services => { - services.AddCookieAuthentication("External", o => { }); - services.AddFacebookAuthentication(o => + services.AddAuthentication() + .AddCookie("External", o => { }) + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; - o.SignInScheme = "External"; }); }, handler: null); @@ -155,8 +155,9 @@ namespace Microsoft.AspNetCore.Authentication.Facebook }, services => { - services.AddCookieAuthentication("External", o => { }); - services.AddFacebookAuthentication(o => + services.AddAuthentication() + .AddCookie("External", o => { }) + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; @@ -185,9 +186,9 @@ namespace Microsoft.AspNetCore.Authentication.Facebook services.AddAuthentication(options => { options.DefaultSignInScheme = "External"; - }); - services.AddCookieAuthentication(); - services.AddFacebookAuthentication(o => + }) + .AddCookie() + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; @@ -217,19 +218,15 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var finalUserInfoEndpoint = string.Empty; var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("FacebookTest")); var server = CreateServer( - app => - { - app.UseAuthentication(); - }, + app => app.UseAuthentication(), services => { services.AddAuthentication(options => { - options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - services.AddCookieAuthentication(); - services.AddFacebookAuthentication(o => + }) + .AddCookie() + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 501fdf6035..2eae266702 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -516,7 +516,7 @@ namespace Microsoft.AspNetCore.Authentication.Google OnCreatingTicket = context => { var refreshToken = context.RefreshToken; - context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Google") }, "Google")); + context.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Google") }, "Google")); return Task.FromResult(0); } }; @@ -595,7 +595,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { OnTicketReceived = context => { - context.Ticket.Properties.RedirectUri = null; + context.Properties.RedirectUri = null; return Task.FromResult(0); } }; @@ -985,7 +985,7 @@ namespace Microsoft.AspNetCore.Authentication.Google else if (req.Path == new PathString("/tokens")) { var result = await context.AuthenticateAsync(TestExtensions.CookieAuthenticationScheme); - var tokens = result.Ticket.Properties.GetTokens(); + var tokens = result.Properties.GetTokens(); res.Describe(tokens); } else if (req.Path == new PathString("/me")) @@ -995,17 +995,17 @@ namespace Microsoft.AspNetCore.Authentication.Google else if (req.Path == new PathString("/authenticate")) { var result = await context.AuthenticateAsync(TestExtensions.CookieAuthenticationScheme); - res.Describe(result.Ticket.Principal); + res.Describe(result.Principal); } else if (req.Path == new PathString("/authenticateGoogle")) { var result = await context.AuthenticateAsync("Google"); - res.Describe(result?.Ticket?.Principal); + res.Describe(result?.Principal); } else if (req.Path == new PathString("/authenticateFacebook")) { var result = await context.AuthenticateAsync("Facebook"); - res.Describe(result?.Ticket?.Principal); + res.Describe(result?.Principal); } else if (req.Path == new PathString("/unauthorized")) { @@ -1024,15 +1024,15 @@ namespace Microsoft.AspNetCore.Authentication.Google } else if (req.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.SignInAsync("Google", new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.SignInAsync("Google", new ClaimsPrincipal())); } else if (req.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.SignOutAsync("Google")); + await Assert.ThrowsAsync(() => context.SignOutAsync("Google")); } else if (req.Path == new PathString("/forbid")) { - await Assert.ThrowsAsync(() => context.ForbidAsync("Google")); + await Assert.ThrowsAsync(() => context.ForbidAsync("Google")); } else if (testpath != null) { @@ -1050,12 +1050,12 @@ namespace Microsoft.AspNetCore.Authentication.Google services.AddAuthentication(o => { o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme; - o.DefaultSignInScheme = TestExtensions.CookieAuthenticationScheme; o.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme; }); - services.AddCookieAuthentication(TestExtensions.CookieAuthenticationScheme); - services.AddGoogleAuthentication(configureOptions); - services.AddFacebookAuthentication(o => + services.AddAuthentication() + .AddCookie(TestExtensions.CookieAuthenticationScheme) + .AddGoogle(configureOptions) + .AddFacebook(o => { o.AppId = "Test AppId"; o.AppSecret = "Test AppSecrent"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 3149e9875b..a9b158d2b0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -127,11 +127,8 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - context.Ticket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)), - new AuthenticationProperties(), context.Scheme.Name); - - context.HandleResponse(); + context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); + context.Success(); return Task.FromResult(null); } @@ -338,7 +335,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { // Retrieve the NameIdentifier claim from the identity // returned by the custom security token validator. - var identity = (ClaimsIdentity)context.Ticket.Principal.Identity; + var identity = (ClaimsIdentity)context.Principal.Identity; var identifier = identity.FindFirst(ClaimTypes.NameIdentifier); Assert.Equal("Bob le Tout Puissant", identifier.Value); @@ -396,7 +393,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { OnMessageReceived = context => { - context.Skip(); + context.NoResult(); return Task.FromResult(0); }, OnTokenValidated = context => @@ -420,7 +417,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } [Fact] - public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() + public async Task EventOnMessageReceivedReject_NoMoreEventsExecuted() { var server = CreateServer(options => { @@ -428,7 +425,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { OnMessageReceived = context => { - context.HandleResponse(); + context.Fail("Authentication was aborted from user code."); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -447,9 +444,12 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer }; }); - var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); - Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); - Assert.Equal(string.Empty, response.ResponseText); + var exception = await Assert.ThrowsAsync(delegate + { + return SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); } [Fact] @@ -461,7 +461,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { OnTokenValidated = context => { - context.Skip(); + context.NoResult(); return Task.FromResult(0); }, OnAuthenticationFailed = context => @@ -483,7 +483,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } [Fact] - public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() + public async Task EventOnTokenValidatedReject_NoMoreEventsExecuted() { var server = CreateServer(options => { @@ -491,7 +491,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { OnTokenValidated = context => { - context.HandleResponse(); + context.Fail("Authentication was aborted from user code."); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -508,9 +508,12 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); }); - var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); - Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); - Assert.Equal(string.Empty, response.ResponseText); + var exception = await Assert.ThrowsAsync(delegate + { + return SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); } [Fact] @@ -526,7 +529,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer }, OnAuthenticationFailed = context => { - context.Skip(); + context.NoResult(); return Task.FromResult(0); }, OnChallenge = context => @@ -544,7 +547,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } [Fact] - public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() + public async Task EventOnAuthenticationFailedReject_NoMoreEventsExecuted() { var server = CreateServer(options => { @@ -556,7 +559,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer }, OnAuthenticationFailed = context => { - context.HandleResponse(); + context.Fail("Authentication was aborted from user code."); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -569,9 +572,12 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); }); - var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); - Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); - Assert.Equal(string.Empty, response.ResponseText); + var exception = await Assert.ThrowsAsync(delegate + { + return SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); } [Fact] @@ -583,7 +589,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { OnChallenge = context => { - context.Skip(); + context.HandleResponse(); return Task.FromResult(0); }, }; @@ -595,29 +601,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal(string.Empty, response.ResponseText); } - - [Fact] - public async Task EventOnChallengeHandled_ResponseNotModified() - { - var server = CreateServer(o => - { - o.Events = new JwtBearerEvents() - { - OnChallenge = context => - { - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }, - }; - }); - - var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); - Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); - Assert.Empty(response.Response.Headers.WwwAuthenticate); - Assert.Equal(string.Empty, response.ResponseText); - } - class InvalidTokenValidator : ISecurityTokenValidator { public InvalidTokenValidator() @@ -752,11 +735,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } else if (context.Request.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); } else if (context.Request.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.SignOutAsync(JwtBearerDefaults.AuthenticationScheme)); + await Assert.ThrowsAsync(() => context.SignOutAsync(JwtBearerDefaults.AuthenticationScheme)); } else { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index bf15c91b00..f516940432 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount OnCreatingTicket = context => { var refreshToken = context.RefreshToken; - context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Microsoft") }, "Microsoft")); + context.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Microsoft") }, "Microsoft")); return Task.FromResult(null); } }; @@ -205,15 +205,15 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount } else if (req.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.SignInAsync("Microsoft", new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.SignInAsync("Microsoft", new ClaimsPrincipal())); } else if (req.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.SignOutAsync("Microsoft")); + await Assert.ThrowsAsync(() => context.SignOutAsync("Microsoft")); } else if (req.Path == new PathString("/forbid")) { - await Assert.ThrowsAsync(() => context.ForbidAsync("Microsoft")); + await Assert.ThrowsAsync(() => context.ForbidAsync("Microsoft")); } else { @@ -226,10 +226,10 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount services.AddAuthentication(o => { o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme; - o.DefaultSignInScheme = TestExtensions.CookieAuthenticationScheme; }); - services.AddCookieAuthentication(TestExtensions.CookieAuthenticationScheme, o => { }); - services.AddMicrosoftAccountAuthentication(configureOptions); + services.AddAuthentication() + .AddCookie(TestExtensions.CookieAuthenticationScheme, o => { }) + .AddMicrosoftAccount(configureOptions); }); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index dcc96c0942..bdd79533b1 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -143,29 +143,6 @@ namespace Microsoft.AspNetCore.Authentication.OAuth Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } - [Fact] - public async Task ThrowsIfSignInSchemeMissing() - { - var server = CreateServer( - app => { }, - services => services.AddOAuthAuthentication("weeblie", o => - { - o.ClientId = "Whatever;"; - o.ClientSecret = "Whatever;"; - o.CallbackPath = "/"; - o.TokenEndpoint = "/"; - o.AuthorizationEndpoint = "/"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("SignInScheme", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - } - [Fact] public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallBackPath() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index 3c0146b083..d21a1f4246 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -335,7 +335,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect // This test can be further refined. When one auth handler skips, the authentication responsibility // will be flowed to the next one. A dummy auth handler can be added to ensure the correct logic. [Fact] - public async Task OnRedirectToIdentityProviderEventSkipResponse() + public async Task OnRedirectToIdentityProviderEventHandleResponse() { var settings = new TestSettings( opts => @@ -346,7 +346,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { OnRedirectToIdentityProvider = context => { - context.Skip(); + context.HandleResponse(); return Task.FromResult(0); } }; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 3ceb4a5336..74f00c8f95 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -22,8 +22,9 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(); - services.AddOpenIdConnectAuthentication(o => + services.AddAuthentication() + .AddCookie() + .AddOpenIdConnect(o => { o.Authority = TestServerBuilder.DefaultAuthority; o.ClientId = Guid.NewGuid().ToString(); @@ -45,19 +46,6 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } - [Fact] - public Task ThrowsWhenSignInSchemeIsMissing() - { - return TestConfigurationException( - o => - { - o.ClientId = "Test Id"; - o.Authority = TestServerBuilder.DefaultAuthority; - o.CallbackPath = "/"; - }, - ex => Assert.Equal("SignInScheme", ex.ParamName)); - } - [Fact] public Task ThrowsWhenClientIdIsMissing() { @@ -119,8 +107,9 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(); - services.AddOpenIdConnectAuthentication(options); + services.AddAuthentication() + .AddCookie() + .AddOpenIdConnect(options); }) .Configure(app => app.UseAuthentication()); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index 607e9bb623..4ea69369e8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect private readonly Func UserNotImpl = context => { throw new NotImplementedException("User"); }; private readonly Func FailedNotImpl = context => { throw new NotImplementedException("Failed", context.Exception); }; private readonly Func TicketNotImpl = context => { throw new NotImplementedException("Ticket"); }; - private readonly Func FailureNotImpl = context => { throw new NotImplementedException("Failure", context.Failure); }; + private readonly Func FailureNotImpl = context => { throw new NotImplementedException("Failure", context.Failure); }; private readonly Func RedirectNotImpl = context => { throw new NotImplementedException("Redirect"); }; private readonly Func RemoteSignOutNotImpl = context => { throw new NotImplementedException("Remote"); }; private readonly RequestDelegate AppNotImpl = context => { throw new NotImplementedException("App"); }; @@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnMessageReceived = context => { messageReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnTokenValidated = TokenNotImpl, @@ -75,6 +75,51 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.True(messageReceived); } + [Fact] + public async Task OnMessageReceived_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnTokenValidated = TokenNotImpl, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", ""); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(remoteFailure); + } + [Fact] public async Task OnMessageReceived_Handled_NoMoreEventsRun() { @@ -124,7 +169,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenValidated = context => { tokenValidated = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnAuthorizationCodeReceived = CodeNotImpl, @@ -151,6 +196,57 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.True(tokenValidated); } + [Fact] + public async Task OnTokenValidated_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(remoteFailure); + } + [Fact] public async Task OnTokenValidated_HandledWithoutTicket_NoMoreEventsRun() { @@ -167,7 +263,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { tokenValidated = true; context.HandleResponse(); - context.Ticket = null; + context.Principal = null; context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -209,8 +305,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenValidated = context => { tokenValidated = true; - context.HandleResponse(); - // context.Ticket = null; + context.Success(); return Task.FromResult(0); }, OnAuthorizationCodeReceived = CodeNotImpl, @@ -262,7 +357,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnAuthorizationCodeReceived = context => { codeReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnTokenResponseReceived = TokenResponseNotImpl, @@ -289,6 +384,63 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.True(codeReceived); } + [Fact] + public async Task OnAuthorizationCodeReceived_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(remoteFailure); + } + [Fact] public async Task OnAuthorizationCodeReceived_HandledWithoutTicket_NoMoreEventsRun() { @@ -311,7 +463,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { codeReceived = true; context.HandleResponse(); - context.Ticket = null; + context.Principal = null; context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -358,8 +510,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnAuthorizationCodeReceived = context => { codeReceived = true; - context.HandleResponse(); - // context.Ticket = null; + context.Success(); return Task.FromResult(0); }, OnTokenResponseReceived = TokenResponseNotImpl, @@ -417,7 +568,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenResponseReceived = context => { tokenResponseReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -444,6 +595,69 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.True(tokenResponseReceived); } + [Fact] + public async Task OnTokenResponseReceived_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(remoteFailure); + } + [Fact] public async Task OnTokenResponseReceived_HandledWithoutTicket_NoMoreEventsRun() { @@ -471,7 +685,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenResponseReceived = context => { tokenResponseReceived = true; - context.Ticket = null; + context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); @@ -525,8 +739,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenResponseReceived = context => { tokenResponseReceived = true; - // context.Ticket = null; - context.HandleResponse(); + context.Success(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -584,7 +797,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenValidated = context => { tokenValidated = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -611,6 +824,69 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.True(tokenValidated); } + [Fact] + public async Task OnTokenValidatedBackchannel_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var codeReceived = false; + var tokenResponseReceived = false; + var tokenValidated = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(tokenValidated); + Assert.True(remoteFailure); + } + [Fact] public async Task OnTokenValidatedBackchannel_HandledWithoutTicket_NoMoreEventsRun() { @@ -638,7 +914,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenValidated = context => { tokenValidated = true; - context.Ticket = null; + context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); @@ -692,8 +968,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTokenValidated = context => { tokenValidated = true; - // context.Ticket = null; - context.HandleResponse(); + context.Success(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -757,7 +1032,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnUserInformationReceived = context => { userInfoReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnAuthenticationFailed = FailedNotImpl, @@ -784,6 +1059,75 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.True(userInfoReceived); } + [Fact] + public async Task OnUserInformationReceived_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(remoteFailure); + } + [Fact] public async Task OnUserInformationReceived_HandledWithoutTicket_NoMoreEventsRun() { @@ -817,7 +1161,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnUserInformationReceived = context => { userInfoReceived = true; - context.Ticket = null; + context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); @@ -878,7 +1222,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { userInfoReceived = true; // context.Ticket = null; - context.HandleResponse(); + context.Success(); return Task.FromResult(0); }, OnAuthenticationFailed = FailedNotImpl, @@ -949,7 +1293,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { authFailed = true; Assert.Equal("TestException", context.Exception.Message); - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnRemoteFailure = FailureNotImpl, @@ -976,6 +1320,82 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.True(authFailed); } + [Fact] + public async Task OnAuthenticationFailed_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var authFailed = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + throw new NotImplementedException("TestException"); + }, + OnAuthenticationFailed = context => + { + authFailed = true; + Assert.Equal("TestException", context.Exception.Message); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(authFailed); + Assert.True(remoteFailure); + } + [Fact] public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() { @@ -1016,7 +1436,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { authFailed = true; Assert.Equal("TestException", context.Exception.Message); - Assert.Null(context.Ticket); + Assert.Null(context.Principal); context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); @@ -1083,7 +1503,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { authFailed = true; Assert.Equal("TestException", context.Exception.Message); - Assert.Null(context.Ticket); + Assert.Null(context.Principal); var claims = new[] { @@ -1092,11 +1512,8 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - context.Ticket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)), - new AuthenticationProperties(), context.Scheme.Name); - - context.HandleResponse(); + context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); + context.Success(); return Task.FromResult(0); }, OnRemoteFailure = FailureNotImpl, @@ -1174,7 +1591,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnTicketReceived = TicketNotImpl, @@ -1314,7 +1731,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect OnTicketReceived = context => { ticektReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, @@ -1408,8 +1825,9 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(); - services.AddOpenIdConnectAuthentication(o => + services.AddAuthentication() + .AddCookie() + .AddOpenIdConnect(o => { o.Events = events; o.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 6cfda3b85a..7f9d42b1c9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net; @@ -11,10 +10,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.DataProtection; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs index aa7f6179be..1ffb9ff686 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -112,10 +112,10 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect services.AddAuthentication(o => { o.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; }); - services.AddCookieAuthentication(); - services.AddOpenIdConnectAuthentication(options); + services.AddAuthentication() + .AddCookie() + .AddOpenIdConnect(options); }); return new TestServer(builder); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs index afdef0a408..05e5708de0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -134,7 +134,7 @@ namespace Microsoft.AspNetCore.Authentication // return Task.FromResult(0); // } - // public Task ChallengeAsync(ChallengeContext context) + // public Task ChallengeAsync(AuthenticationProperties properties) // { // throw new NotImplementedException(); // } @@ -144,12 +144,12 @@ namespace Microsoft.AspNetCore.Authentication // throw new NotImplementedException(); // } - // public Task SignInAsync(SignInContext context) + // public Task SignInAsync(ClaimsPrincipal principal, AuthenticationProperties properties) // { // throw new NotImplementedException(); // } - // public Task SignOutAsync(SignOutContext context) + // public Task SignOutAsync(AuthenticationProperties properties) // { // throw new NotImplementedException(); // } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 8fcc0780d2..76f6b1aad9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Security.Claims; @@ -13,7 +12,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -177,15 +175,15 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var res = context.Response; if (req.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.SignInAsync("Twitter", new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.SignInAsync("Twitter", new ClaimsPrincipal())); } else if (req.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.SignOutAsync("Twitter")); + await Assert.ThrowsAsync(() => context.SignOutAsync("Twitter")); } else if (req.Path == new PathString("/forbid")) { - await Assert.ThrowsAsync(() => context.ForbidAsync("Twitter")); + await Assert.ThrowsAsync(() => context.ForbidAsync("Twitter")); } else if (handler == null || !handler(context)) { @@ -195,13 +193,14 @@ namespace Microsoft.AspNetCore.Authentication.Twitter }) .ConfigureServices(services => { - services.AddCookieAuthentication("External", _ => { }); Action wrapOptions = o => { o.SignInScheme = "External"; options(o); }; - services.AddTwitterAuthentication(wrapOptions); + services.AddAuthentication() + .AddCookie("External", _ => { }) + .AddTwitter(wrapOptions); }); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index b6b2776a8a..5c2458c529 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -312,7 +312,7 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(o => + services.AddAuthentication().AddCookie(o => { o.CookieName = "TestCookie"; o.CookieHttpOnly = false; @@ -352,7 +352,7 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(o => + services.AddAuthentication().AddCookie(o => { o.CookieName = "TestCookie"; o.CookieHttpOnly = false; diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index ae5e6f0183..e2e4fd7d07 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -68,7 +68,7 @@ namespace Microsoft.Owin.Security.Interop await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); }); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); @@ -123,7 +123,7 @@ namespace Microsoft.Owin.Security.Interop await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); }); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); @@ -155,7 +155,7 @@ namespace Microsoft.Owin.Security.Interop app.UseAuthentication(); app.Run(context => context.SignInAsync("Cookies", user)); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); @@ -202,7 +202,7 @@ namespace Microsoft.Owin.Security.Interop app.UseAuthentication(); app.Run(context => context.SignInAsync("Cookies", user)); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); From 96f6436a677aba66f4b5a39da4bc9153921eeab6 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 3 Jul 2017 14:07:57 -0700 Subject: [PATCH 753/900] Update LICENSE.txt text --- LICENSE.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 0bdc1962b6..7b2956ecee 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,10 +1,12 @@ -Copyright (c) .NET Foundation. All rights reserved. +Copyright (c) .NET Foundation and Contributors + +All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use -these files except in compliance with the License. You may obtain a copy of the +this file except in compliance with the License. You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR From 66b939725ed6d1b4eb8ce5d4823b635990c086b4 Mon Sep 17 00:00:00 2001 From: Murat Girgin Date: Mon, 3 Jul 2017 15:42:40 -0700 Subject: [PATCH 754/900] https://github.com/aspnet/Security/issues/1265. Check Auth failures and log them. --- .../AuthenticationHandler.cs | 4 ++++ .../LoggingExtensions.cs | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index aeb70cb0de..a258d0acaf 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -142,6 +142,10 @@ namespace Microsoft.AspNetCore.Authentication Logger.AuthenticationSchemeNotAuthenticated(Scheme.Name); } } + else if (result?.Failure != null) + { + Logger.AuthenticationSchemeNotAuthenticatedWithFailure(Scheme.Name, result.Failure.Message); + } return result; } diff --git a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs index ed15e61904..46223d6471 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -9,6 +9,7 @@ namespace Microsoft.Extensions.Logging { private static Action _authSchemeAuthenticated; private static Action _authSchemeNotAuthenticated; + private static Action _authSchemeNotAuthenticatedWithFailure; private static Action _authSchemeChallenged; private static Action _authSchemeForbidden; private static Action _remoteAuthenticationError; @@ -32,6 +33,10 @@ namespace Microsoft.Extensions.Logging eventId: 6, logLevel: LogLevel.Debug, formatString: "The SigningIn event returned Skipped."); + _authSchemeNotAuthenticatedWithFailure = LoggerMessage.Define( + eventId: 7, + logLevel: LogLevel.Information, + formatString: "{AuthenticationScheme} was not authenticated. Failure message: {FailureMessage}"); _authSchemeAuthenticated = LoggerMessage.Define( eventId: 8, logLevel: LogLevel.Information, @@ -72,6 +77,11 @@ namespace Microsoft.Extensions.Logging _authSchemeNotAuthenticated(logger, authenticationScheme, null); } + public static void AuthenticationSchemeNotAuthenticatedWithFailure(this ILogger logger, string authenticationScheme, string failureMessage) + { + _authSchemeNotAuthenticatedWithFailure(logger, authenticationScheme, failureMessage, null); + } + public static void AuthenticationSchemeChallenged(this ILogger logger, string authenticationScheme) { _authSchemeChallenged(logger, authenticationScheme, null); From 968237d75126b7b5d8a5383677431d06452c1dc8 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 29 Jun 2017 16:23:31 -0700 Subject: [PATCH 755/900] Replace configure method on Twitter, RemoteAuthentication, and OpenIdConnect options with CookieBuilder --- .../OpenIdConnectHandler.cs | 42 ++++---------- .../OpenIdConnectOptions.cs | 50 +++++++++++++++-- .../TwitterHandler.cs | 27 ++------- .../TwitterOptions.cs | 55 +++++++++++++++---- .../Internal/RequestPathBaseCookieBuilder.cs | 38 +++++++++++++ .../RemoteAuthenticationHandler.cs | 32 ++--------- .../RemoteAuthenticationOptions.cs | 55 +++++++++++++++++-- .../OAuthTests.cs | 2 +- .../OpenIdConnect/OpenIdConnectTests.cs | 4 +- 9 files changed, 203 insertions(+), 102 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 341abbf5a2..9e6d34bc98 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -275,8 +275,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// A task executing the callback procedure protected virtual Task HandleSignOutCallbackAsync() { - StringValues protectedState; - if (Request.Query.TryGetValue(OpenIdConnectParameterNames.State, out protectedState)) + if (Request.Query.TryGetValue(OpenIdConnectParameterNames.State, out StringValues protectedState)) { var properties = Options.StateDataFormat.Unprotect(protectedState); if (!string.IsNullOrEmpty(properties?.RedirectUri)) @@ -505,8 +504,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return HandleRequestResult.Fail(Resources.MessageStateIsInvalid); } - string userstate = null; - properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out userstate); + properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out string userstate); authorizationResponse.State = userstate; if (!ValidateCorrelationId(properties)) @@ -859,8 +857,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (!string.IsNullOrEmpty(message.ExpiresIn)) { - int value; - if (int.TryParse(message.ExpiresIn, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) + if (int.TryParse(message.ExpiresIn, NumberStyles.Integer, CultureInfo.InvariantCulture, out int value)) { var expiresAt = Clock.UtcNow + TimeSpan.FromSeconds(value); // https://www.w3.org/TR/xmlschema-2/#dateTime @@ -885,21 +882,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect throw new ArgumentNullException(nameof(nonce)); } - var options = new CookieOptions - { - HttpOnly = true, - SameSite = Http.SameSiteMode.None, - Path = OriginalPathBase + Options.CallbackPath, - Secure = Request.IsHttps, - Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) - }; - - Options.ConfigureNonceCookie?.Invoke(Context, options); + var cookieOptions = Options.NonceCookie.Build(Context, Clock.UtcNow); Response.Cookies.Append( - OpenIdConnectDefaults.CookieNoncePrefix + Options.StringDataFormat.Protect(nonce), + Options.NonceCookie.Name + Options.StringDataFormat.Protect(nonce), NonceProperty, - options); + cookieOptions); } /// @@ -918,23 +906,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect foreach (var nonceKey in Request.Cookies.Keys) { - if (nonceKey.StartsWith(OpenIdConnectDefaults.CookieNoncePrefix)) + if (nonceKey.StartsWith(Options.NonceCookie.Name)) { try { - var nonceDecodedValue = Options.StringDataFormat.Unprotect(nonceKey.Substring(OpenIdConnectDefaults.CookieNoncePrefix.Length, nonceKey.Length - OpenIdConnectDefaults.CookieNoncePrefix.Length)); + var nonceDecodedValue = Options.StringDataFormat.Unprotect(nonceKey.Substring(Options.NonceCookie.Name.Length, nonceKey.Length - Options.NonceCookie.Name.Length)); if (nonceDecodedValue == nonce) { - var cookieOptions = new CookieOptions - { - HttpOnly = true, - Path = OriginalPathBase + Options.CallbackPath, - SameSite = Http.SameSiteMode.None, - Secure = Request.IsHttps - }; - - Options.ConfigureNonceCookie?.Invoke(Context, cookieOptions); - + var cookieOptions = Options.NonceCookie.Build(Context, Clock.UtcNow); Response.Cookies.Delete(nonceKey, cookieOptions); return nonce; } @@ -1170,8 +1149,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect validationParameters.IssuerSigningKeys = validationParameters.IssuerSigningKeys?.Concat(_configuration.SigningKeys) ?? _configuration.SigningKeys; } - SecurityToken validatedToken = null; - var principal = Options.SecurityTokenValidator.ValidateToken(idToken, validationParameters, out validatedToken); + var principal = Options.SecurityTokenValidator.ValidateToken(idToken, validationParameters, out SecurityToken validatedToken); jwt = validatedToken as JwtSecurityToken; if (jwt == null) { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 8bcedaec27..23169b5bcd 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; +using Microsoft.AspNetCore.Authentication.Internal; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Protocols; @@ -17,6 +18,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// public class OpenIdConnectOptions : RemoteAuthenticationOptions { + private CookieBuilder _nonceCookieBuilder; + /// /// Initializes a new /// @@ -65,6 +68,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect ClaimActions.MapUniqueJsonKey("family_name", "family_name"); ClaimActions.MapUniqueJsonKey("profile", "profile"); ClaimActions.MapUniqueJsonKey("email", "email"); + + _nonceCookieBuilder = new OpenIdConnectNonceCookieBuilder(this) + { + Name = OpenIdConnectDefaults.CookieNoncePrefix, + HttpOnly = true, + SameSite = SameSiteMode.None, + SecurePolicy = CookieSecurePolicy.SameAsRequest, + }; } /// @@ -145,8 +156,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// public new OpenIdConnectEvents Events { - get { return (OpenIdConnectEvents)base.Events; } - set { base.Events = value; } + get => (OpenIdConnectEvents)base.Events; + set => base.Events = value; } /// @@ -259,9 +270,40 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect public bool DisableTelemetry { get; set; } /// - /// Gets or sets an action that can override the nonce cookie options before the + /// Determines the settings used to create the nonce cookie before the /// cookie gets added to the response. /// - public Action ConfigureNonceCookie { get; set; } + /// + /// The value of is treated as the prefix to the cookie name, and defaults to . + /// + public CookieBuilder NonceCookie + { + get => _nonceCookieBuilder; + set => _nonceCookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); + } + + private class OpenIdConnectNonceCookieBuilder : RequestPathBaseCookieBuilder + { + private readonly OpenIdConnectOptions _options; + + public OpenIdConnectNonceCookieBuilder(OpenIdConnectOptions oidcOptions) + { + _options = oidcOptions; + } + + protected override string AdditionalPath => _options.CallbackPath; + + public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom) + { + var cookieOptions = base.Build(context, expiresFrom); + + if (!Expiration.HasValue || !cookieOptions.Expires.HasValue) + { + cookieOptions.Expires = expiresFrom.Add(_options.ProtocolValidator.NonceLifetime); + } + + return cookieOptions; + } + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 7fcc01eee1..ddcd095d5b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -10,7 +10,6 @@ using System.Security.Cryptography; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; @@ -23,7 +22,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter internal class TwitterHandler : RemoteAuthenticationHandler { private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - private const string StateCookie = "__TwitterState"; private const string RequestTokenEndpoint = "https://api.twitter.com/oauth/request_token"; private const string AuthenticationEndpoint = "https://api.twitter.com/oauth/authenticate?oauth_token="; private const string AccessTokenEndpoint = "https://api.twitter.com/oauth/access_token"; @@ -50,7 +48,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { AuthenticationProperties properties = null; var query = Request.Query; - var protectedRequestToken = Request.Cookies[StateCookie]; + var protectedRequestToken = Request.Cookies[Options.StateCookie.Name]; var requestToken = Options.StateDataFormat.Unprotect(protectedRequestToken); @@ -80,16 +78,9 @@ namespace Microsoft.AspNetCore.Authentication.Twitter return HandleRequestResult.Fail("Missing or blank oauth_verifier"); } - var cookieOptions = new CookieOptions - { - HttpOnly = true, - SameSite = SameSiteMode.Lax, - Secure = Request.IsHttps - }; + var cookieOptions = Options.StateCookie.Build(Context, Clock.UtcNow); - Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); - - Response.Cookies.Delete(StateCookie, cookieOptions); + Response.Cookies.Delete(Options.StateCookie.Name, cookieOptions); var accessToken = await ObtainAccessTokenAsync(requestToken, oauthVerifier); @@ -144,17 +135,9 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var requestToken = await ObtainRequestTokenAsync(BuildRedirectUri(Options.CallbackPath), properties); var twitterAuthenticationEndpoint = AuthenticationEndpoint + requestToken.Token; - var cookieOptions = new CookieOptions - { - HttpOnly = true, - SameSite = SameSiteMode.Lax, - Secure = Request.IsHttps, - Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), - }; + var cookieOptions = Options.StateCookie.Build(Context, Clock.UtcNow); - Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); - - Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions); + Response.Cookies.Append(Options.StateCookie.Name, Options.StateDataFormat.Protect(requestToken), cookieOptions); var redirectContext = new RedirectContext(Context, Scheme, Options, properties, twitterAuthenticationEndpoint); await Events.RedirectToAuthorizationEndpoint(redirectContext); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 8b57f2502f..0190f21a6b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -3,10 +3,7 @@ using System; using System.Security.Claims; -using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth.Claims; -using Microsoft.AspNetCore.Authentication.Twitter; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -16,6 +13,10 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// public class TwitterOptions : RemoteAuthenticationOptions { + private const string DefaultStateCookieName = "__TwitterState"; + + private CookieBuilder _stateCookieBuilder; + /// /// Initializes a new instance of the class. /// @@ -26,6 +27,14 @@ namespace Microsoft.AspNetCore.Authentication.Twitter Events = new TwitterEvents(); ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); + + _stateCookieBuilder = new TwitterCookieBuilder(this) + { + Name = DefaultStateCookieName, + SecurePolicy = CookieSecurePolicy.SameAsRequest, + HttpOnly = true, + SameSite = SameSiteMode.Lax, + }; } /// @@ -58,19 +67,43 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// public ISecureDataFormat StateDataFormat { get; set; } - /// - /// Gets or sets an action that can override the state cookie options before the - /// cookie gets added to the response. - /// - public Action ConfigureStateCookie { get; set; } - /// /// Gets or sets the used to handle authentication events. /// public new TwitterEvents Events { - get { return (TwitterEvents)base.Events; } - set { base.Events = value; } + get => (TwitterEvents)base.Events; + set => base.Events = value; + } + + /// + /// Determines the settings used to create the state cookie before the + /// cookie gets added to the response. + /// + public CookieBuilder StateCookie + { + get => _stateCookieBuilder; + set => _stateCookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); + } + + private class TwitterCookieBuilder : CookieBuilder + { + private readonly TwitterOptions _twitterOptions; + + public TwitterCookieBuilder(TwitterOptions twitterOptions) + { + _twitterOptions = twitterOptions; + } + + public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom) + { + var options = base.Build(context, expiresFrom); + if (!Expiration.HasValue) + { + options.Expires = expiresFrom.Add(_twitterOptions.RemoteAuthenticationTimeout); + } + return options; + } } } } diff --git a/src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs b/src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs new file mode 100644 index 0000000000..f42617cb23 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs @@ -0,0 +1,38 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication.Internal +{ + /// + /// A cookie builder that sets to the request path base. + /// + public class RequestPathBaseCookieBuilder : CookieBuilder + { + /// + /// Gets an optional value that is appended to the request path base. + /// + protected virtual string AdditionalPath { get; } + + public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom) + { + // check if the user has overridden the default value of path. If so, use that instead of our default value. + var path = Path; + if (path == null) + { + var originalPathBase = context.Features.Get()?.OriginalPathBase ?? context.Request.PathBase; + path = originalPathBase + AdditionalPath; + } + + var options = base.Build(context, expiresFrom); + + options.Path = !string.IsNullOrEmpty(path) + ? path + : "/"; + + return options; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 62213a171b..7bd3b07731 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -5,7 +5,6 @@ using System; using System.Security.Cryptography; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -14,7 +13,6 @@ namespace Microsoft.AspNetCore.Authentication public abstract class RemoteAuthenticationHandler : AuthenticationHandler, IAuthenticationRequestHandler where TOptions : RemoteAuthenticationOptions, new() { - private const string CorrelationPrefix = ".AspNetCore.Correlation."; private const string CorrelationProperty = ".xsrf"; private const string CorrelationMarker = "N"; private const string AuthSchemeKey = ".AuthScheme"; @@ -187,20 +185,11 @@ namespace Microsoft.AspNetCore.Authentication CryptoRandom.GetBytes(bytes); var correlationId = Base64UrlTextEncoder.Encode(bytes); - var cookieOptions = new CookieOptions - { - HttpOnly = true, - SameSite = SameSiteMode.None, - Secure = Request.IsHttps, - Path = OriginalPathBase + Options.CallbackPath, - Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), - }; - - Options.ConfigureCorrelationIdCookie?.Invoke(Context, cookieOptions); + var cookieOptions = Options.CorrelationCookie.Build(Context, Clock.UtcNow); properties.Items[CorrelationProperty] = correlationId; - var cookieName = CorrelationPrefix + Scheme.Name + "." + correlationId; + var cookieName = Options.CorrelationCookie.Name + Scheme.Name + "." + correlationId; Response.Cookies.Append(cookieName, CorrelationMarker, cookieOptions); } @@ -212,16 +201,15 @@ namespace Microsoft.AspNetCore.Authentication throw new ArgumentNullException(nameof(properties)); } - string correlationId; - if (!properties.Items.TryGetValue(CorrelationProperty, out correlationId)) + if (!properties.Items.TryGetValue(CorrelationProperty, out string correlationId)) { - Logger.CorrelationPropertyNotFound(CorrelationPrefix); + Logger.CorrelationPropertyNotFound(Options.CorrelationCookie.Name); return false; } properties.Items.Remove(CorrelationProperty); - var cookieName = CorrelationPrefix + Scheme.Name + "." + correlationId; + var cookieName = Options.CorrelationCookie.Name + Scheme.Name + "." + correlationId; var correlationCookie = Request.Cookies[cookieName]; if (string.IsNullOrEmpty(correlationCookie)) @@ -230,15 +218,7 @@ namespace Microsoft.AspNetCore.Authentication return false; } - var cookieOptions = new CookieOptions - { - HttpOnly = true, - Path = OriginalPathBase + Options.CallbackPath, - SameSite = SameSiteMode.None, - Secure = Request.IsHttps - }; - - Options.ConfigureCorrelationIdCookie?.Invoke(Context, cookieOptions); + var cookieOptions = Options.CorrelationCookie.Build(Context, Clock.UtcNow); Response.Cookies.Delete(cookieName, cookieOptions); diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index a5f0bb44b4..3b34cf43e9 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -3,6 +3,7 @@ using System; using System.Net.Http; +using Microsoft.AspNetCore.Authentication.Internal; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; @@ -13,6 +14,24 @@ namespace Microsoft.AspNetCore.Authentication /// public class RemoteAuthenticationOptions : AuthenticationSchemeOptions { + private const string CorrelationPrefix = ".AspNetCore.Correlation."; + + private CookieBuilder _correlationCookieBuilder; + + /// + /// Initializes a new . + /// + public RemoteAuthenticationOptions() + { + _correlationCookieBuilder = new CorrelationCookieBuilder(this) + { + Name = CorrelationPrefix, + HttpOnly = true, + SameSite = SameSiteMode.None, + SecurePolicy = CookieSecurePolicy.SameAsRequest, + }; + } + /// /// Check that the options are valid. Should throw an exception if things are not ok. /// @@ -71,8 +90,8 @@ namespace Microsoft.AspNetCore.Authentication public new RemoteAuthenticationEvents Events { - get { return (RemoteAuthenticationEvents)base.Events; } - set { base.Events = value; } + get => (RemoteAuthenticationEvents)base.Events; + set => base.Events = value; } /// @@ -84,9 +103,37 @@ namespace Microsoft.AspNetCore.Authentication public bool SaveTokens { get; set; } /// - /// Gets or sets an action that can override the correlation id cookie options before the + /// Determines the settings used to create the correlation cookie before the /// cookie gets added to the response. /// - public Action ConfigureCorrelationIdCookie { get; set; } + public CookieBuilder CorrelationCookie + { + get => _correlationCookieBuilder; + set => _correlationCookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); + } + + private class CorrelationCookieBuilder : RequestPathBaseCookieBuilder + { + private readonly RemoteAuthenticationOptions _options; + + public CorrelationCookieBuilder(RemoteAuthenticationOptions remoteAuthenticationOptions) + { + _options = remoteAuthenticationOptions; + } + + protected override string AdditionalPath => _options.CallbackPath; + + public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom) + { + var cookieOptions = base.Build(context, expiresFrom); + + if (!Expiration.HasValue || !cookieOptions.Expires.HasValue) + { + cookieOptions.Expires = expiresFrom.Add(_options.RemoteAuthenticationTimeout); + } + + return cookieOptions; + } + } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index bdd79533b1..62d11e52aa 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -190,7 +190,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth opt.AuthorizationEndpoint = "https://example.com/provider/login"; opt.TokenEndpoint = "https://example.com/provider/token"; opt.CallbackPath = "/oauth-callback"; - opt.ConfigureCorrelationIdCookie = (ctx, options) => options.Path = "/"; + opt.CorrelationCookie.Path = "/"; }), ctx => { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 7f9d42b1c9..b7ac1f82d5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { AuthorizationEndpoint = "https://example.com/provider/login" }; - opt.ConfigureNonceCookie = (ctx, options) => options.Path = "/"; + opt.NonceCookie.Path = "/"; }); var server = setting.CreateTestServer(); @@ -143,7 +143,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { AuthorizationEndpoint = "https://example.com/provider/login" }; - opt.ConfigureCorrelationIdCookie = (ctx, options) => options.Path = "/"; + opt.CorrelationCookie.Path = "/"; }); var server = setting.CreateTestServer(); From a7bf561b1c76aaee3d68c7448d780bc925ee283e Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 29 Jun 2017 17:24:23 -0700 Subject: [PATCH 756/900] Add CookieBuilder to CookieAuthenticationOptions and obsolete the duplicated properties --- Security.sln | 6 +- .../CookieAuthenticationHandler.cs | 39 ++-- .../CookieAuthenticationOptions.cs | 183 ++++++++++++------ ...t.AspNetCore.Authentication.Cookies.csproj | 4 + ...ostConfigureCookieAuthenticationOptions.cs | 4 +- .../Properties/Resources.Designer.cs | 62 ------ .../CookieTests.cs | 69 ++++--- .../CookiePolicyTests.cs | 12 +- 8 files changed, 188 insertions(+), 191 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs diff --git a/Security.sln b/Security.sln index 7c34ff0701..2e5ee56d00 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26507.0 +VisualStudioVersion = 15.0.26621.2 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -59,6 +59,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution build\common.props = build\common.props build\dependencies.props = build\dependencies.props build\Key.snk = build\Key.snk + NuGet.config = NuGet.config build\repo.props = build\repo.props EndProjectSection EndProject @@ -484,4 +485,7 @@ Global {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {58194599-F07D-47A3-9DF2-E21A22C5EF9E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ABF8089E-43D0-4010-84A7-7A9DCFE49357} + EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 4751c6f857..e093e87b78 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -14,9 +14,9 @@ using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Authentication.Cookies { - public class CookieAuthenticationHandler : - AuthenticationHandler, - IAuthenticationSignInHandler, + public class CookieAuthenticationHandler : + AuthenticationHandler, + IAuthenticationSignInHandler, IAuthenticationSignOutHandler { private const string HeaderValueNoCache = "no-cache"; @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { } /// - /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// protected new CookieAuthenticationEvents Events @@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies private async Task ReadCookieTicket() { - var cookie = Options.CookieManager.GetRequestCookie(Context, Options.CookieName); + var cookie = Options.CookieManager.GetRequestCookie(Context, Options.Cookie.Name); if (string.IsNullOrEmpty(cookie)) { return AuthenticateResult.NoResult(); @@ -176,22 +176,9 @@ namespace Microsoft.AspNetCore.Authentication.Cookies private CookieOptions BuildCookieOptions() { - var cookieOptions = new CookieOptions - { - Domain = Options.CookieDomain, - SameSite = Options.CookieSameSite, - HttpOnly = Options.CookieHttpOnly, - Path = Options.CookiePath ?? (OriginalPathBase.HasValue ? OriginalPathBase.ToString() : "/"), - }; - - if (Options.CookieSecure == CookieSecurePolicy.SameAsRequest) - { - cookieOptions.Secure = Request.IsHttps; - } - else - { - cookieOptions.Secure = Options.CookieSecure == CookieSecurePolicy.Always; - } + var cookieOptions = Options.Cookie.Build(Context); + // ignore the 'Expires' value as this will be computed elsewhere + cookieOptions.Expires = null; return cookieOptions; } @@ -239,7 +226,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Options.CookieManager.AppendResponseCookie( Context, - Options.CookieName, + Options.Cookie.Name, cookieValue, cookieOptions); @@ -283,14 +270,14 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (!signInContext.Properties.ExpiresUtc.HasValue) { - signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.ExpireTimeSpan); + signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.Cookie.Expiration ?? default(TimeSpan)); } await Events.SigningIn(signInContext); if (signInContext.Properties.IsPersistent) { - var expiresUtc = signInContext.Properties.ExpiresUtc ?? issuedUtc.Add(Options.ExpireTimeSpan); + var expiresUtc = signInContext.Properties.ExpiresUtc ?? issuedUtc.Add(Options.Cookie.Expiration ?? default(TimeSpan)); signInContext.CookieOptions.Expires = expiresUtc.ToUniversalTime(); } @@ -314,7 +301,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Options.CookieManager.AppendResponseCookie( Context, - Options.CookieName, + Options.Cookie.Name, cookieValue, signInContext.CookieOptions); @@ -359,7 +346,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Options.CookieManager.DeleteCookie( Context, - Options.CookieName, + Options.Cookie.Name, context.CookieOptions); // Only redirect on the logout path diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 01a5ae9c9d..4f8b201ad3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication.Internal; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; @@ -12,7 +13,16 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// public class CookieAuthenticationOptions : AuthenticationSchemeOptions { - private string _cookieName; + private CookieBuilder _cookieBuilder = new RequestPathBaseCookieBuilder + { + // the default name is configured in PostConfigureCookieAuthenticationOptions + + // To support OAuth authentication, a lax mode is required, see https://github.com/aspnet/Security/issues/1231. + SameSite = SameSiteMode.Lax, + HttpOnly = true, + SecurePolicy = CookieSecurePolicy.SameAsRequest, + Expiration = TimeSpan.FromDays(14), + }; /// /// Create an instance of the options initialized with the default values @@ -20,77 +30,52 @@ namespace Microsoft.AspNetCore.Authentication.Cookies public CookieAuthenticationOptions() { ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; - ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; - // To support OAuth authentication, a lax mode is required, see https://github.com/aspnet/Security/issues/1231. - CookieSameSite = SameSiteMode.Lax; - CookieHttpOnly = true; - CookieSecure = CookieSecurePolicy.SameAsRequest; Events = new CookieAuthenticationEvents(); } /// - /// Determines the cookie name used to persist the identity. The default value is ".AspNetCore.Cookies". + /// + /// Determines the settings used to create the cookie. + /// + /// + /// defaults to . + /// defaults to true. + /// defaults to . + /// defaults to 14 days. + /// + /// + /// + /// + /// The default value for cookie name is ".AspNetCore.Cookies". /// This value should be changed if you change the name of the AuthenticationScheme, especially if your /// system uses the cookie authentication handler multiple times. - /// - public string CookieName + /// + /// + /// determines if the browser should allow the cookie to be attached to same-site or cross-site requests. + /// The default is Lax, which means the cookie is only allowed to be attached to cross-site requests using safe HTTP methods and same-site requests. + /// + /// + /// determines if the browser should allow the cookie to be accessed by client-side javascript. + /// The default is true, which means the cookie will only be passed to http requests and is not made available to script on the page. + /// + /// + /// controls how much time the cookie will remain valid from the point it is created. The expiration + /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored + /// even if it is passed to the server after the browser should have purged it + /// + /// + public CookieBuilder Cookie { - get { return _cookieName; } - set - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - - _cookieName = value; - } + get => _cookieBuilder; + set => _cookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); } - /// - /// Determines the domain used to create the cookie. Is not provided by default. - /// - public string CookieDomain { get; set; } - - /// - /// Determines the path used to create the cookie. The default value is "/" for highest browser compatibility. - /// - public string CookiePath { get; set; } - - /// - /// Determines if the browser should allow the cookie to be attached to same-site or cross-site requests. The - /// default is Lax, which means the cookie is only allowed to be attached to cross-site requests using safe - /// HTTP methods and same-site requests. - /// - public SameSiteMode CookieSameSite { get; set; } - - /// - /// Determines if the browser should allow the cookie to be accessed by client-side javascript. The - /// default is true, which means the cookie will only be passed to http requests and is not made available - /// to script on the page. - /// - public bool CookieHttpOnly { get; set; } - - /// - /// Determines if the cookie should only be transmitted on HTTPS request. The default is to limit the cookie - /// to HTTPS requests if the page which is doing the SignIn is also HTTPS. If you have an HTTPS sign in page - /// and portions of your site are HTTP you may need to change this value. - /// - public CookieSecurePolicy CookieSecure { get; set; } - /// /// If set this will be used by the CookieAuthenticationHandler for data protection. /// public IDataProtectionProvider DataProtectionProvider { get; set; } - /// - /// Controls how much time the cookie will remain valid from the point it is created. The expiration - /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored - /// even if it is passed to the server after the browser should have purged it - /// - public TimeSpan ExpireTimeSpan { get; set; } - /// /// The SlidingExpiration is set to true to instruct the handler to re-issue a new cookie with a new /// expiration time any time it processes a request which is more than halfway through the expiration window. @@ -132,8 +117,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// public new CookieAuthenticationEvents Events { - get { return (CookieAuthenticationEvents)base.Events; } - set { base.Events = value; } + get => (CookieAuthenticationEvents)base.Events; + set => base.Events = value; } /// @@ -154,5 +139,85 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// to the client. This can be used to mitigate potential problems with very large identities. /// public ITicketStore SessionStore { get; set; } + + #region Obsolete API + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Determines the cookie name used to persist the identity. The default value is ".AspNetCore.Cookies". + /// This value should be changed if you change the name of the AuthenticationScheme, especially if your + /// system uses the cookie authentication handler multiple times. + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Domain) + ".")] + public string CookieName { get => Cookie.Name; set => Cookie.Name = value; } + + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Determines the domain used to create the cookie. Is not provided by default. + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Domain) + ".")] + public string CookieDomain { get => Cookie.Domain; set => Cookie.Domain = value; } + + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Determines the path used to create the cookie. The default value is "/" for highest browser compatibility. + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Path) + ".")] + public string CookiePath { get => Cookie.Path; set => Cookie.Path = value; } + + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Determines if the browser should allow the cookie to be accessed by client-side javascript. The + /// default is true, which means the cookie will only be passed to http requests and is not made available + /// to script on the page. + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.SameSite) + ".")] + public bool CookieHttpOnly { get => Cookie.HttpOnly; set => Cookie.HttpOnly = value; } + + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Determines if the cookie should only be transmitted on HTTPS request. The default is to limit the cookie + /// to HTTPS requests if the page which is doing the SignIn is also HTTPS. If you have an HTTPS sign in page + /// and portions of your site are HTTP you may need to change this value. + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.SecurePolicy) + ".")] + public CookieSecurePolicy CookieSecure { get => Cookie.SecurePolicy; set => Cookie.SecurePolicy = value; } + + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Controls how much time the cookie will remain valid from the point it is created. The expiration + /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored + /// even if it is passed to the server after the browser should have purged it + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Expiration) + ".")] + public TimeSpan ExpireTimeSpan + { + get => Cookie.Expiration ?? default(TimeSpan); + set => Cookie.Expiration = value; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 712aa81772..fb20a55b9f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -19,4 +19,8 @@ + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs index e6a62d1b68..48895072e9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs @@ -28,9 +28,9 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; - if (String.IsNullOrEmpty(options.CookieName)) + if (string.IsNullOrEmpty(options.Cookie.Name)) { - options.CookieName = CookieAuthenticationDefaults.CookiePrefix + name; + options.Cookie.Name = CookieAuthenticationDefaults.CookiePrefix + name; } if (options.TicketDataFormat == null) { diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs deleted file mode 100644 index e2719f39d2..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -namespace Microsoft.AspNetCore.Authentication.Cookies -{ - using System.Globalization; - using System.Reflection; - using System.Resources; - - internal static class Resources - { - private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNetCore.Authentication.Cookies.Resources", typeof(Resources).GetTypeInfo().Assembly); - - /// - /// The cookie key and options are larger than ChunksSize, leaving no room for data. - /// - internal static string Exception_CookieLimitTooSmall - { - get { return GetString("Exception_CookieLimitTooSmall"); } - } - - /// - /// The cookie key and options are larger than ChunksSize, leaving no room for data. - /// - internal static string FormatException_CookieLimitTooSmall() - { - return GetString("Exception_CookieLimitTooSmall"); - } - - /// - /// The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded. - /// - internal static string Exception_ImcompleteChunkedCookie - { - get { return GetString("Exception_ImcompleteChunkedCookie"); } - } - - /// - /// The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded. - /// - internal static string FormatException_ImcompleteChunkedCookie(object p0, object p1, object p2) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_ImcompleteChunkedCookie"), p0, p1, p2); - } - - private static string GetString(string name, params string[] formatterNames) - { - var value = _resourceManager.GetString(name); - - System.Diagnostics.Debug.Assert(value != null); - - if (formatterNames != null) - { - for (var i = 0; i < formatterNames.Length; i++) - { - value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); - } - } - - return value; - } - } -} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 7dade96eec..1471caf440 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -18,7 +18,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Xunit; namespace Microsoft.AspNetCore.Authentication.Cookies @@ -129,7 +128,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var server = CreateServerWithServices(s => s.AddAuthentication().AddCookie(o => { o.LoginPath = new PathString("/login"); - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }), SignInAsAlice); var transaction = await SendAsync(server, "http://example.com/testpath"); @@ -150,7 +149,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var server = CreateServer(o => { o.LoginPath = new PathString("/login"); - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, SignInAsWrong); await Assert.ThrowsAsync(async () => await SendAsync(server, "http://example.com/testpath")); @@ -162,7 +161,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var server = CreateServer(o => { o.LoginPath = new PathString("/login"); - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, SignOutAsWrong); await Assert.ThrowsAsync(async () => await SendAsync(server, "http://example.com/testpath")); @@ -183,8 +182,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var server = CreateServer(o => { o.LoginPath = new PathString("/login"); - o.CookieName = "TestCookie"; - o.CookieSecure = cookieSecurePolicy; + o.Cookie.Name = "TestCookie"; + o.Cookie.SecurePolicy = cookieSecurePolicy; }, SignInAsAlice); var transaction = await SendAsync(server, requestUri); @@ -205,12 +204,12 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server1 = CreateServer(o => { - o.CookieName = "TestCookie"; - o.CookiePath = "/foo"; - o.CookieDomain = "another.com"; - o.CookieSecure = CookieSecurePolicy.Always; - o.CookieSameSite = SameSiteMode.None; - o.CookieHttpOnly = true; + o.Cookie.Name = "TestCookie"; + o.Cookie.Path = "/foo"; + o.Cookie.Domain = "another.com"; + o.Cookie.SecurePolicy = CookieSecurePolicy.Always; + o.Cookie.SameSite = SameSiteMode.None; + o.Cookie.HttpOnly = true; }, SignInAsAlice, baseAddress: new Uri("http://example.com/base")); var transaction1 = await SendAsync(server1, "http://example.com/base/testpath"); @@ -226,10 +225,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var server2 = CreateServer(o => { - o.CookieName = "SecondCookie"; - o.CookieSecure = CookieSecurePolicy.None; - o.CookieSameSite = SameSiteMode.Strict; - o.CookieHttpOnly = false; + o.Cookie.Name = "SecondCookie"; + o.Cookie.SecurePolicy = CookieSecurePolicy.None; + o.Cookie.SameSite = SameSiteMode.Strict; + o.Cookie.HttpOnly = false; }, SignInAsAlice, baseAddress: new Uri("http://example.com/base")); var transaction2 = await SendAsync(server2, "http://example.com/base/testpath"); @@ -278,7 +277,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, SignInAsAlice); @@ -307,7 +306,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, context => @@ -340,7 +339,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => @@ -368,7 +367,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -396,7 +395,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -432,7 +431,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -477,7 +476,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => @@ -521,7 +520,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -570,7 +569,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies DateTimeOffset? lastExpiresDate = null; var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = sliding; o.Events = new CookieAuthenticationEvents { @@ -620,7 +619,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents() { @@ -657,7 +656,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = true; }, SignInAsAlice); @@ -825,7 +824,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { services.AddAuthentication().AddCookie(); services.Configure(CookieAuthenticationDefaults.AuthenticationScheme, - o => o.CookieName = "One"); + o => o.Cookie.Name = "One"); }); var server = new TestServer(builder); @@ -848,7 +847,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { services.AddAuthentication().AddCookie("Cookie1"); services.Configure("Cookie1", - o => o.CookieName = "One"); + o => o.Cookie.Name = "One"); }); var server = new TestServer(builder); @@ -984,7 +983,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var server = CreateServer(o => { o.LoginPath = "/testpath"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => await context.SignInAsync( @@ -1006,7 +1005,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { o.LoginPath = "/testpath"; o.ReturnUrlParameter = "return"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => { @@ -1028,7 +1027,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { o.LoginPath = "/testpath"; o.ReturnUrlParameter = "return"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => { @@ -1049,7 +1048,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { o.LoginPath = "/testpath"; o.ReturnUrlParameter = "return"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => { @@ -1102,7 +1101,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies .ConfigureServices(services => services.AddAuthentication().AddCookie(o => { o.TicketDataFormat = new TicketDataFormat(dp); - o.CookieName = "Cookie"; + o.Cookie.Name = "Cookie"; })); var server1 = new TestServer(builder1); @@ -1121,7 +1120,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies }) .ConfigureServices(services => services.AddAuthentication().AddCookie("Cookies", o => { - o.CookieName = "Cookie"; + o.Cookie.Name = "Cookie"; o.TicketDataFormat = new TicketDataFormat(dp); })); var server2 = new TestServer(builder2); diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index 5c2458c529..49089234ee 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -314,9 +314,9 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test { services.AddAuthentication().AddCookie(o => { - o.CookieName = "TestCookie"; - o.CookieHttpOnly = false; - o.CookieSecure = CookieSecurePolicy.None; + o.Cookie.Name = "TestCookie"; + o.Cookie.HttpOnly = false; + o.Cookie.SecurePolicy = CookieSecurePolicy.None; }); }) .Configure(app => @@ -354,9 +354,9 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test { services.AddAuthentication().AddCookie(o => { - o.CookieName = "TestCookie"; - o.CookieHttpOnly = false; - o.CookieSecure = CookieSecurePolicy.None; + o.Cookie.Name = "TestCookie"; + o.Cookie.HttpOnly = false; + o.Cookie.SecurePolicy = CookieSecurePolicy.None; }); }) .Configure(app => From 1c30f33c925a97b105b3f9d34497218b0c9342b6 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 3 Jul 2017 12:56:39 -0700 Subject: [PATCH 757/900] Remove AddXyzAuth extension methods --- .../CookieExtensions.cs | 15 --------------- .../FacebookExtensions.cs | 11 ----------- .../GoogleExtensions.cs | 12 ------------ .../JwtBearerExtensions.cs | 14 -------------- .../MicrosoftAccountExtensions.cs | 12 ------------ .../OAuthExtensions.cs | 14 -------------- .../OpenIdConnectExtensions.cs | 13 ------------- .../TwitterExtensions.cs | 13 ------------- .../AuthenticationMiddleware.cs | 2 -- .../FacebookTests.cs | 10 ++++------ .../GoogleTests.cs | 3 ++- .../JwtBearerTests.cs | 5 +++-- .../MicrosoftAccountTests.cs | 3 ++- .../OAuthTests.cs | 17 +++++++++-------- .../TwitterTests.cs | 4 ++-- 15 files changed, 22 insertions(+), 126 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index 67c4416ebb..61f72e361f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -25,20 +25,5 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); return builder.AddScheme(authenticationScheme, configureOptions); } - - - // REMOVE below once callers have been updated - public static IServiceCollection AddCookieAuthentication(this IServiceCollection services) => services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme); - - public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme) => services.AddCookieAuthentication(authenticationScheme, configureOptions: null); - - public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, Action configureOptions) => - services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); - return services.AddScheme(authenticationScheme, configureOptions); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index e4dcbfee8b..1cb1ef03eb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -17,16 +17,5 @@ namespace Microsoft.Extensions.DependencyInjection public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) => builder.AddOAuth(authenticationScheme, configureOptions); - - - // REMOVE below once callers have been updated - public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services) - => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index ee42c5564c..7bb9b7bebd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -17,17 +17,5 @@ namespace Microsoft.Extensions.DependencyInjection public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) => builder.AddOAuth(authenticationScheme, configureOptions); - - - // REMOVE below once callers have been updated - - public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services) - => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 4f051bd39a..698c0118e0 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -22,19 +22,5 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); return builder.AddScheme(authenticationScheme, configureOptions); } - - - // REMOVE once callers updated - public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services) - => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); - return services.AddScheme(authenticationScheme, configureOptions); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 9a53fd7700..8da6daaac8 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -17,17 +17,5 @@ namespace Microsoft.Extensions.DependencyInjection public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) => builder.AddOAuth(authenticationScheme, configureOptions); - - - // REMOVE below once callers have been updated - - public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services) - => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 5720d8e4f4..8c9d34c5f9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -21,19 +21,5 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } - - // REMOVE below once callers have been updated - public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - return services.AddOAuthAuthentication>(authenticationScheme, configureOptions); - } - - public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - where TOptions : OAuthOptions, new() - where THandler : OAuthHandler - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); - return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index 7ba262bf39..43059b3ffe 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -22,18 +22,5 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } - - // REMOVE once callers have been updated - public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services) - => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); - return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index e49244920e..bd0a3b1e20 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -22,18 +22,5 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } - - // REMOVE below once callers have been updated. - public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services) - => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); - return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs index eba561d1da..0c62cc3c39 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs @@ -37,8 +37,6 @@ namespace Microsoft.AspNetCore.Authentication OriginalPathBase = context.Request.PathBase }); - // REVIEW: alternatively could depend on a routing middleware to do this - // Give any IAuthenticationRequestHandler schemes a chance to handle the request var handlers = context.RequestServices.GetRequiredService(); foreach (var scheme in await Schemes.GetRequestHandlerSchemesAsync()) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index e6b5574df1..43c52b0fd9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; @@ -16,10 +15,8 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; using Newtonsoft.Json; using Xunit; @@ -30,7 +27,8 @@ namespace Microsoft.AspNetCore.Authentication.Facebook [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddFacebookAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var services = new ServiceCollection(); + services.AddAuthentication().AddFacebook(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(FacebookDefaults.AuthenticationScheme); @@ -44,7 +42,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { var server = CreateServer( app => { }, - services => services.AddFacebookAuthentication(o => o.SignInScheme = "Whatever"), + services => services.AddAuthentication().AddFacebook(o => o.SignInScheme = "Whatever"), context => { // REVIEW: Gross. @@ -60,7 +58,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { var server = CreateServer( app => { }, - services => services.AddFacebookAuthentication(o => o.AppId = "Whatever"), + services => services.AddAuthentication().AddFacebook(o => o.AppId = "Whatever"), context => { // REVIEW: Gross. diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 2eae266702..3bfea45df8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -29,7 +29,8 @@ namespace Microsoft.AspNetCore.Authentication.Google [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddGoogleAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var services = new ServiceCollection(); + services.AddAuthentication().AddGoogle(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(GoogleDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index a9b158d2b0..c7153ded30 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -29,7 +29,8 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddJwtBearerAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var services = new ServiceCollection(); + services.AddAuthentication().AddJwtBearer(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(JwtBearerDefaults.AuthenticationScheme); @@ -747,7 +748,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } }); }) - .ConfigureServices(services => services.AddJwtBearerAuthentication(options)); + .ConfigureServices(services => services.AddAuthentication().AddJwtBearer(options)); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index f516940432..941dd13481 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -30,7 +30,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddMicrosoftAccountAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var services = new ServiceCollection(); + services.AddAuthentication().AddMicrosoftAccount(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(MicrosoftAccountDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 62d11e52aa..ea0c941c91 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -19,7 +19,8 @@ namespace Microsoft.AspNetCore.Authentication.OAuth [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddOAuthAuthentication("oauth", o => { }); + var services = new ServiceCollection(); + services.AddAuthentication().AddOAuth("oauth", o => { }); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync("oauth"); @@ -33,7 +34,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "whatever"; o.CallbackPath = "/"; @@ -56,7 +57,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "whatever"; o.ClientId = "Whatever;"; @@ -79,7 +80,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; o.ClientSecret = "Whatever;"; @@ -102,7 +103,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; o.ClientSecret = "Whatever;"; @@ -125,7 +126,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; o.ClientSecret = "Whatever;"; @@ -148,7 +149,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { var server = CreateServer( app => { }, - s => s.AddOAuthAuthentication( + s => s.AddAuthentication().AddOAuth( "Weblie", opt => { @@ -180,7 +181,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { var server = CreateServer( app => { }, - s => s.AddOAuthAuthentication( + s => s.AddAuthentication().AddOAuth( "Weblie", opt => { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 76f6b1aad9..1c387d889a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -21,7 +20,8 @@ namespace Microsoft.AspNetCore.Authentication.Twitter [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddTwitterAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var services = new ServiceCollection(); + services.AddAuthentication().AddTwitter(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(TwitterDefaults.AuthenticationScheme); From 658f4621b17e14e5eba007c83426764d1fd8a5a6 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 28 Jun 2017 10:50:52 -0700 Subject: [PATCH 758/900] #1208 Clean up JWT and OIDC issuer handling --- .../JwtBearerHandler.cs | 14 ++++---------- .../OpenIdConnectHandler.cs | 13 ++++--------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 999d323e11..1cb1ea4496 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -90,17 +90,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer var validationParameters = Options.TokenValidationParameters.Clone(); if (_configuration != null) { - if (validationParameters.ValidIssuer == null && !string.IsNullOrEmpty(_configuration.Issuer)) - { - validationParameters.ValidIssuer = _configuration.Issuer; - } - else - { - var issuers = new[] { _configuration.Issuer }; - validationParameters.ValidIssuers = (validationParameters.ValidIssuers == null ? issuers : validationParameters.ValidIssuers.Concat(issuers)); - } + var issuers = new[] { _configuration.Issuer }; + validationParameters.ValidIssuers = validationParameters.ValidIssuers?.Concat(issuers) ?? issuers; - validationParameters.IssuerSigningKeys = (validationParameters.IssuerSigningKeys == null ? _configuration.SigningKeys : validationParameters.IssuerSigningKeys.Concat(_configuration.SigningKeys)); + validationParameters.IssuerSigningKeys = validationParameters.IssuerSigningKeys?.Concat(_configuration.SigningKeys) + ?? _configuration.SigningKeys; } List validationFailures = null; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 9e6d34bc98..068593837b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -1137,16 +1137,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect if (_configuration != null) { - if (string.IsNullOrEmpty(validationParameters.ValidIssuer)) - { - validationParameters.ValidIssuer = _configuration.Issuer; - } - else if (!string.IsNullOrEmpty(_configuration.Issuer)) - { - validationParameters.ValidIssuers = validationParameters.ValidIssuers?.Concat(new[] { _configuration.Issuer }) ?? new[] { _configuration.Issuer }; - } + var issuer = new[] { _configuration.Issuer }; + validationParameters.ValidIssuers = validationParameters.ValidIssuers?.Concat(issuer) ?? issuer; - validationParameters.IssuerSigningKeys = validationParameters.IssuerSigningKeys?.Concat(_configuration.SigningKeys) ?? _configuration.SigningKeys; + validationParameters.IssuerSigningKeys = validationParameters.IssuerSigningKeys?.Concat(_configuration.SigningKeys) + ?? _configuration.SigningKeys; } var principal = Options.SecurityTokenValidator.ValidateToken(idToken, validationParameters, out SecurityToken validatedToken); From bd19ba9533cfd3ffd81e4ef2c874109e8b3dbccd Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 5 Jul 2017 15:43:43 -0700 Subject: [PATCH 759/900] Revert obsoleting CookieAuthenticationOptions.ExpireTimeSpan (#1296) - Revert the obsoleting of CookieAuthenticationOptions.ExpireTimeSpan in aspnet/Security#1285 - Add test to ensure Cookie.Expiration is ignored --- .../CookieAuthenticationHandler.cs | 4 +- .../CookieAuthenticationOptions.cs | 37 +++++++----------- ...t.AspNetCore.Authentication.Cookies.csproj | 4 -- .../CookieTests.cs | 39 +++++++++++++------ 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index e093e87b78..f411997520 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -270,14 +270,14 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (!signInContext.Properties.ExpiresUtc.HasValue) { - signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.Cookie.Expiration ?? default(TimeSpan)); + signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.ExpireTimeSpan); } await Events.SigningIn(signInContext); if (signInContext.Properties.IsPersistent) { - var expiresUtc = signInContext.Properties.ExpiresUtc ?? issuedUtc.Add(Options.Cookie.Expiration ?? default(TimeSpan)); + var expiresUtc = signInContext.Properties.ExpiresUtc ?? issuedUtc.Add(Options.ExpireTimeSpan); signInContext.CookieOptions.Expires = expiresUtc.ToUniversalTime(); } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 4f8b201ad3..ec67ecc181 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -21,7 +21,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies SameSite = SameSiteMode.Lax, HttpOnly = true, SecurePolicy = CookieSecurePolicy.SameAsRequest, - Expiration = TimeSpan.FromDays(14), }; /// @@ -29,6 +28,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// public CookieAuthenticationOptions() { + ExpireTimeSpan = TimeSpan.FromDays(14); ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; SlidingExpiration = true; Events = new CookieAuthenticationEvents(); @@ -42,7 +42,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// defaults to . /// defaults to true. /// defaults to . - /// defaults to 14 days. /// /// /// @@ -60,9 +59,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// The default is true, which means the cookie will only be passed to http requests and is not made available to script on the page. /// /// - /// controls how much time the cookie will remain valid from the point it is created. The expiration - /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored - /// even if it is passed to the server after the browser should have purged it + /// is currently ignored. Use to control lifetime of cookie authentication. /// /// public CookieBuilder Cookie @@ -140,6 +137,19 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// public ITicketStore SessionStore { get; set; } + /// + /// + /// Controls how much time the authentication ticket stored in the cookie will remain valid from the point it is created + /// The expiration information is stored in the protected cookie ticket. Because of that an expired cookie will be ignored + /// even if it is passed to the server after the browser should have purged it. + /// + /// + /// This is separate from the value of , which specifies + /// how long the browser will keep the cookie. + /// + /// + public TimeSpan ExpireTimeSpan { get; set; } + #region Obsolete API /// /// @@ -201,23 +211,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.SecurePolicy) + ".")] public CookieSecurePolicy CookieSecure { get => Cookie.SecurePolicy; set => Cookie.SecurePolicy = value; } - - /// - /// - /// This property is obsolete and will be removed in a future version. The recommended alternative is on . - /// - /// - /// Controls how much time the cookie will remain valid from the point it is created. The expiration - /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored - /// even if it is passed to the server after the browser should have purged it - /// - /// - [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Expiration) + ".")] - public TimeSpan ExpireTimeSpan - { - get => Cookie.Expiration ?? default(TimeSpan); - set => Cookie.Expiration = value; - } #endregion } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index fb20a55b9f..712aa81772 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 1471caf440..c2d843bf10 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -143,6 +143,23 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.DoesNotContain("; secure", setCookie); } + [Fact] + public async Task CookieExpirationOptionIsIgnored() + { + var server = CreateServerWithServices(s => s.AddAuthentication().AddCookie(o => + { + o.Cookie.Name = "TestCookie"; + // this is currently ignored. Users should set o.ExpireTimeSpan instead + o.Cookie.Expiration = TimeSpan.FromDays(10); + }), SignInAsAlice); + + var transaction = await SendAsync(server, "http://example.com/testpath"); + + var setCookie = transaction.SetCookie; + Assert.StartsWith("TestCookie=", setCookie); + Assert.DoesNotContain("; expires=", setCookie); + } + [Fact] public async Task SignInWrongAuthTypeThrows() { @@ -277,7 +294,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, SignInAsAlice); @@ -306,7 +323,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, context => @@ -339,7 +356,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => @@ -367,7 +384,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -395,7 +412,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -431,7 +448,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -476,7 +493,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => @@ -520,7 +537,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -569,7 +586,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies DateTimeOffset? lastExpiresDate = null; var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = sliding; o.Events = new CookieAuthenticationEvents { @@ -619,7 +636,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents() { @@ -656,7 +673,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = true; }, SignInAsAlice); From fd502195a4320150a1d328e9b6d055dd3a9b419f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 6 Jul 2017 10:39:16 -0700 Subject: [PATCH 760/900] React to aspnet/BuildTools#293 [ci skip] --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index f00799700a..44605092cc 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 4.4.0-* 3.13.9 2.1.3 - 2.1.0-* + 2.0.1-* 10.0.1 2.0.0-* 2.0.0-* From 23da47617624cfed065cd1cdd552d34e5ea5b821 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 6 Jul 2017 13:41:47 -0700 Subject: [PATCH 761/900] Switch to IOptionsMonitor (#1295) --- .../CookieAuthenticationHandler.cs | 2 +- .../FacebookHandler.cs | 2 +- .../GoogleHandler.cs | 2 +- .../JwtBearerHandler.cs | 2 +- .../MicrosoftAccountHandler.cs | 2 +- .../OAuthHandler.cs | 2 +- .../OpenIdConnectHandler.cs | 2 +- .../TwitterHandler.cs | 2 +- .../AuthenticationHandler.cs | 8 +-- .../RemoteAuthenticationHandler.cs | 2 +- .../DynamicSchemeTests.cs | 72 ++++++++++++++++--- 11 files changed, 76 insertions(+), 22 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index f411997520..996c334a73 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies private string _sessionKey; private Task _readCookieTask; - public CookieAuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public CookieAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 8a1f29bbe5..9004fc09cd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { internal class FacebookHandler : OAuthHandler { - public FacebookHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public FacebookHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index aa5e596494..7a2e1a2d14 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { internal class GoogleHandler : OAuthHandler { - public GoogleHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public GoogleHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 1cb1ea4496..9cf73182ba 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { private OpenIdConnectConfiguration _configuration; - public JwtBearerHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + public JwtBearerHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 45fae3d0ea..8204bf07b9 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { internal class MicrosoftAccountHandler : OAuthHandler { - public MicrosoftAccountHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public MicrosoftAccountHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index b61d575375..007d7dbefd 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth set { base.Events = value; } } - public OAuthHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public OAuthHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 068593837b..65e1e1951e 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect protected HtmlEncoder HtmlEncoder { get; } - public OpenIdConnectHandler(IOptionsSnapshot options, ILoggerFactory logger, HtmlEncoder htmlEncoder, UrlEncoder encoder, ISystemClock clock) + public OpenIdConnectHandler(IOptionsMonitor options, ILoggerFactory logger, HtmlEncoder htmlEncoder, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { HtmlEncoder = htmlEncoder; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index ddcd095d5b..1e1dd08d87 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter set { base.Events = value; } } - public TwitterHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public TwitterHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index a258d0acaf..d1d09f0746 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Authentication protected ISystemClock Clock { get; } - protected IOptionsSnapshot OptionsSnapshot { get; } + protected IOptionsMonitor OptionsMonitor { get; } /// /// The handler calls methods on the events which give the application control at certain points where processing is occurring. @@ -58,12 +58,12 @@ namespace Microsoft.AspNetCore.Authentication } } - protected AuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + protected AuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) { Logger = logger.CreateLogger(this.GetType().FullName); UrlEncoder = encoder; Clock = clock; - OptionsSnapshot = options; + OptionsMonitor = options; } /// @@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.Authentication Scheme = scheme; Context = context; - Options = OptionsSnapshot.Get(Scheme.Name) ?? new TOptions(); + Options = OptionsMonitor.Get(Scheme.Name) ?? new TOptions(); Options.Validate(); await InitializeEventsAsync(); diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 7bd3b07731..bcd5983642 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Authentication set { base.Events = value; } } - protected RemoteAuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + protected RemoteAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } protected override Task CreateEventsAsync() diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs index d239d85f81..fe7443679c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs @@ -18,6 +18,42 @@ namespace Microsoft.AspNetCore.Authentication { public class DynamicSchemeTests { + [Fact] + public async Task OptionsAreConfiguredOnce() + { + var server = CreateServer(s => + { + s.Configure("One", o => o.Instance = new Singleton()); + s.Configure("Two", o => o.Instance = new Singleton()); + }); + // Add One scheme + var response = await server.CreateClient().GetAsync("http://example.com/add/One"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + var transaction = await server.SendAsync("http://example.com/auth/One"); + Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); + Assert.Equal("1", transaction.FindClaimValue("Count")); + + // Verify option is not recreated + transaction = await server.SendAsync("http://example.com/auth/One"); + Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); + Assert.Equal("1", transaction.FindClaimValue("Count")); + + // Add Two scheme + response = await server.CreateClient().GetAsync("http://example.com/add/Two"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + transaction = await server.SendAsync("http://example.com/auth/Two"); + Assert.Equal("Two", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "Two")); + Assert.Equal("2", transaction.FindClaimValue("Count")); + + // Verify options are not recreated + transaction = await server.SendAsync("http://example.com/auth/One"); + Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); + Assert.Equal("1", transaction.FindClaimValue("Count")); + transaction = await server.SendAsync("http://example.com/auth/Two"); + Assert.Equal("Two", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "Two")); + Assert.Equal("2", transaction.FindClaimValue("Count")); + } + [Fact] public async Task CanAddAndRemoveSchemes() { @@ -48,7 +84,6 @@ namespace Microsoft.AspNetCore.Authentication Assert.Equal(HttpStatusCode.OK, response.StatusCode); await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/Two")); await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/One")); - } [Fact] @@ -69,9 +104,27 @@ namespace Microsoft.AspNetCore.Authentication await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth")); } - private class TestHandler : AuthenticationHandler + public class TestOptions : AuthenticationSchemeOptions { - public TestHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + public Singleton Instance { get; set; } + } + + public class Singleton + { + public static int _count; + + public Singleton() + { + _count++; + Count = _count; + } + + public int Count { get; } + } + + private class TestHandler : AuthenticationHandler + { + public TestHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } @@ -80,12 +133,16 @@ namespace Microsoft.AspNetCore.Authentication var principal = new ClaimsPrincipal(); var id = new ClaimsIdentity(); id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + if (Options.Instance != null) + { + id.AddClaim(new Claim("Count", Options.Instance.Count.ToString())); + } principal.AddIdentity(id); return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); } } - private static TestServer CreateServer(Action configureAuth = null) + private static TestServer CreateServer(Action configureServices = null) { var builder = new WebHostBuilder() .Configure(app => @@ -122,11 +179,8 @@ namespace Microsoft.AspNetCore.Authentication }) .ConfigureServices(services => { - if (configureAuth == null) - { - configureAuth = o => { }; - } - services.AddAuthentication(configureAuth); + configureServices?.Invoke(services); + services.AddAuthentication(); }); return new TestServer(builder); } From 184ccb8f4a83b21eab0812ccc84714f14aaf0092 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 6 Jul 2017 12:26:50 -0700 Subject: [PATCH 762/900] Set "TreatWarningsAsErrors" before NuGet restore * Ensures our build stays clean of NuGet warnings --- build/common.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.props b/build/common.props index dc4ad9a786..1555ad6383 100644 --- a/build/common.props +++ b/build/common.props @@ -10,6 +10,7 @@ true true $(VersionSuffix)-$(BuildNumber) + true From bfe067432567f25f148149b78f90a0a5c1d9a5fb Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 6 Jul 2017 15:08:51 -0700 Subject: [PATCH 763/900] Update version suffix for 2.0.0 RTM release --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 90a2f5b5cc..b94223e008 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview3 + rtm \ No newline at end of file From d433f034fab3daea2cfd5e2661bd1512cd0d2efc Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 6 Jul 2017 15:44:03 -0700 Subject: [PATCH 764/900] Remove NETStandard.Library.NETFramework --- build/common.props | 4 ---- samples/CookieSample/CookieSample.csproj | 4 ---- samples/CookieSessionSample/CookieSessionSample.csproj | 4 ---- samples/JwtBearerSample/JwtBearerSample.csproj | 4 ---- .../OpenIdConnect.AzureAdSample.csproj | 4 ---- samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 4 ---- samples/SocialSample/SocialSample.csproj | 4 ---- 7 files changed, 28 deletions(-) diff --git a/build/common.props b/build/common.props index 1555ad6383..f7497c8f43 100644 --- a/build/common.props +++ b/build/common.props @@ -17,8 +17,4 @@ - - - - diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index d251b844e1..64438de77d 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index a2d0490f1a..cb07f4385b 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index c2f73fd961..fe2a5fa9d9 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -20,8 +20,4 @@ - - - - diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 7857249087..ece748d0dd 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -23,8 +23,4 @@ - - - - diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 03384f567e..9f62a06b50 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -33,8 +33,4 @@ - - - - diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 999dc91a6f..d35796f759 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -35,8 +35,4 @@ - - - - From 38d33cfbf2d639e22ea0316a50a72a642cc7196d Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 7 Jul 2017 11:28:41 -0700 Subject: [PATCH 765/900] Fix tests to work with new default --- .../CookieTests.cs | 2 +- .../DynamicSchemeTests.cs | 18 ------------------ .../FacebookTests.cs | 5 ++--- .../GoogleTests.cs | 2 +- .../JwtBearerTests.cs | 2 +- .../MicrosoftAccountTests.cs | 2 +- .../OpenIdConnect/TestServerBuilder.cs | 2 +- 7 files changed, 7 insertions(+), 26 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index c2d843bf10..83083cbf0a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -1247,7 +1247,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies => CreateServerWithServices(s => { s.AddSingleton(_clock); - s.AddAuthentication().AddCookie(configureOptions); + s.AddAuthentication(o => o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions); s.AddSingleton(); }, testpath, baseAddress); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs index fe7443679c..d658609b04 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs @@ -86,24 +86,6 @@ namespace Microsoft.AspNetCore.Authentication await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/One")); } - [Fact] - public async Task VerifyDefaultBehavior() - { - var server = CreateServer(); - - await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth")); - - var response = await server.CreateClient().GetAsync("http://example.com/add/One"); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - var transaction = await server.SendAsync("http://example.com/auth"); - Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); - response = await server.CreateClient().GetAsync("http://example.com/add/Two"); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - - // Default will blow up since now there's two - await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth")); - } - public class TestOptions : AuthenticationSchemeOptions { public Singleton Instance { get; set; } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 43c52b0fd9..35752ec6b0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -81,8 +81,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { services.AddAuthentication(options => { - options.DefaultSignInScheme = "External"; - options.DefaultAuthenticateScheme = "External"; + options.DefaultScheme = "External"; }) .AddCookie("External", o => { }) .AddFacebook(o => @@ -221,7 +220,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { services.AddAuthentication(options => { - options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; }) .AddCookie() .AddFacebook(o => diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 3bfea45df8..f1038bb51d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -1050,7 +1050,7 @@ namespace Microsoft.AspNetCore.Authentication.Google services.AddTransient(); services.AddAuthentication(o => { - o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme; + o.DefaultScheme = TestExtensions.CookieAuthenticationScheme; o.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme; }); services.AddAuthentication() diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index c7153ded30..e001bd9950 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -748,7 +748,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } }); }) - .ConfigureServices(services => services.AddAuthentication().AddJwtBearer(options)); + .ConfigureServices(services => services.AddAuthentication(o => o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options)); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 941dd13481..b63ad1f7d6 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { services.AddAuthentication(o => { - o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme; + o.DefaultScheme = TestExtensions.CookieAuthenticationScheme; }); services.AddAuthentication() .AddCookie(TestExtensions.CookieAuthenticationScheme, o => { }) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs index 1ffb9ff686..4d6a268217 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { services.AddAuthentication(o => { - o.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; }); services.AddAuthentication() .AddCookie() From df325deaf355f99239c1319932bc28eb3a837372 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 7 Jul 2017 12:04:32 -0700 Subject: [PATCH 766/900] Add AddAuthentication(defaultScheme) overload --- .../AuthenticationServiceCollectionExtensions.cs | 3 +++ .../CookieTests.cs | 2 +- .../FacebookTests.cs | 10 ++-------- .../JwtBearerTests.cs | 2 +- .../MicrosoftAccountTests.cs | 6 +----- .../OpenIdConnect/TestServerBuilder.cs | 6 +----- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 28291f4196..e1beea7b6e 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -27,6 +27,9 @@ namespace Microsoft.Extensions.DependencyInjection return new AuthenticationBuilder(services); } + public static AuthenticationBuilder AddAuthentication(this IServiceCollection services, string defaultScheme) + => services.AddAuthentication(o => o.DefaultScheme = defaultScheme); + public static AuthenticationBuilder AddAuthentication(this IServiceCollection services, Action configureOptions) { if (services == null) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 83083cbf0a..c711fde493 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -1247,7 +1247,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies => CreateServerWithServices(s => { s.AddSingleton(_clock); - s.AddAuthentication(o => o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions); + s.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions); s.AddSingleton(); }, testpath, baseAddress); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 35752ec6b0..75de0652e4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -79,10 +79,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook }, services => { - services.AddAuthentication(options => - { - options.DefaultScheme = "External"; - }) + services.AddAuthentication("External") .AddCookie("External", o => { }) .AddFacebook(o => { @@ -218,10 +215,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook app => app.UseAuthentication(), services => { - services.AddAuthentication(options => - { - options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }) + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie() .AddFacebook(o => { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index e001bd9950..97adb21054 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -748,7 +748,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } }); }) - .ConfigureServices(services => services.AddAuthentication(o => o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options)); + .ConfigureServices(services => services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options)); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index b63ad1f7d6..2e249a833a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -224,11 +224,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount }) .ConfigureServices(services => { - services.AddAuthentication(o => - { - o.DefaultScheme = TestExtensions.CookieAuthenticationScheme; - }); - services.AddAuthentication() + services.AddAuthentication(TestExtensions.CookieAuthenticationScheme) .AddCookie(TestExtensions.CookieAuthenticationScheme, o => { }) .AddMicrosoftAccount(configureOptions); }); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs index 4d6a268217..c37da8c043 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -109,11 +109,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect }) .ConfigureServices(services => { - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - services.AddAuthentication() + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie() .AddOpenIdConnect(options); }); From 979475fbf3461cd64607d9f5fa7987bd3279e04a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 10 Jul 2017 11:46:06 -0700 Subject: [PATCH 767/900] Branching for 2.0.0 rtm --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de1..37f0d27ea0 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,7 +2,7 @@ - + From 72bf2507d8829cdddf43ade87493497e8c1464e8 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 10 Jul 2017 11:58:01 -0700 Subject: [PATCH 768/900] Updating KoreBuild branch --- build.ps1 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..1785334385 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..5e27ed8efb 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From a894c38f7a8ec58d70fd24d2c54f5279eacf5684 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 7 Jul 2017 14:57:59 -0700 Subject: [PATCH 769/900] Skip first time experience on Appveyor --- appveyor.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 1041615c68..31efd8196f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -init: +init: - git config --global core.autocrlf true branches: only: @@ -9,6 +9,10 @@ branches: build_script: - ps: .\build.ps1 clone_depth: 1 +environment: + global: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 test: off deploy: off os: Visual Studio 2017 From 5485846b5c119a365ac3d004effc8aa97d987fce Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 12 Jul 2017 09:56:25 -0700 Subject: [PATCH 770/900] Update IdentityModel versions to latest, fix samples. --- build/dependencies.props | 4 ++-- samples/OpenIdConnect.AzureAdSample/Startup.cs | 3 +-- samples/OpenIdConnectSample/Startup.cs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 44605092cc..3ceeb8708b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,8 +2,8 @@ 2.0.0-* 4.4.0-* - 3.13.9 - 2.1.3 + 3.14.1 + 2.1.4 2.0.1-* 10.0.1 2.0.0-* diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index aab6e60df8..6a6abd7c34 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -45,8 +45,7 @@ namespace OpenIdConnect.AzureAdSample { services.AddAuthentication(sharedOptions => { - sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; - sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }) .AddCookie() diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index bc5af750d3..3325ea3c3b 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -147,7 +147,7 @@ namespace OpenIdConnectSample // Authenticated, but not authorized if (context.Request.Path.Equals("/restricted") && !user.Identities.Any(identity => identity.HasClaim("special", "true"))) { - await context.ChallengeAsync(); + await context.ForbidAsync(); return; } From 36d3d97b9935b2cefb22731084adc4754d1e61e9 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 13 Jul 2017 12:25:36 -0700 Subject: [PATCH 771/900] #1319 Add DisplayName overloads --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- samples/SocialSample/Startup.cs | 6 +++--- .../CookieExtensions.cs | 5 ++++- .../FacebookDefaults.cs | 2 ++ .../FacebookExtensions.cs | 5 ++++- .../GoogleDefaults.cs | 2 ++ .../GoogleExtensions.cs | 5 ++++- .../JwtBearerExtensions.cs | 5 ++++- .../MicrosoftAccountDefaults.cs | 2 ++ .../MicrosoftAccountExtensions.cs | 5 ++++- .../OAuthDefaults.cs | 10 ++++++++++ .../OAuthExtensions.cs | 10 +++++++++- .../OpenIdConnectDefaults.cs | 4 ++-- .../OpenIdConnectExtensions.cs | 5 ++++- .../OpenIdConnectOptions.cs | 1 - .../breakingchanges.netcore.json | 5 +++++ .../TwitterDefaults.cs | 2 ++ .../TwitterExtensions.cs | 5 ++++- .../OAuthTests.cs | 2 +- 19 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 6a6abd7c34..c3fa3c719b 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -49,7 +49,7 @@ namespace OpenIdConnect.AzureAdSample sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }) .AddCookie() - .AddOpenIdConnect(o => + .AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, "AAD", o => { o.ClientId = ClientId; o.ClientSecret = ClientSecret; // for code flow diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index dcf76263d5..8a59928c41 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -70,7 +70,7 @@ namespace SocialSample }) // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project - .AddOAuth("Google-AccessToken", o => + .AddOAuth("Google-AccessToken", "Google AccessToken only", o => { o.ClientId = Configuration["google:clientid"]; o.ClientSecret = Configuration["google:clientsecret"]; @@ -128,7 +128,7 @@ namespace SocialSample */ // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. // https://apps.dev.microsoft.com/ - .AddOAuth("Microsoft-AccessToken", o => + .AddOAuth("Microsoft-AccessToken", "Microsoft AccessToken only", o => { o.ClientId = Configuration["microsoftaccount:clientid"]; o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; @@ -148,7 +148,7 @@ namespace SocialSample }) // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ - .AddOAuth("GitHub-AccessToken", o => + .AddOAuth("GitHub-AccessToken", "GitHub AccessToken only", o => { o.ClientId = Configuration["github-token:clientid"]; o.ClientSecret = Configuration["github-token:clientsecret"]; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index 61f72e361f..4c41f54a9c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -21,9 +21,12 @@ namespace Microsoft.Extensions.DependencyInjection => builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddCookie(authenticationScheme, displayName: null, configureOptions: configureOptions); + + public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); - return builder.AddScheme(authenticationScheme, configureOptions); + return builder.AddScheme(authenticationScheme, displayName, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs index 012f95dcce..6143a4f235 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -7,6 +7,8 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { public const string AuthenticationScheme = "Facebook"; + public static readonly string DisplayName = "Facebook"; + public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.6/dialog/oauth"; public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.6/oauth/access_token"; diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 1cb1ef03eb..2273724a42 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -16,6 +16,9 @@ namespace Microsoft.Extensions.DependencyInjection => builder.AddFacebook(FacebookDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) - => builder.AddOAuth(authenticationScheme, configureOptions); + => builder.AddFacebook(authenticationScheme, FacebookDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + => builder.AddOAuth(authenticationScheme, displayName, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs index 77d68aed93..e4bd666157 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -10,6 +10,8 @@ namespace Microsoft.AspNetCore.Authentication.Google { public const string AuthenticationScheme = "Google"; + public static readonly string DisplayName = "Google"; + public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/auth"; public static readonly string TokenEndpoint = "https://www.googleapis.com/oauth2/v4/token"; diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index 7bb9b7bebd..95547014ca 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -16,6 +16,9 @@ namespace Microsoft.Extensions.DependencyInjection => builder.AddGoogle(GoogleDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) - => builder.AddOAuth(authenticationScheme, configureOptions); + => builder.AddGoogle(authenticationScheme, GoogleDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + => builder.AddOAuth(authenticationScheme, displayName, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 698c0118e0..334407c0da 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -18,9 +18,12 @@ namespace Microsoft.Extensions.DependencyInjection => builder.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddJwtBearer(authenticationScheme, displayName: null, configureOptions: configureOptions); + + public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); - return builder.AddScheme(authenticationScheme, configureOptions); + return builder.AddScheme(authenticationScheme, displayName, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs index 0d272f9792..1b0859c5b7 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs @@ -7,6 +7,8 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { public const string AuthenticationScheme = "Microsoft"; + public static readonly string DisplayName = "Microsoft"; + public static readonly string AuthorizationEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"; public static readonly string TokenEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/token"; diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 8da6daaac8..7f24e5af77 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -16,6 +16,9 @@ namespace Microsoft.Extensions.DependencyInjection => builder.AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) - => builder.AddOAuth(authenticationScheme, configureOptions); + => builder.AddMicrosoftAccount(authenticationScheme, MicrosoftAccountDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + => builder.AddOAuth(authenticationScheme, displayName, configureOptions); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs new file mode 100644 index 0000000000..376f8ab01a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs @@ -0,0 +1,10 @@ +// 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.AspNetCore.Authentication.OAuth +{ + public static class OAuthDefaults + { + public static readonly string DisplayName = "OAuth"; + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 8c9d34c5f9..22c541a0ac 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -14,12 +14,20 @@ namespace Microsoft.Extensions.DependencyInjection public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) => builder.AddOAuth>(authenticationScheme, configureOptions); + public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + => builder.AddOAuth>(authenticationScheme, displayName, configureOptions); + public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) where TOptions : OAuthOptions, new() where THandler : OAuthHandler + => builder.AddOAuth(authenticationScheme, OAuthDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + where TOptions : OAuthOptions, new() + where THandler : OAuthHandler { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); - return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + return builder.AddRemoteScheme(authenticationScheme, displayName, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs index c5baca4db9..f98ba87e02 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs @@ -19,9 +19,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect public const string AuthenticationScheme = "OpenIdConnect"; /// - /// The default value for OpenIdConnectOptions.Caption. + /// The default value for the display name. /// - public static readonly string Caption = "OpenIdConnect"; + public static readonly string DisplayName = "OpenIdConnect"; /// /// The prefix used to for the nonce in the cookie. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index 43059b3ffe..f427bebaff 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -18,9 +18,12 @@ namespace Microsoft.Extensions.DependencyInjection => builder.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddOpenIdConnect(authenticationScheme, OpenIdConnectDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); - return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + return builder.AddRemoteScheme(authenticationScheme, displayName, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 23169b5bcd..a8545e35a6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -27,7 +27,6 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Defaults: /// AddNonceToRequest: true. /// BackchannelTimeout: 1 minute. - /// Caption: . /// ProtocolValidator: new . /// RefreshOnIssuerKeyNotFound: true /// ResponseType: diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json index 0f50b12103..931a7b079d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json @@ -59,5 +59,10 @@ { "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", + "MemberId": "public static readonly System.String Caption", + "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs index 0610ccfc9d..a39a3f0367 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs @@ -6,5 +6,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter public static class TwitterDefaults { public const string AuthenticationScheme = "Twitter"; + + public static readonly string DisplayName = "Twitter"; } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index bd0a3b1e20..7243805692 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -18,9 +18,12 @@ namespace Microsoft.Extensions.DependencyInjection => builder.AddTwitter(TwitterDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddTwitter(authenticationScheme, TwitterDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); - return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + return builder.AddRemoteScheme(authenticationScheme, displayName, configureOptions); } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index ea0c941c91..aeb313daa3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth var scheme = await schemeProvider.GetSchemeAsync("oauth"); Assert.NotNull(scheme); Assert.Equal("OAuthHandler`1", scheme.HandlerType.Name); - Assert.Equal("oauth", scheme.DisplayName); + Assert.Equal(OAuthDefaults.DisplayName, scheme.DisplayName); } [Fact] From 04a40b54543b9260c11c822b680bfa86d5f54f1d Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 13 Jul 2017 15:10:12 -0700 Subject: [PATCH 772/900] Removed DotNetCliToolReference from the samples to fix build break --- .../OpenIdConnect.AzureAdSample.csproj | 1 - samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 1 - 2 files changed, 2 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index ece748d0dd..cd8b6976f2 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -20,7 +20,6 @@ - diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 9f62a06b50..b3d875d474 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -26,7 +26,6 @@ - From b61f1ee7817b2b6f3c55237f03af3854927b3b44 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 14 Jul 2017 16:34:20 -0700 Subject: [PATCH 773/900] Enable Travis and AppVeyor for rel branches (#1324) --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index b10be14215..6c59666f3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ branches: - release - dev - /^(.*\/)?ci-.*$/ + - /^rel\/.*/ before_install: - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: diff --git a/appveyor.yml b/appveyor.yml index 1041615c68..04dfabcb0b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,7 @@ branches: - release - dev - /^(.*\/)?ci-.*$/ + - /^rel\/.*/ build_script: - ps: .\build.ps1 clone_depth: 1 From fcd9f0c3ff5693f453fde62c9e16c1991085ce93 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 14 Jul 2017 16:55:07 -0700 Subject: [PATCH 774/900] Update Owin to latest (#1323) --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3ceeb8708b..85abdc8943 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,7 +8,7 @@ 10.0.1 2.0.0-* 2.0.0-* - 3.0.1 + 3.1.0 2.0.0-* 15.3.0-* 2.3.0-beta2-* From ba7739f14de51662134f4a101e2475d3984a222c Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 14 Jul 2017 18:14:22 -0700 Subject: [PATCH 775/900] Revert "Update Owin to latest (#1323)" This reverts commit fcd9f0c3ff5693f453fde62c9e16c1991085ce93. --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 85abdc8943..3ceeb8708b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,7 +8,7 @@ 10.0.1 2.0.0-* 2.0.0-* - 3.1.0 + 3.0.1 2.0.0-* 15.3.0-* 2.3.0-beta2-* From 644f34e90d35b369efdce9c11ab1db42e0a7f4a7 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 20 Jul 2017 11:07:01 -0700 Subject: [PATCH 776/900] AuthZ PolicyEvalutor should take resource --- .../IPolicyEvaluator.cs | 6 ++- .../PolicyEvaluator.cs | 8 ++- .../PolicyEvaluatorTests.cs | 50 +++++++++++++++---- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs b/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs index 1717a0ae0a..dd5e6fc038 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs @@ -28,9 +28,13 @@ namespace Microsoft.AspNetCore.Authorization.Policy /// The . /// The result of a call to . /// The . + /// + /// An optional resource the policy should be checked with. + /// If a resource is not required for policy evaluation you may pass null as the value. + /// /// Returns if authorization succeeds. /// Otherwise returns if , otherwise /// returns - Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context); + Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context, object resource); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs index f93c2d92a3..3100ff4d3e 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs @@ -67,17 +67,21 @@ namespace Microsoft.AspNetCore.Authorization.Policy /// The . /// The result of a call to . /// The . + /// + /// An optional resource the policy should be checked with. + /// If a resource is not required for policy evaluation you may pass null as the value. + /// /// Returns if authorization succeeds. /// Otherwise returns if , otherwise /// returns - public virtual async Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context) + public virtual async Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context, object resource) { if (policy == null) { throw new ArgumentNullException(nameof(policy)); } - var result = await _authorization.AuthorizeAsync(context.User, context, policy); + var result = await _authorization.AuthorizeAsync(context.User, resource, policy); if (result.Succeeded) { return PolicyAuthorizationResult.Success(); diff --git a/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs index 216fc1440e..2384e6db5f 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.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.Collections.Generic; using System.Linq; using System.Security.Claims; @@ -18,7 +19,7 @@ namespace Microsoft.AspNetCore.Authorization.Policy.Test public async Task AuthenticateFailsIfNoPrincipalReturned() { // Arrange - var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var evaluator = BuildEvaluator(); var context = new DefaultHttpContext(); var services = new ServiceCollection().AddSingleton(); context.RequestServices = services.BuildServiceProvider(); @@ -35,7 +36,7 @@ namespace Microsoft.AspNetCore.Authorization.Policy.Test public async Task AuthenticateMergeSchemes() { // Arrange - var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var evaluator = BuildEvaluator(); var context = new DefaultHttpContext(); var services = new ServiceCollection().AddSingleton(); context.RequestServices = services.BuildServiceProvider(); @@ -54,12 +55,12 @@ namespace Microsoft.AspNetCore.Authorization.Policy.Test public async Task AuthorizeSucceedsEvenIfAuthenticationFails() { // Arrange - var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var evaluator = BuildEvaluator(); var context = new DefaultHttpContext(); var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); // Act - var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context); + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context, resource: null); // Assert Assert.True(result.Succeeded); @@ -67,16 +68,34 @@ namespace Microsoft.AspNetCore.Authorization.Policy.Test Assert.False(result.Forbidden); } + [Fact] + public async Task AuthorizeSucceedsOnlyIfResourceSpecified() + { + // Arrange + var evaluator = BuildEvaluator(); + var context = new DefaultHttpContext(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(c => c.Resource != null).Build(); + var success = AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), "whatever")); + + // Act + var result = await evaluator.AuthorizeAsync(policy, success, context, resource: null); + var result2 = await evaluator.AuthorizeAsync(policy, success, context, resource: new object()); + + // Assert + Assert.False(result.Succeeded); + Assert.True(result2.Succeeded); + } + [Fact] public async Task AuthorizeChallengesIfAuthenticationFails() { // Arrange - var evaluator = new PolicyEvaluator(new SadAuthorization()); + var evaluator = BuildEvaluator(); var context = new DefaultHttpContext(); - var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => false).Build(); // Act - var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context); + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context, resource: null); // Assert Assert.False(result.Succeeded); @@ -88,12 +107,12 @@ namespace Microsoft.AspNetCore.Authorization.Policy.Test public async Task AuthorizeForbidsIfAuthenticationSuceeds() { // Arrange - var evaluator = new PolicyEvaluator(new SadAuthorization()); + var evaluator = BuildEvaluator(); var context = new DefaultHttpContext(); - var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => false).Build(); // Act - var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), "scheme")), context); + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), "scheme")), context, resource: null); // Assert Assert.False(result.Succeeded); @@ -101,6 +120,17 @@ namespace Microsoft.AspNetCore.Authorization.Policy.Test Assert.True(result.Forbidden); } + private IPolicyEvaluator BuildEvaluator(Action setupServices = null) + { + var services = new ServiceCollection() + .AddAuthorization() + .AddAuthorizationPolicyEvaluator() + .AddLogging() + .AddOptions(); + setupServices?.Invoke(services); + return services.BuildServiceProvider().GetRequiredService(); + } + public class HappyAuthorization : IAuthorizationService { public Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) From 827852efdb4e61f255770ac1b9d6e2bf7c77fa23 Mon Sep 17 00:00:00 2001 From: richstokoe Date: Mon, 24 Jul 2017 16:49:49 +0100 Subject: [PATCH 777/900] Corrected typos in XML Docs in MessageReceivedContext for events in JwtBearer and OpenIdConnect middlesware. (#1336) --- .../Events/MessageReceivedContext.cs | 2 +- .../Events/MessageReceivedContext.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs index 3c263f6b24..1850ad0492 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer : base(context, scheme, options) { } /// - /// Bearer Token. This will give application an opportunity to retrieve token from an alternation location. + /// Bearer Token. This will give the application an opportunity to retrieve a token from an alternative location. /// public string Token { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs index 106ecb8c03..7d06e44799 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect public OpenIdConnectMessage ProtocolMessage { get; set; } /// - /// Bearer Token. This will give application an opportunity to retrieve token from an alternation location. + /// Bearer Token. This will give the application an opportunity to retrieve a token from an alternative location. /// public string Token { get; set; } } From b787344b905d90981ad50b51a00fc6b12e8f1c19 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 21 Jul 2017 13:02:43 -0700 Subject: [PATCH 778/900] 2.0.0-rtm to 2.1.0-preview1 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index b94223e008..cb77b43933 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 2.0.0 - rtm + 2.1.0 + preview1 \ No newline at end of file From b7d29e4f7b968722127948052c24d423ee19026d Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 24 Jul 2017 17:58:45 -0700 Subject: [PATCH 779/900] Set AspNetCoreVersion --- build/dependencies.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3ceeb8708b..4a2338b8b5 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - + - 2.0.0-* + 2.1.0-* 4.4.0-* 3.14.1 2.1.4 From 10b2e70f4c36293aa2ff341b0453a2fe8125ab7d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Jul 2017 15:14:51 -0700 Subject: [PATCH 780/900] Updating to InternalAspNetCoreSdkVersion 2.1.1-* --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4a2338b8b5..a97cae9f61 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 4.4.0-* 3.14.1 2.1.4 - 2.0.1-* + 2.1.1-* 10.0.1 2.0.0-* 2.0.0-* From b9153be7453b871acd9043b5c373f86368fa8154 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 25 Jul 2017 16:34:44 -0700 Subject: [PATCH 781/900] Update bootstrappers to use the compiled version of KoreBuild [ci skip] --- .gitignore | 1 + build.cmd | 2 +- build.ps1 | 218 ++++++++++++++++++++++++++++++++----------- build.sh | 224 +++++++++++++++++++++++++++++++++++++-------- build/common.props | 2 +- version.props | 7 -- version.xml | 8 ++ 7 files changed, 362 insertions(+), 100 deletions(-) delete mode 100644 version.props create mode 100644 version.xml diff --git a/.gitignore b/.gitignore index d5717b3f3f..bac5b75057 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ project.lock.json /.vs/ .vscode/ global.json +korebuild-lock.txt diff --git a/build.cmd b/build.cmd index 7d4894cb4a..b6c8d24864 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" \ No newline at end of file +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..d5eb4d5cf2 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,67 +1,177 @@ -$ErrorActionPreference = "Stop" +#!/usr/bin/env powershell +#requires -version 4 -function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) -{ - while($true) - { - try - { - Invoke-WebRequest $url -OutFile $downloadLocation - break - } - catch - { - $exceptionMessage = $_.Exception.Message - Write-Host "Failed to download '$url': $exceptionMessage" - if ($retries -gt 0) { - $retries-- - Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" - Start-Sleep -Seconds 10 +<# +.SYNOPSIS +Build this repository +.DESCRIPTION +Downloads korebuild if required. Then builds the repository. + +.PARAMETER Path +The folder to build. Defaults to the folder containing this script. + +.PARAMETER Channel +The channel of KoreBuild to download. Overrides the value from the config file. + +.PARAMETER DotNetHome +The directory where .NET Core tools will be stored. + +.PARAMETER ToolsSource +The base url where build tools can be downloaded. Overrides the value from the config file. + +.PARAMETER Update +Updates KoreBuild to the latest version even if a lock file is present. + +.PARAMETER ConfigFile +The path to the configuration file that stores values. Defaults to version.xml. + +.PARAMETER MSBuildArgs +Arguments to be passed to MSBuild + +.NOTES +This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. +When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. + +The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well. + +.EXAMPLE +Example config file: +```xml + + + + dev + https://aspnetcore.blob.core.windows.net/buildtools + + +``` +#> +[CmdletBinding(PositionalBinding = $false)] +param( + [string]$Path = $PSScriptRoot, + [Alias('c')] + [string]$Channel, + [Alias('d')] + [string]$DotNetHome, + [Alias('s')] + [string]$ToolsSource, + [Alias('u')] + [switch]$Update, + [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'), + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$MSBuildArgs +) + +Set-StrictMode -Version 2 +$ErrorActionPreference = 'Stop' + +# +# Functions +# + +function Get-KoreBuild { + + $lockFile = Join-Path $Path 'korebuild-lock.txt' + + if (!(Test-Path $lockFile) -or $Update) { + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + } + + $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 + if (!$version) { + Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" + } + $version = $version.TrimStart('version:').Trim() + $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) + + if (!(Test-Path $korebuildPath)) { + Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" + New-Item -ItemType Directory -Path $korebuildPath | Out-Null + $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" + + try { + $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" + Get-RemoteFile $remotePath $tmpfile + if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { + # Use built-in commands where possible as they are cross-plat compatible + Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath } - else - { - $exception = $_.Exception - throw $exception + else { + # Fallback to old approach for old installations of PowerShell + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) } } + catch { + Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore + throw + } + finally { + Remove-Item $tmpfile -ErrorAction Ignore + } } + + return $korebuildPath } -cd $PSScriptRoot - -$repoFolder = $PSScriptRoot -$env:REPO_FOLDER = $repoFolder - -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if ($env:KOREBUILD_ZIP) -{ - $koreBuildZip=$env:KOREBUILD_ZIP +function Join-Paths([string]$path, [string[]]$childPaths) { + $childPaths | ForEach-Object { $path = Join-Path $path $_ } + return $path } -$buildFolder = ".build" -$buildFile="$buildFolder\KoreBuild.ps1" - -if (!(Test-Path $buildFolder)) { - Write-Host "Downloading KoreBuild from $koreBuildZip" - - $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() - New-Item -Path "$tempFolder" -Type directory | Out-Null - - $localZipFile="$tempFolder\korebuild.zip" - - DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 - - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) - - New-Item -Path "$buildFolder" -Type directory | Out-Null - copy-item "$tempFolder\**\build\*" $buildFolder -Recurse - - # Cleanup - if (Test-Path $tempFolder) { - Remove-Item -Recurse -Force $tempFolder +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { + if ($RemotePath -notlike 'http*') { + Copy-Item $RemotePath $LocalPath + return } + + $retries = 10 + while ($retries -gt 0) { + $retries -= 1 + try { + Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath + return + } + catch { + Write-Verbose "Request failed. $retries retries remaining" + } + } + + Write-Error "Download failed: '$RemotePath'." } -&"$buildFile" @args +# +# Main +# + +# Load configuration or set defaults + +if (Test-Path $ConfigFile) { + [xml] $config = Get-Content $ConfigFile + if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' } + if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' } +} + +if (!$DotNetHome) { + $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` + elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` + elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` + else { Join-Path $PSScriptRoot '.dotnet'} +} + +if (!$Channel) { $Channel = 'dev' } +if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } + +# Execute + +$korebuildPath = Get-KoreBuild +Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') + +try { + Install-Tools $ToolsSource $DotNetHome + Invoke-RepositoryBuild $Path @MSBuildArgs +} +finally { + Remove-Module 'KoreBuild' -ErrorAction Ignore +} diff --git a/build.sh b/build.sh index b0bcadb579..ab590e62f1 100755 --- a/build.sh +++ b/build.sh @@ -1,46 +1,196 @@ #!/usr/bin/env bash -repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if [ ! -z $KOREBUILD_ZIP ]; then - koreBuildZip=$KOREBUILD_ZIP -fi +set -euo pipefail -buildFolder=".build" -buildFile="$buildFolder/KoreBuild.sh" +# +# variables +# -if test ! -d $buildFolder; then - echo "Downloading KoreBuild from $koreBuildZip" +RESET="\033[0m" +RED="\033[0;31m" +MAGENTA="\033[0;95m" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet" +config_file="$DIR/version.xml" +verbose=false +update=false +repo_path="$DIR" +channel='' +tools_source='' - tempFolder="/tmp/KoreBuild-$(uuidgen)" - mkdir $tempFolder +# +# Functions +# +__usage() { + echo "Usage: $(basename ${BASH_SOURCE[0]}) [options] [[--] ...]" + echo "" + echo "Arguments:" + echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." + echo "" + echo "Options:" + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file TThe path to the configuration file that stores values. Defaults to version.xml." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source The base url where build tools can be downloaded. Overrides the value from the config file." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo "" + echo "Description:" + echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." + echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - localZipFile="$tempFolder/korebuild.zip" - - retries=6 - until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) - do - echo "Failed to download '$koreBuildZip'" - if [ "$retries" -le 0 ]; then - exit 1 - fi - retries=$((retries - 1)) - echo "Waiting 10 seconds before retrying. Retries left: $retries" - sleep 10s - done - - unzip -q -d $tempFolder $localZipFile - - mkdir $buildFolder - cp -r $tempFolder/**/build/** $buildFolder - - chmod +x $buildFile - - # Cleanup - if test -d $tempFolder; then - rm -rf $tempFolder + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 fi +} + +get_korebuild() { + local lock_file="$repo_path/korebuild-lock.txt" + if [ ! -f $lock_file ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" $lock_file + fi + local version="$(grep 'version:*' -m 1 $lock_file)" + if [[ "$version" == '' ]]; then + __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + return 1 + fi + version="$(echo ${version#version:} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + + { + if [ ! -d "$korebuild_path" ]; then + mkdir -p "$korebuild_path" + local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" + tmpfile="$(mktemp)" + echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" + if __get_remote_file $remote_path $tmpfile; then + unzip -q -d "$korebuild_path" $tmpfile + fi + rm $tmpfile || true + fi + + source "$korebuild_path/KoreBuild.sh" + } || { + if [ -d "$korebuild_path" ]; then + echo "Cleaning up after failed installation" + rm -rf "$korebuild_path" || true + fi + return 1 + } +} + +__error() { + echo -e "${RED}$@${RESET}" 1>&2 +} + +__machine_has() { + hash "$1" > /dev/null 2>&1 + return $? +} + +__get_remote_file() { + local remote_path=$1 + local local_path=$2 + + if [[ "$remote_path" != 'http'* ]]; then + cp $remote_path $local_path + return 0 + fi + + failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O $local_path $remote_path || failed=true + fi + + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + fi + + if [ "$failed" = true ]; then + __error "Download failed: $remote_path" 1>&2 + return 1 + fi +} + +__read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ;} + +# +# main +# + +while [[ $# > 0 ]]; do + case $1 in + -\?|-h|--help) + __usage --no-exit + exit 0 + ;; + -c|--channel|-Channel) + shift + channel=${1:-} + [ -z "$channel" ] && __usage + ;; + --config-file|-ConfigFile) + shift + config_file="${1:-}" + [ -z "$config_file" ] && __usage + ;; + -d|--dotnet-home|-DotNetHome) + shift + DOTNET_HOME=${1:-} + [ -z "$DOTNET_HOME" ] && __usage + ;; + --path|-Path) + shift + repo_path="${1:-}" + [ -z "$repo_path" ] && __usage + ;; + -s|--tools-source|-ToolsSource) + shift + tools_source="${1:-}" + [ -z "$tools_source" ] && __usage + ;; + -u|--update|-Update) + update=true + ;; + --verbose|-Verbose) + verbose=true + ;; + --) + shift + break + ;; + *) + break + ;; + esac + shift +done + +if ! __machine_has unzip; then + __error 'Missing required command: unzip' + exit 1 fi -$buildFile -r $repoFolder "$@" +if ! __machine_has curl && ! __machine_has wget; then + __error 'Missing required command. Either wget or curl is required.' + exit 1 +fi + +if [ -f $config_file ]; then + comment=false + while __read_dom; do + if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi + if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi + if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi + if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi + done < $config_file +fi + +[ -z "$channel" ] && channel='dev' +[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' + +get_korebuild +install_tools "$tools_source" "$DOTNET_HOME" +invoke_repository_build "$repo_path" $@ diff --git a/build/common.props b/build/common.props index f7497c8f43..ea940214e6 100644 --- a/build/common.props +++ b/build/common.props @@ -1,6 +1,6 @@ - + Microsoft ASP.NET Core diff --git a/version.props b/version.props deleted file mode 100644 index cb77b43933..0000000000 --- a/version.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - 2.1.0 - preview1 - - \ No newline at end of file diff --git a/version.xml b/version.xml new file mode 100644 index 0000000000..3c05022b7d --- /dev/null +++ b/version.xml @@ -0,0 +1,8 @@ + + + + dev + 2.1.0 + preview1 + + From a4458191c700437a00603116ad92633d1590319d Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 26 Jul 2017 10:29:04 -0700 Subject: [PATCH 782/900] Fix syntax warning when running build.sh on older versions of bash [ci skip] --- build.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/build.sh b/build.sh index ab590e62f1..5568c6182a 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ RESET="\033[0m" RED="\033[0;31m" MAGENTA="\033[0;95m" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet" +[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" config_file="$DIR/version.xml" verbose=false update=false @@ -22,7 +22,7 @@ tools_source='' # Functions # __usage() { - echo "Usage: $(basename ${BASH_SOURCE[0]}) [options] [[--] ...]" + echo "Usage: $(basename "${BASH_SOURCE[0]}") [options] [[--] ...]" echo "" echo "Arguments:" echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." @@ -46,16 +46,17 @@ __usage() { } get_korebuild() { + local version local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f $lock_file ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" $lock_file + if [ ! -f "$lock_file" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" fi - local version="$(grep 'version:*' -m 1 $lock_file)" + version="$(grep 'version:*' -m 1 "$lock_file")" if [[ "$version" == '' ]]; then __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" return 1 fi - version="$(echo ${version#version:} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" { @@ -64,10 +65,10 @@ get_korebuild() { local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" tmpfile="$(mktemp)" echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file $remote_path $tmpfile; then - unzip -q -d "$korebuild_path" $tmpfile + if __get_remote_file "$remote_path" "$tmpfile"; then + unzip -q -d "$korebuild_path" "$tmpfile" fi - rm $tmpfile || true + rm "$tmpfile" || true fi source "$korebuild_path/KoreBuild.sh" @@ -81,7 +82,7 @@ get_korebuild() { } __error() { - echo -e "${RED}$@${RESET}" 1>&2 + echo -e "${RED}$*${RESET}" 1>&2 } __machine_has() { @@ -94,18 +95,18 @@ __get_remote_file() { local local_path=$2 if [[ "$remote_path" != 'http'* ]]; then - cp $remote_path $local_path + cp "$remote_path" "$local_path" return 0 fi failed=false if __machine_has wget; then - wget --tries 10 --quiet -O $local_path $remote_path || failed=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true fi if [ "$failed" = true ] && __machine_has curl; then failed=false - curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true fi if [ "$failed" = true ]; then @@ -114,13 +115,13 @@ __get_remote_file() { fi } -__read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ;} +__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;} # # main # -while [[ $# > 0 ]]; do +while [[ $# -gt 0 ]]; do case $1 in -\?|-h|--help) __usage --no-exit @@ -128,7 +129,7 @@ while [[ $# > 0 ]]; do ;; -c|--channel|-Channel) shift - channel=${1:-} + channel="${1:-}" [ -z "$channel" ] && __usage ;; --config-file|-ConfigFile) @@ -138,7 +139,7 @@ while [[ $# > 0 ]]; do ;; -d|--dotnet-home|-DotNetHome) shift - DOTNET_HOME=${1:-} + DOTNET_HOME="${1:-}" [ -z "$DOTNET_HOME" ] && __usage ;; --path|-Path) @@ -178,14 +179,14 @@ if ! __machine_has curl && ! __machine_has wget; then exit 1 fi -if [ -f $config_file ]; then +if [ -f "$config_file" ]; then comment=false while __read_dom; do if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi - done < $config_file + done < "$config_file" fi [ -z "$channel" ] && channel='dev' @@ -193,4 +194,4 @@ fi get_korebuild install_tools "$tools_source" "$DOTNET_HOME" -invoke_repository_build "$repo_path" $@ +invoke_repository_build "$repo_path" "$@" From 98496d7d6b55e079e78ef71cc9b4e4af5d8a63fe Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 2 Aug 2017 12:44:48 -0700 Subject: [PATCH 783/900] Update __get_remote_file logic --- build.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 5568c6182a..8eace4c20d 100755 --- a/build.sh +++ b/build.sh @@ -99,17 +99,16 @@ __get_remote_file() { return 0 fi - failed=false + local succeeded=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" && succeeded=true fi - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + if [ "$succeeded" = false ] && __machine_has curl; then + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" && succeeded=true fi - if [ "$failed" = true ]; then + if [ "$succeeded" = false ]; then __error "Download failed: $remote_path" 1>&2 return 1 fi From 4fec8c11c280dbb08a1bd3c76408c438d3c50c7b Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 2 Aug 2017 14:33:52 -0700 Subject: [PATCH 784/900] Ensure fallback to curl after failed wget --- build.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 8eace4c20d..11cdbe5504 100755 --- a/build.sh +++ b/build.sh @@ -99,16 +99,19 @@ __get_remote_file() { return 0 fi - local succeeded=false + local failed=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" && succeeded=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + else + failed=true fi - if [ "$succeeded" = false ] && __machine_has curl; then - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" && succeeded=true + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true fi - if [ "$succeeded" = false ]; then + if [ "$failed" = true ]; then __error "Download failed: $remote_path" 1>&2 return 1 fi From d797543cfc587fbe812e66ddf910acbe5f86d009 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 3 Aug 2017 12:59:45 -0700 Subject: [PATCH 785/900] Update obsolete error (#1346) --- .../CookieAppBuilderExtensions.cs | 8 ++++---- .../FacebookAppBuilderExtensions.cs | 8 ++++---- .../GoogleAppBuilderExtensions.cs | 8 ++++---- .../JwtBearerAppBuilderExtensions.cs | 8 ++++---- .../MicrosoftAccountAppBuilderExtensions.cs | 8 ++++---- .../OAuthAppBuilderExtensions.cs | 8 ++++---- .../OpenIdConnectAppBuilderExtensions.cs | 8 ++++---- .../TwitterAppBuilderExtensions.cs | 8 ++++---- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs index bb5cdfff0e..bdfd43c796 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class CookieAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseCookieAuthentication is obsolete. Configure Cookie authentication with AddAuthentication().AddCookie in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseCookieAuthentication is obsolete. Configure Cookie authentication with AddAuthentication().AddCookie in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseCookieAuthentication is obsolete. Configure Cookie authentication with AddAuthentication().AddCookie in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseCookieAuthentication is obsolete. Configure Cookie authentication with AddAuthentication().AddCookie in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuilder app, CookieAuthenticationOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs index 1a9607eea4..a94dc7bc45 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class FacebookAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseFacebookAuthentication is obsolete. Configure Facebook authentication with AddAuthentication().AddFacebook in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseFacebookAuthentication is obsolete. Configure Facebook authentication with AddAuthentication().AddFacebook in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseFacebookAuthentication is obsolete. Configure Facebook authentication with AddAuthentication().AddFacebook in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseFacebookAuthentication is obsolete. Configure Facebook authentication with AddAuthentication().AddFacebook in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app, FacebookOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs index ec7e8a7aab..4302d20db1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -3,8 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.Google; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { @@ -14,21 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class GoogleAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseGoogleAuthentication is obsolete. Configure Google authentication with AddAuthentication().AddGoogle in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. + [Obsolete("UseGoogleAuthentication is obsolete. Configure Google authentication with AddAuthentication().AddGoogle in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseGoogleAuthentication is obsolete. Configure Google authentication with AddAuthentication().AddGoogle in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. + [Obsolete("UseGoogleAuthentication is obsolete. Configure Google authentication with AddAuthentication().AddGoogle in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app, GoogleOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index 9755c5cb7d..0cfc97573c 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class JwtBearerAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseJwtBearerAuthentication is obsolete. Configure JwtBearer authentication with AddAuthentication().AddJwtBearer in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseJwtBearerAuthentication is obsolete. Configure JwtBearer authentication with AddAuthentication().AddJwtBearer in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseJwtBearerAuthentication is obsolete. Configure JwtBearer authentication with AddAuthentication().AddJwtBearer in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseJwtBearerAuthentication is obsolete. Configure JwtBearer authentication with AddAuthentication().AddJwtBearer in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app, JwtBearerOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs index 88306efbed..7fd71d7a9b 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class MicrosoftAccountAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseMicrosoftAccountAuthentication is obsolete. Configure MicrosoftAccount authentication with AddAuthentication().AddMicrosoftAccount in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseMicrosoftAccountAuthentication is obsolete. Configure MicrosoftAccount authentication with AddAuthentication().AddMicrosoftAccount in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseMicrosoftAccountAuthentication is obsolete. Configure MicrosoftAccount authentication with AddAuthentication().AddMicrosoftAccount in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseMicrosoftAccountAuthentication is obsolete. Configure MicrosoftAccount authentication with AddAuthentication().AddMicrosoftAccount in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app, MicrosoftAccountOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs index ceec294eca..d55f311f7b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class OAuthAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseOAuthAuthentication is obsolete. Configure OAuth authentication with AddAuthentication().AddOAuth in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseOAuthAuthentication is obsolete. Configure OAuth authentication with AddAuthentication().AddOAuth in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseOAuthAuthentication is obsolete. Configure OAuth authentication with AddAuthentication().AddOAuth in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseOAuthAuthentication is obsolete. Configure OAuth authentication with AddAuthentication().AddOAuth in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app, OAuthOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs index db5cfbbcc9..0746ae3fdb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class OpenIdConnectAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseOpenIdConnectAuthentication is obsolete. Configure OpenIdConnect authentication with AddAuthentication().AddOpenIdConnect in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseOpenIdConnectAuthentication is obsolete. Configure OpenIdConnect authentication with AddAuthentication().AddOpenIdConnect in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseOpenIdConnectAuthentication is obsolete. Configure OpenIdConnect authentication with AddAuthentication().AddOpenIdConnect in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseOpenIdConnectAuthentication is obsolete. Configure OpenIdConnect authentication with AddAuthentication().AddOpenIdConnect in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app, OpenIdConnectOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs index 2896365d69..36e1111da6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class TwitterAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseTwitterAuthentication is obsolete. Configure Twitter authentication with AddAuthentication().AddTwitter in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseTwitterAuthentication is obsolete. Configure Twitter authentication with AddAuthentication().AddTwitter in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseTwitterAuthentication is obsolete. Configure Twitter authentication with AddAuthentication().AddTwitter in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseTwitterAuthentication is obsolete. Configure Twitter authentication with AddAuthentication().AddTwitter in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, TwitterOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); From 5d802a798847f61c8c32368f5690a48caefbca97 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 12 Jul 2017 08:54:58 -0700 Subject: [PATCH 786/900] Add sample for refresh tokens --- samples/OpenIdConnectSample/Startup.cs | 107 ++++++++++-- samples/SocialSample/Startup.cs | 231 +++++++++++++++++++++---- 2 files changed, 286 insertions(+), 52 deletions(-) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 3325ea3c3b..c05bc8b522 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; +using System.Net.Http; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; @@ -11,7 +13,9 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Newtonsoft.Json.Linq; namespace OpenIdConnectSample { @@ -53,6 +57,7 @@ namespace OpenIdConnectSample o.ClientSecret = Configuration["oidc:clientsecret"]; // for code flow o.Authority = Configuration["oidc:authority"]; o.ResponseType = OpenIdConnectResponseType.CodeIdToken; + o.SaveTokens = true; o.GetClaimsFromUserInfoEndpoint = true; o.Events = new OpenIdConnectEvents() { @@ -73,19 +78,21 @@ namespace OpenIdConnectSample }); } - public void Configure(IApplicationBuilder app) + public void Configure(IApplicationBuilder app, IOptionsMonitor optionsMonitor) { app.UseDeveloperExceptionPage(); app.UseAuthentication(); app.Run(async context => { + var response = context.Response; + if (context.Request.Path.Equals("/signedout")) { - await WriteHtmlAsync(context.Response, async res => + await WriteHtmlAsync(response, async res => { await res.WriteAsync($"

You have been signed out.

"); - await res.WriteAsync("Sign In"); + await res.WriteAsync("Home"); }); return; } @@ -93,10 +100,10 @@ namespace OpenIdConnectSample if (context.Request.Path.Equals("/signout")) { await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - await WriteHtmlAsync(context.Response, async res => + await WriteHtmlAsync(response, async res => { - await context.Response.WriteAsync($"

Signed out {HtmlEncode(context.User.Identity.Name)}

"); - await context.Response.WriteAsync("Sign In"); + await res.WriteAsync($"

Signed out {HtmlEncode(context.User.Identity.Name)}

"); + await res.WriteAsync("Home"); }); return; } @@ -115,19 +122,22 @@ namespace OpenIdConnectSample if (context.Request.Path.Equals("/Account/AccessDenied")) { await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - await WriteHtmlAsync(context.Response, async res => + await WriteHtmlAsync(response, async res => { - await context.Response.WriteAsync($"

Access Denied for user {HtmlEncode(context.User.Identity.Name)} to resource '{HtmlEncode(context.Request.Query["ReturnUrl"])}'

"); - await context.Response.WriteAsync("Sign Out"); + await res.WriteAsync($"

Access Denied for user {HtmlEncode(context.User.Identity.Name)} to resource '{HtmlEncode(context.Request.Query["ReturnUrl"])}'

"); + await res.WriteAsync("Sign Out"); + await res.WriteAsync("Home"); }); return; } // DefaultAuthenticateScheme causes User to be set - var user = context.User; + // var user = context.User; // This is what [Authorize] calls - // var user = await context.AuthenticateAsync(); + var userResult = await context.AuthenticateAsync(); + var user = userResult.Principal; + var props = userResult.Properties; // This is what [Authorize(ActiveAuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)] calls // var user = await context.AuthenticateAsync(OpenIdConnectDefaults.AuthenticationScheme); @@ -151,15 +161,76 @@ namespace OpenIdConnectSample return; } - await WriteHtmlAsync(context.Response, async response => + if (context.Request.Path.Equals("/refresh")) { - await response.WriteAsync($"

Hello Authenticated User {HtmlEncode(user.Identity.Name)}

"); - await response.WriteAsync("Restricted"); - await response.WriteAsync("Sign Out"); - await response.WriteAsync("Sign Out Remote"); + var refreshToken = props.GetTokenValue("refresh_token"); - await response.WriteAsync("

Claims:

"); - await WriteTableHeader(response, new string[] { "Claim Type", "Value" }, context.User.Claims.Select(c => new string[] { c.Type, c.Value })); + if (string.IsNullOrEmpty(refreshToken)) + { + await WriteHtmlAsync(response, async res => + { + await res.WriteAsync($"No refresh_token is available.
"); + await res.WriteAsync("Sign Out"); + }); + + return; + } + + var options = optionsMonitor.Get(OpenIdConnectDefaults.AuthenticationScheme); + var metadata = await options.ConfigurationManager.GetConfigurationAsync(context.RequestAborted); + + var pairs = new Dictionary() + { + { "client_id", options.ClientId }, + { "client_secret", options.ClientSecret }, + { "grant_type", "refresh_token" }, + { "refresh_token", refreshToken } + }; + var content = new FormUrlEncodedContent(pairs); + var tokenResponse = await options.Backchannel.PostAsync(metadata.TokenEndpoint, content, context.RequestAborted); + tokenResponse.EnsureSuccessStatusCode(); + + var payload = JObject.Parse(await tokenResponse.Content.ReadAsStringAsync()); + + // Persist the new acess token + props.UpdateTokenValue("access_token", payload.Value("access_token")); + props.UpdateTokenValue("refresh_token", payload.Value("refresh_token")); + if (int.TryParse(payload.Value("expires_in"), NumberStyles.Integer, CultureInfo.InvariantCulture, out var seconds)) + { + var expiresAt = DateTimeOffset.UtcNow + TimeSpan.FromSeconds(seconds); + props.UpdateTokenValue("expires_at", expiresAt.ToString("o", CultureInfo.InvariantCulture)); + } + await context.SignInAsync(user, props); + + await WriteHtmlAsync(response, async res => + { + await res.WriteAsync($"

Refreshed.

"); + await res.WriteAsync("Refresh tokens"); + await res.WriteAsync("Home"); + + await res.WriteAsync("

Tokens:

"); + await WriteTableHeader(res, new string[] { "Token Type", "Value" }, props.GetTokens().Select(token => new string[] { token.Name, token.Value })); + + await res.WriteAsync("

Payload:

"); + await res.WriteAsync(HtmlEncoder.Default.Encode(payload.ToString()).Replace(",", ",
") + "
"); + }); + + return; + } + + await WriteHtmlAsync(response, async res => + { + await res.WriteAsync($"

Hello Authenticated User {HtmlEncode(user.Identity.Name)}

"); + await res.WriteAsync("Refresh tokens"); + await res.WriteAsync("Restricted"); + await res.WriteAsync("Sign Out"); + await res.WriteAsync("Sign Out Remote"); + + await res.WriteAsync("

Claims:

"); + await WriteTableHeader(res, new string[] { "Claim Type", "Value" }, context.User.Claims.Select(c => new string[] { c.Type, c.Value })); + + await res.WriteAsync("

Tokens:

"); + await WriteTableHeader(res, new string[] { "Token Type", "Value" }, props.GetTokens().Select(token => new string[] { token.Name, token.Value })); }); }); } diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 8a59928c41..d69b25ee31 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; @@ -7,6 +9,7 @@ using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.Facebook; using Microsoft.AspNetCore.Authentication.Google; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; using Microsoft.AspNetCore.Authentication.OAuth; @@ -14,8 +17,10 @@ using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; namespace SocialSample @@ -50,12 +55,7 @@ namespace SocialSample throw new InvalidOperationException("User secrets must be configured for each authentication provider."); } - services.AddAuthentication(options => - { - options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; - options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }) + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(o => o.LoginPath = new PathString("/login")) // You must first create an app with Facebook and add its ID and Secret to your user-secrets. // https://developers.facebook.com/apps/ @@ -88,6 +88,8 @@ namespace SocialSample { o.ClientId = Configuration["google:clientid"]; o.ClientSecret = Configuration["google:clientsecret"]; + o.AuthorizationEndpoint += "?prompt=consent"; // Hack so we always get a refresh token, it only comes on the first authorization response + o.AccessType = "offline"; o.SaveTokens = true; o.Events = new OAuthEvents() { @@ -145,6 +147,7 @@ namespace SocialSample o.ClientId = Configuration["microsoftaccount:clientid"]; o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; o.SaveTokens = true; + o.Scope.Add("offline_access"); }) // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ @@ -215,16 +218,135 @@ namespace SocialSample return; } - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync(""); - await context.Response.WriteAsync("Choose an authentication scheme:
"); + var response = context.Response; + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("Choose an authentication scheme:
"); var schemeProvider = context.RequestServices.GetRequiredService(); foreach (var provider in await schemeProvider.GetAllSchemesAsync()) { - // REVIEW: we lost access to display name (which is buried in the handler options) - await context.Response.WriteAsync("" + (provider.DisplayName ?? "(suppressed)") + "
"); + await response.WriteAsync("" + (provider.DisplayName ?? "(suppressed)") + "
"); } - await context.Response.WriteAsync(""); + await response.WriteAsync(""); + }); + }); + + // Refresh the access token + app.Map("/refresh_token", signinApp => + { + signinApp.Run(async context => + { + var response = context.Response; + + // Setting DefaultAuthenticateScheme causes User to be set + // var user = context.User; + + // This is what [Authorize] calls + var userResult = await context.AuthenticateAsync(); + var user = userResult.Principal; + var authProperties = userResult.Properties; + + // This is what [Authorize(ActiveAuthenticationSchemes = MicrosoftAccountDefaults.AuthenticationScheme)] calls + // var user = await context.AuthenticateAsync(MicrosoftAccountDefaults.AuthenticationScheme); + + // Deny anonymous request beyond this point. + if (!userResult.Succeeded || user == null || !user.Identities.Any(identity => identity.IsAuthenticated)) + { + // This is what [Authorize] calls + // The cookie middleware will handle this and redirect to /login + await context.ChallengeAsync(); + + // This is what [Authorize(ActiveAuthenticationSchemes = MicrosoftAccountDefaults.AuthenticationScheme)] calls + // await context.ChallengeAsync(MicrosoftAccountDefaults.AuthenticationScheme); + + return; + } + + var currentAuthType = user.Identities.First().AuthenticationType; + if (string.Equals(GoogleDefaults.AuthenticationScheme, currentAuthType) + || string.Equals(MicrosoftAccountDefaults.AuthenticationScheme, currentAuthType)) + { + var refreshToken = authProperties.GetTokenValue("refresh_token"); + + if (string.IsNullOrEmpty(refreshToken)) + { + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("No refresh_token is available.
"); + await response.WriteAsync("Home"); + await response.WriteAsync(""); + return; + } + + var options = await GetOAuthOptionsAsync(context, currentAuthType); + + var pairs = new Dictionary() + { + { "client_id", options.ClientId }, + { "client_secret", options.ClientSecret }, + { "grant_type", "refresh_token" }, + { "refresh_token", refreshToken } + }; + var content = new FormUrlEncodedContent(pairs); + var refreshResponse = await options.Backchannel.PostAsync(options.TokenEndpoint, content, context.RequestAborted); + refreshResponse.EnsureSuccessStatusCode(); + + var payload = JObject.Parse(await refreshResponse.Content.ReadAsStringAsync()); + + // Persist the new acess token + authProperties.UpdateTokenValue("access_token", payload.Value("access_token")); + refreshToken = payload.Value("refresh_token"); + if (!string.IsNullOrEmpty(refreshToken)) + { + authProperties.UpdateTokenValue("refresh_token", refreshToken); + } + if (int.TryParse(payload.Value("expires_in"), NumberStyles.Integer, CultureInfo.InvariantCulture, out var seconds)) + { + var expiresAt = DateTimeOffset.UtcNow + TimeSpan.FromSeconds(seconds); + authProperties.UpdateTokenValue("expires_at", expiresAt.ToString("o", CultureInfo.InvariantCulture)); + } + await context.SignInAsync(user, authProperties); + + await PrintRefreshedTokensAsync(response, payload, authProperties); + + return; + } + // https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension + else if (string.Equals(FacebookDefaults.AuthenticationScheme, currentAuthType)) + { + var options = await GetOAuthOptionsAsync(context, currentAuthType); + + var accessToken = authProperties.GetTokenValue("access_token"); + + var query = new QueryBuilder() + { + { "grant_type", "fb_exchange_token" }, + { "client_id", options.ClientId }, + { "client_secret", options.ClientSecret }, + { "fb_exchange_token", accessToken }, + }.ToQueryString(); + + var refreshResponse = await options.Backchannel.GetStringAsync(options.TokenEndpoint + query); + var payload = JObject.Parse(refreshResponse); + + authProperties.UpdateTokenValue("access_token", payload.Value("access_token")); + if (int.TryParse(payload.Value("expires_in"), NumberStyles.Integer, CultureInfo.InvariantCulture, out var seconds)) + { + var expiresAt = DateTimeOffset.UtcNow + TimeSpan.FromSeconds(seconds); + authProperties.UpdateTokenValue("expires_at", expiresAt.ToString("o", CultureInfo.InvariantCulture)); + } + await context.SignInAsync(user, authProperties); + + await PrintRefreshedTokensAsync(response, payload, authProperties); + + return; + } + + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("Refresh has not been implemented for this provider.
"); + await response.WriteAsync("Home"); + await response.WriteAsync(""); }); }); @@ -233,12 +355,13 @@ namespace SocialSample { signoutApp.Run(async context => { - context.Response.ContentType = "text/html"; + var response = context.Response; + response.ContentType = "text/html"; await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - await context.Response.WriteAsync(""); - await context.Response.WriteAsync("You have been logged out. Goodbye " + context.User.Identity.Name + "
"); - await context.Response.WriteAsync("Home"); - await context.Response.WriteAsync(""); + await response.WriteAsync(""); + await response.WriteAsync("You have been logged out. Goodbye " + context.User.Identity.Name + "
"); + await response.WriteAsync("Home"); + await response.WriteAsync(""); }); }); @@ -247,11 +370,12 @@ namespace SocialSample { errorApp.Run(async context => { - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync(""); - await context.Response.WriteAsync("An remote failure has occurred: " + context.Request.Query["FailureMessage"] + "
"); - await context.Response.WriteAsync("Home"); - await context.Response.WriteAsync(""); + var response = context.Response; + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("An remote failure has occurred: " + context.Request.Query["FailureMessage"] + "
"); + await response.WriteAsync("Home"); + await response.WriteAsync(""); }); }); @@ -271,7 +395,7 @@ namespace SocialSample if (user == null || !user.Identities.Any(identity => identity.IsAuthenticated)) { // This is what [Authorize] calls - // The cookie middleware will intercept this 401 and redirect to /login + // The cookie middleware will handle this and redirect to /login await context.ChallengeAsync(); // This is what [Authorize(ActiveAuthenticationSchemes = MicrosoftAccountDefaults.AuthenticationScheme)] calls @@ -281,24 +405,63 @@ namespace SocialSample } // Display user information - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync(""); - await context.Response.WriteAsync("Hello " + (context.User.Identity.Name ?? "anonymous") + "
"); + var response = context.Response; + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("Hello " + (context.User.Identity.Name ?? "anonymous") + "
"); foreach (var claim in context.User.Claims) { - await context.Response.WriteAsync(claim.Type + ": " + claim.Value + "
"); + await response.WriteAsync(claim.Type + ": " + claim.Value + "
"); } - await context.Response.WriteAsync("Tokens:
"); + await response.WriteAsync("Tokens:
"); - await context.Response.WriteAsync("Access Token: " + await context.GetTokenAsync("access_token") + "
"); - await context.Response.WriteAsync("Refresh Token: " + await context.GetTokenAsync("refresh_token") + "
"); - await context.Response.WriteAsync("Token Type: " + await context.GetTokenAsync("token_type") + "
"); - await context.Response.WriteAsync("expires_at: " + await context.GetTokenAsync("expires_at") + "
"); - await context.Response.WriteAsync("Logout
"); - await context.Response.WriteAsync(""); + await response.WriteAsync("Access Token: " + await context.GetTokenAsync("access_token") + "
"); + await response.WriteAsync("Refresh Token: " + await context.GetTokenAsync("refresh_token") + "
"); + await response.WriteAsync("Token Type: " + await context.GetTokenAsync("token_type") + "
"); + await response.WriteAsync("expires_at: " + await context.GetTokenAsync("expires_at") + "
"); + await response.WriteAsync("Logout
"); + await response.WriteAsync("Refresh Token
"); + await response.WriteAsync(""); }); } + + private async Task GetOAuthOptionsAsync(HttpContext context, string currentAuthType) + { + if (string.Equals(GoogleDefaults.AuthenticationScheme, currentAuthType)) + { + return context.RequestServices.GetRequiredService>().Get(currentAuthType); + } + else if (string.Equals(MicrosoftAccountDefaults.AuthenticationScheme, currentAuthType)) + { + return context.RequestServices.GetRequiredService>().Get(currentAuthType); + } + else if (string.Equals(FacebookDefaults.AuthenticationScheme, currentAuthType)) + { + return context.RequestServices.GetRequiredService>().Get(currentAuthType); + } + + throw new NotImplementedException(currentAuthType); + } + + private async Task PrintRefreshedTokensAsync(HttpResponse response, JObject payload, AuthenticationProperties authProperties) + { + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("Refreshed.
"); + await response.WriteAsync(HtmlEncoder.Default.Encode(payload.ToString()).Replace(",", ",
") + "
"); + + await response.WriteAsync("
Tokens:
"); + + await response.WriteAsync("Access Token: " + authProperties.GetTokenValue("access_token") + "
"); + await response.WriteAsync("Refresh Token: " + authProperties.GetTokenValue("refresh_token") + "
"); + await response.WriteAsync("Token Type: " + authProperties.GetTokenValue("token_type") + "
"); + await response.WriteAsync("expires_at: " + authProperties.GetTokenValue("expires_at") + "
"); + + await response.WriteAsync("Home
"); + await response.WriteAsync("Refresh Token
"); + await response.WriteAsync(""); + } } } From c1250220508996a494d51627a8bd02b7792c012f Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 9 Aug 2017 15:29:34 -0700 Subject: [PATCH 787/900] #772 Fill in OIDC test gaps --- samples/SocialSample/Startup.cs | 2 +- .../OpenIdConnectChallengeTests.cs | 36 +++++++++++++------ .../OpenIdConnect/OpenIdConnectEventTests.cs | 14 ++++---- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index d69b25ee31..36a53b38ae 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -162,7 +162,7 @@ namespace SocialSample }) // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ - .AddOAuth("GitHub", o => + .AddOAuth("GitHub", "Github", o => { o.ClientId = Configuration["github:clientid"]; o.ClientSecret = Configuration["github:clientsecret"]; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index d21a1f4246..fb08ae2786 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -5,11 +5,12 @@ using System; using System.Linq; using System.Net; using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Primitives; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect @@ -19,7 +20,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect private static readonly string ChallengeEndpoint = TestServerBuilder.TestHost + TestServerBuilder.Challenge; [Fact] - public async Task ChallengeIsIssuedCorrectly() + public async Task ChallengeRedirectIsIssuedCorrectly() { var settings = new TestSettings( opt => @@ -86,7 +87,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect */ [Fact] - public async Task ChallengeIssueedCorrectlyForFormPost() + public async Task ChallengeFormPostIssuedCorrectly() { var settings = new TestSettings( opt => @@ -361,24 +362,37 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.Null(res.Headers.Location); } - [Fact] - public async Task ChallengeSetsNonceAndStateCookies() + [Theory] + [InlineData(OpenIdConnectRedirectBehavior.RedirectGet)] + [InlineData(OpenIdConnectRedirectBehavior.FormPost)] + public async Task ChallengeSetsNonceAndStateCookies(OpenIdConnectRedirectBehavior method) { var settings = new TestSettings(o => { + o.AuthenticationMethod = method; o.ClientId = "Test Id"; o.Authority = TestServerBuilder.DefaultAuthority; }); var server = settings.CreateTestServer(); var transaction = await server.SendAsync(ChallengeEndpoint); - var firstCookie = transaction.SetCookie.First(); - Assert.Contains(OpenIdConnectDefaults.CookieNoncePrefix, firstCookie); - Assert.Contains("expires", firstCookie); + var challengeCookies = SetCookieHeaderValue.ParseList(transaction.SetCookie); + var nonceCookie = challengeCookies.Where(cookie => cookie.Name.StartsWith(OpenIdConnectDefaults.CookieNoncePrefix, StringComparison.Ordinal)).Single(); + Assert.True(nonceCookie.Expires.HasValue); + Assert.True(nonceCookie.Expires > DateTime.UtcNow); + Assert.True(nonceCookie.HttpOnly); + Assert.Equal("/signin-oidc", nonceCookie.Path); + Assert.Equal("N", nonceCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.None, nonceCookie.SameSite); - var secondCookie = transaction.SetCookie.Skip(1).First(); - Assert.StartsWith(".AspNetCore.Correlation.OpenIdConnect.", secondCookie); - Assert.Contains("expires", secondCookie); + var correlationCookie = challengeCookies.Where(cookie => cookie.Name.StartsWith(".AspNetCore.Correlation.", StringComparison.Ordinal)).Single(); + Assert.True(correlationCookie.Expires.HasValue); + Assert.True(nonceCookie.Expires > DateTime.UtcNow); + Assert.True(correlationCookie.HttpOnly); + Assert.Equal("/signin-oidc", correlationCookie.Path); + Assert.False(StringSegment.IsNullOrEmpty(correlationCookie.Value)); + + Assert.Equal(2, challengeCookies.Count); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index 4ea69369e8..ed20d2f5ac 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnMessageReceived_Reject_NoMoreEventsRun() + public async Task OnMessageReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var remoteFailure = false; @@ -197,7 +197,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnTokenValidated_Reject_NoMoreEventsRun() + public async Task OnTokenValidated_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -385,7 +385,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnAuthorizationCodeReceived_Reject_NoMoreEventsRun() + public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -596,7 +596,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnTokenResponseReceived_Reject_NoMoreEventsRun() + public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -825,7 +825,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnTokenValidatedBackchannel_Reject_NoMoreEventsRun() + public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() { var messageReceived = false; var codeReceived = false; @@ -1060,7 +1060,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnUserInformationReceived_Reject_NoMoreEventsRun() + public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -1321,7 +1321,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task OnAuthenticationFailed_Reject_NoMoreEventsRun() + public async Task OnAuthenticationFailed_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; From 4eb1306692a7592210250e47a585fc47e40b7c2c Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Fri, 11 Aug 2017 10:24:18 -0700 Subject: [PATCH 788/900] Reacting to ResponseCookie Delete changes (#1362) https://github.com/aspnet/HttpAbstractions/commit/594f55947f4c1d0a9d3122e3f39bcfa81199b12a --- .../Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index 49089234ee..7c34f950a5 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -273,7 +273,7 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test Assert.NotNull(transaction.SetCookie); Assert.Equal(1, transaction.SetCookie.Count); - Assert.Equal("A=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("A=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; secure; samesite=lax", transaction.SetCookie[0]); } [Fact] From 0c82d94a544caa7f39f1692c46d8d16a833daaa8 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 11 Aug 2017 11:50:25 -0700 Subject: [PATCH 789/900] #772 Signout FormPost test (#1358) --- .../OpenIdConnect/OpenIdConnectTests.cs | 36 +++++--- .../OpenIdConnect/TestSettings.cs | 90 ++++++++++++++----- 2 files changed, 91 insertions(+), 35 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index b7ac1f82d5..32be26d33e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -182,27 +182,39 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } [Fact] - public async Task SignOutWithDefaultRedirectUri() + public async Task SignOutFormPostWithDefaultRedirectUri() { - var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); - var server = TestServerBuilder.CreateServer(o => + var settings = new TestSettings(o => { + o.AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost; o.Authority = TestServerBuilder.DefaultAuthority; o.ClientId = "Test Id"; - o.Configuration = configuration; }); + var server = settings.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + + settings.ValidateSignoutFormPost(transaction, + OpenIdConnectParameterNames.PostLogoutRedirectUri); + } + + [Fact] + public async Task SignOutRedirectWithDefaultRedirectUri() + { + var settings = new TestSettings(o => + { + o.AuthenticationMethod = OpenIdConnectRedirectBehavior.RedirectGet; + o.Authority = TestServerBuilder.DefaultAuthority; + o.ClientId = "Test Id"; + }); + var server = settings.CreateTestServer(); var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.True(transaction.Response.Headers.Location.AbsoluteUri.StartsWith(configuration.EndSessionEndpoint)); - var query = transaction.Response.Headers.Location.Query.Substring(1).Split('&') - .Select(each => each.Split('=')) - .ToDictionary(pair => pair[0], pair => pair[1]); - - string redirectUri; - Assert.True(query.TryGetValue("post_logout_redirect_uri", out redirectUri)); - Assert.Equal(UrlEncoder.Default.Encode("https://example.com/signout-callback-oidc"), redirectUri, true); + settings.ValidateSignoutRedirect(transaction.Response.Headers.Location, + OpenIdConnectParameterNames.PostLogoutRedirectUri); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 9d9e5537fe..bf9df40384 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -80,6 +80,44 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect return formInputs; } + public IDictionary ValidateSignoutFormPost(TestTransaction transaction, params string[] parametersToValidate) + { + IDictionary formInputs = null; + var errors = new List(); + var xdoc = XDocument.Parse(transaction.ResponseText.Replace("doctype", "DOCTYPE")); + var forms = xdoc.Descendants("form"); + if (forms.Count() != 1) + { + errors.Add("Only one form element is expected in response body."); + } + else + { + formInputs = forms.Single() + .Elements("input") + .ToDictionary(elem => elem.Attribute("name").Value, + elem => elem.Attribute("value").Value); + + ValidateParameters(formInputs, parametersToValidate, errors, htmlEncoded: false); + } + + if (errors.Any()) + { + var buf = new StringBuilder(); + buf.AppendLine($"The signout form post is not valid."); + // buf.AppendLine(); + + foreach (var error in errors) + { + buf.AppendLine(error); + } + + Debug.WriteLine(buf.ToString()); + Assert.True(false, buf.ToString()); + } + + return formInputs; + } + public IDictionary ValidateChallengeRedirect(Uri redirectUri, params string[] parametersToValidate) => ValidateRedirectCore(redirectUri, OpenIdConnectRequestType.Authentication, parametersToValidate); @@ -156,6 +194,9 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect case OpenIdConnectParameterNames.VersionTelemetry: ValidateVersionTelemetry(actualValues, errors, htmlEncoded); break; + case OpenIdConnectParameterNames.PostLogoutRedirectUri: + ValidatePostLogoutRedirectUri(actualValues, errors, htmlEncoded); + break; default: throw new InvalidOperationException($"Unknown parameter \"{paramToValidate}\"."); } @@ -186,42 +227,45 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } } - private void ValidateClientId(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.ClientId, _options.ClientId, actualQuery, errors, htmlEncoded); + private void ValidateClientId(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.ClientId, _options.ClientId, actualParams, errors, htmlEncoded); - private void ValidateResponseType(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.ResponseType, _options.ResponseType, actualQuery, errors, htmlEncoded); + private void ValidateResponseType(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.ResponseType, _options.ResponseType, actualParams, errors, htmlEncoded); - private void ValidateResponseMode(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.ResponseMode, _options.ResponseMode, actualQuery, errors, htmlEncoded); + private void ValidateResponseMode(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.ResponseMode, _options.ResponseMode, actualParams, errors, htmlEncoded); - private void ValidateScope(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.Scope, string.Join(" ", _options.Scope), actualQuery, errors, htmlEncoded); + private void ValidateScope(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.Scope, string.Join(" ", _options.Scope), actualParams, errors, htmlEncoded); - private void ValidateRedirectUri(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, TestServerBuilder.TestHost + _options.CallbackPath, actualQuery, errors, htmlEncoded); + private void ValidateRedirectUri(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.RedirectUri, TestServerBuilder.TestHost + _options.CallbackPath, actualParams, errors, htmlEncoded); - private void ValidateResource(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, _options.Resource, actualQuery, errors, htmlEncoded); + private void ValidateResource(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.RedirectUri, _options.Resource, actualParams, errors, htmlEncoded); - private void ValidateState(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.State, ExpectedState, actualQuery, errors, htmlEncoded); + private void ValidateState(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); - private void ValidateSkuTelemetry(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET", actualQuery, errors, htmlEncoded); + private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET", actualParams, errors, htmlEncoded); - private void ValidateVersionTelemetry(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.VersionTelemetry, typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualQuery, errors, htmlEncoded); + private void ValidateVersionTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.VersionTelemetry, typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualParams, errors, htmlEncoded); - private void ValidateQueryParameter( + private void ValidatePostLogoutRedirectUri(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.PostLogoutRedirectUri, "https://example.com/signout-callback-oidc", actualParams, errors, htmlEncoded); + + private void ValidateParameter( string parameterName, string expectedValue, - IDictionary actualQuery, + IDictionary actualParams, ICollection errors, bool htmlEncoded) { string actualValue; - if (actualQuery.TryGetValue(parameterName, out actualValue)) + if (actualParams.TryGetValue(parameterName, out actualValue)) { if (htmlEncoded) { @@ -230,12 +274,12 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect if (actualValue != expectedValue) { - errors.Add($"Query parameter {parameterName}'s expected value is {expectedValue} but its actual value is {actualValue}"); + errors.Add($"Parameter {parameterName}'s expected value is '{expectedValue}' but its actual value is '{actualValue}'"); } } else { - errors.Add($"Query parameter {parameterName} is missing"); + errors.Add($"Parameter {parameterName} is missing"); } } } From 43db99a5686471641eed7913d71dab2dcf0d2464 Mon Sep 17 00:00:00 2001 From: Saravanan Date: Mon, 14 Aug 2017 22:59:02 +0530 Subject: [PATCH 790/900] =?UTF-8?q?Updated=20for=20the=20TwitterOptions=20?= =?UTF-8?q?Validation=20for=20the=20ConsumerKey=20and=20Con=E2=80=A6=20(#1?= =?UTF-8?q?337)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TwitterOptions.cs | 18 +++++++++++ .../TwitterTests.cs | 32 ++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 0190f21a6b..86919d0925 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -3,6 +3,7 @@ using System; using System.Security.Claims; +using System.Globalization; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Http; @@ -86,6 +87,23 @@ namespace Microsoft.AspNetCore.Authentication.Twitter set => _stateCookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); } + /// + /// Added the validate method to ensure that the customer key and customer secret values are not not empty for the twitter authentication middleware + /// + public override void Validate() + { + base.Validate(); + if (string.IsNullOrEmpty(ConsumerKey)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(ConsumerKey)), nameof(ConsumerKey)); + } + + if (string.IsNullOrEmpty(ConsumerSecret)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(ConsumerSecret)), nameof(ConsumerSecret)); + } + } + private class TwitterCookieBuilder : CookieBuilder { private readonly TwitterOptions _twitterOptions; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 1c387d889a..746dfee6ab 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter } }; }, - context => + context => { // REVIEW: Gross context.ChallengeAsync("Twitter").GetAwaiter().GetResult(); @@ -75,6 +75,36 @@ namespace Microsoft.AspNetCore.Authentication.Twitter Assert.Contains("custom=test", query); } + /// + /// Validates the Twitter Options to check if the Consumer Key is missing in the TwitterOptions and if so throws the ArgumentException + /// + /// + [Fact] + public async Task ThrowsIfClientIdMissing() + { + var server = CreateServer(o => + { + o.ConsumerSecret = "Test Consumer Secret"; + }); + + await Assert.ThrowsAsync("ConsumerKey", async () => await server.SendAsync("http://example.com/challenge")); + } + + /// + /// Validates the Twitter Options to check if the Consumer Secret is missing in the TwitterOptions and if so throws the ArgumentException + /// + /// + [Fact] + public async Task ThrowsIfClientSecretMissing() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + }); + + await Assert.ThrowsAsync("ConsumerSecret", async () => await server.SendAsync("http://example.com/challenge")); + } + [Fact] public async Task BadSignInWillThrow() { From b43ffc4acc6c38bc421678e9fe46da5585147c80 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Mon, 14 Aug 2017 13:06:32 -0500 Subject: [PATCH 791/900] Recommend CookieBuilder.HttpOnly instead of CookieBuilder.SameSite (#1366) --- .../CookieAuthenticationOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index ec67ecc181..420435dafc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -196,7 +196,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// to script on the page. /// ///
- [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.SameSite) + ".")] + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.HttpOnly) + ".")] public bool CookieHttpOnly { get => Cookie.HttpOnly; set => Cookie.HttpOnly = value; } /// From 488eb44467eb677eab62bdc49aa6255cc1be3119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Mon, 14 Aug 2017 20:07:19 +0200 Subject: [PATCH 792/900] Fix obsolete warning message (#1363) Fixes the messaged shown to developers when they are updating their applications to 2.0. Bad idea to set the domain with some random naming text. --- .../CookieAuthenticationOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 420435dafc..0f2dbd3124 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// system uses the cookie authentication handler multiple times. /// /// - [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Domain) + ".")] + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Name) + ".")] public string CookieName { get => Cookie.Name; set => Cookie.Name = value; } /// From 5b29bced0d2f1cfc78843bcd9ec9a828c6fb5fef Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 22 Aug 2017 18:12:32 -0700 Subject: [PATCH 793/900] Upgrade to xunit 2.3.0-beta4 Includes changes to assertions as required by xunit.analyzers 0.6 --- build/dependencies.props | 5 +-- .../CookieTests.cs | 24 ++++++------- ...soft.AspNetCore.Authentication.Test.csproj | 1 + .../TicketSerializerTests.cs | 8 ++--- .../TokenExtensionTests.cs | 2 +- .../AuthorizationPolicyFacts.cs | 34 +++++++++---------- .../TicketInteropTests.cs | 2 +- 7 files changed, 39 insertions(+), 37 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a97cae9f61..0f73dd1b42 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -10,7 +10,8 @@ 2.0.0-* 3.0.1 2.0.0-* - 15.3.0-* - 2.3.0-beta2-* + 15.3.0 + 0.6.1 + 2.3.0-beta4-build3742 diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index c711fde493..d346c68d7f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -54,8 +54,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await SendAsync(server, "http://example.com/challenge?X-Requested-With=XMLHttpRequest"); Assert.Equal(HttpStatusCode.Unauthorized, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); - Assert.Equal(1, responded.Count()); - Assert.True(responded.Single().StartsWith("http://example.com/login")); + Assert.Single(responded); + Assert.StartsWith("http://example.com/login", responded.Single()); } [Fact] @@ -65,8 +65,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await SendAsync(server, "http://example.com/forbid?X-Requested-With=XMLHttpRequest"); Assert.Equal(HttpStatusCode.Forbidden, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); - Assert.Equal(1, responded.Count()); - Assert.True(responded.Single().StartsWith("http://example.com/denied")); + Assert.Single(responded); + Assert.StartsWith("http://example.com/denied", responded.Single()); } [Fact] @@ -76,8 +76,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await SendAsync(server, "http://example.com/signout?X-Requested-With=XMLHttpRequest&ReturnUrl=/"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); - Assert.Equal(1, responded.Count()); - Assert.True(responded.Single().StartsWith("/")); + Assert.Single(responded); + Assert.StartsWith("/", responded.Single()); } [Fact] @@ -87,8 +87,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await SendAsync(server, "http://example.com/challenge?X-Requested-With=XMLHttpRequest&ReturnUrl=/"); Assert.Equal(HttpStatusCode.Unauthorized, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); - Assert.Equal(1, responded.Count()); - Assert.True(responded.Single().StartsWith("http://example.com/Account/Login")); + Assert.Single(responded); + Assert.StartsWith("http://example.com/Account/Login", responded.Single()); } [Fact] @@ -439,7 +439,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies // signout wins over renew var transaction4 = await server.SendAsync("http://example.com/signout", transaction3.SetCookie[0]); - Assert.Equal(1, transaction4.SetCookie.Count()); + Assert.Single(transaction4.SetCookie); Assert.Contains(".AspNetCore.Cookies=; expires=", transaction4.SetCookie[0]); } @@ -717,7 +717,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies new Uri("http://example.com/base")); var transaction1 = await SendAsync(server, "http://example.com/base/testpath"); - Assert.True(transaction1.SetCookie.Contains("path=/base")); + Assert.Contains("path=/base", transaction1.SetCookie); } [Fact] @@ -848,7 +848,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await server.SendAsync("http://example.com"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.True(transaction.SetCookie[0].StartsWith("One=")); + Assert.StartsWith("One=", transaction.SetCookie[0]); } [Fact] @@ -871,7 +871,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await server.SendAsync("http://example.com"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.True(transaction.SetCookie[0].StartsWith("One=")); + Assert.StartsWith("One=", transaction.SetCookie[0]); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 1529dc8036..fc73325e0b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -23,6 +23,7 @@ + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs index b37ae53d5b..a1e58743b6 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Authentication serializer.Write(writer, ticket); stream.Position = 0; var readTicket = serializer.Read(reader); - Assert.Equal(0, readTicket.Principal.Identities.Count()); + Assert.Empty(readTicket.Principal.Identities); Assert.Equal("bye", readTicket.Properties.RedirectUri); Assert.Equal("Hello", readTicket.AuthenticationScheme); } @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Authentication serializer.Write(writer, ticket); stream.Position = 0; var readTicket = serializer.Read(reader); - Assert.Equal(1, readTicket.Principal.Identities.Count()); + Assert.Single(readTicket.Principal.Identities); Assert.Equal("misc", readTicket.Principal.Identity.AuthenticationType); Assert.Equal("bootstrap", readTicket.Principal.Identities.First().BootstrapContext); } @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Authentication serializer.Write(writer, ticket); stream.Position = 0; var readTicket = serializer.Read(reader); - Assert.Equal(1, readTicket.Principal.Identities.Count()); + Assert.Single(readTicket.Principal.Identities); Assert.Equal("misc", readTicket.Principal.Identity.AuthenticationType); var identity = (ClaimsIdentity) readTicket.Principal.Identity; @@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Authentication serializer.Write(writer, ticket); stream.Position = 0; var readTicket = serializer.Read(reader); - Assert.Equal(1, readTicket.Principal.Identities.Count()); + Assert.Single(readTicket.Principal.Identities); Assert.Equal("misc", readTicket.Principal.Identity.AuthenticationType); var readClaim = readTicket.Principal.FindFirst("type"); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs index 05e5708de0..4d4023bee5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Authentication Assert.Null(props.GetTokenValue("One")); Assert.Null(props.GetTokenValue("Two")); Assert.Null(props.GetTokenValue("Three")); - Assert.Equal(1, props.GetTokens().Count()); + Assert.Single(props.GetTokens()); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs index 714b26c7e1..3eefb7af7b 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -40,12 +40,12 @@ namespace Microsoft.AspNetCore.Authroization.Test // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); - Assert.True(combined.AuthenticationSchemes.Contains("dupe")); - Assert.True(combined.AuthenticationSchemes.Contains("roles")); + Assert.Contains("dupe", combined.AuthenticationSchemes); + Assert.Contains("roles", combined.AuthenticationSchemes); Assert.Equal(4, combined.Requirements.Count()); - Assert.True(combined.Requirements.Any(r => r is DenyAnonymousAuthorizationRequirement)); + Assert.Contains(combined.Requirements, r => r is DenyAnonymousAuthorizationRequirement); Assert.Equal(2, combined.Requirements.OfType().Count()); - Assert.Equal(1, combined.Requirements.OfType().Count()); + Assert.Single(combined.Requirements.OfType()); } [Fact] @@ -67,10 +67,10 @@ namespace Microsoft.AspNetCore.Authroization.Test // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); - Assert.True(combined.AuthenticationSchemes.Contains("dupe")); - Assert.True(combined.AuthenticationSchemes.Contains("default")); + Assert.Contains("dupe", combined.AuthenticationSchemes); + Assert.Contains("default", combined.AuthenticationSchemes); Assert.Equal(2, combined.Requirements.Count()); - Assert.False(combined.Requirements.Any(r => r is DenyAnonymousAuthorizationRequirement)); + Assert.DoesNotContain(combined.Requirements, r => r is DenyAnonymousAuthorizationRequirement); Assert.Equal(2, combined.Requirements.OfType().Count()); } @@ -88,11 +88,11 @@ namespace Microsoft.AspNetCore.Authroization.Test var combined = await AuthorizationPolicy.CombineAsync(provider, attributes); // Assert - Assert.True(combined.Requirements.Any(r => r is RolesAuthorizationRequirement)); + Assert.Contains(combined.Requirements, r => r is RolesAuthorizationRequirement); var rolesAuthorizationRequirement = combined.Requirements.OfType().First(); Assert.Equal(2, rolesAuthorizationRequirement.AllowedRoles.Count()); - Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r1"))); - Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r2"))); + Assert.Contains(rolesAuthorizationRequirement.AllowedRoles, r => r.Equals("r1")); + Assert.Contains(rolesAuthorizationRequirement.AllowedRoles, r => r.Equals("r2")); } [Fact] @@ -111,8 +111,8 @@ namespace Microsoft.AspNetCore.Authroization.Test // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); - Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a1"))); - Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a2"))); + Assert.Contains(combined.AuthenticationSchemes, a => a.Equals("a1")); + Assert.Contains(combined.AuthenticationSchemes, a => a.Equals("a2")); } [Fact] @@ -131,8 +131,8 @@ namespace Microsoft.AspNetCore.Authroization.Test // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); - Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a1"))); - Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a2"))); + Assert.Contains(combined.AuthenticationSchemes, a => a.Equals("a1")); + Assert.Contains(combined.AuthenticationSchemes, a => a.Equals("a2")); } [Fact] @@ -149,11 +149,11 @@ namespace Microsoft.AspNetCore.Authroization.Test var combined = await AuthorizationPolicy.CombineAsync(provider, attributes); // Assert - Assert.True(combined.Requirements.Any(r => r is RolesAuthorizationRequirement)); + Assert.Contains(combined.Requirements, r => r is RolesAuthorizationRequirement); var rolesAuthorizationRequirement = combined.Requirements.OfType().First(); Assert.Equal(2, rolesAuthorizationRequirement.AllowedRoles.Count()); - Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r1"))); - Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r2"))); + Assert.Contains(rolesAuthorizationRequirement.AllowedRoles, r => r.Equals("r1")); + Assert.Contains(rolesAuthorizationRequirement.AllowedRoles, r => r.Equals("r2")); } } } \ No newline at end of file diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs index b14ea0d74e..769adc015b 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -35,7 +35,7 @@ namespace Microsoft.Owin.Security.Interop.Test var newTicket = newSerializer.Deserialize(bytes); Assert.NotNull(newTicket); - Assert.Equal(1, newTicket.Principal.Identities.Count()); + Assert.Single(newTicket.Principal.Identities); var newIdentity = newTicket.Principal.Identity as ClaimsIdentity; Assert.NotNull(newIdentity); Assert.Equal("scheme", newIdentity.AuthenticationType); From 414d596639d56633a789e039406eacecbe464f82 Mon Sep 17 00:00:00 2001 From: Brian Chavez Date: Sun, 27 Aug 2017 21:03:29 -0700 Subject: [PATCH 794/900] Spelling and grammar cleanup (#1391) --- .../Claims/ClaimAction.cs | 4 ++-- .../DefaultAuthorizationService.cs | 6 +++--- .../IAuthorizationService.cs | 2 +- .../Infrastructure/PassThroughAuthorizationHandler.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs index 965ca5fdb3..78b63bb38e 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs @@ -31,10 +31,10 @@ namespace Microsoft.AspNetCore.Authentication.OAuth.Claims public string ValueType { get; } /// - /// Exhamine the given userData json, determine if the requisite data is present, and optionally add it + /// Examine the given userData json, determine if the requisite data is present, and optionally add it /// as a new Claim on the ClaimsIdentity. /// - /// The source data to exhamine. This value may be null. + /// The source data to examine. This value may be null. /// The identity to add Claims to. /// The value to use for Claim.Issuer when creating a Claim. public abstract void Run(JObject userData, ClaimsIdentity identity, string issuer); diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 3380f64b14..9773ebbcc2 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Authorization /// The handlers used to fulfill s. /// The logger used to log messages, warnings and errors. /// The used to create the context to handle the authorization. - /// The used to determine if authorzation was successful. + /// The used to determine if authorization was successful. /// The used. public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IAuthorizationHandlerProvider handlers, ILogger logger, IAuthorizationHandlerContextFactory contextFactory, IAuthorizationEvaluator evaluator, IOptions options) { @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Authorization /// The resource to evaluate the requirements against. /// The requirements to evaluate. /// - /// A flag indicating whether authorization has succeded. + /// A flag indicating whether authorization has succeeded. /// This value is true when the user fulfills the policy otherwise false. /// public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) @@ -136,7 +136,7 @@ namespace Microsoft.AspNetCore.Authorization /// The resource the policy should be checked with. /// The name of the policy to check against a specific context. /// - /// A flag indicating whether authorization has succeded. + /// A flag indicating whether authorization has succeeded. /// This value is true when the user fulfills the policy otherwise false. /// public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs index 32af746072..8976425ba6 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Authorization /// /// A flag indicating whether authorization has succeeded. /// Returns a flag indicating whether the user, and optional resource has fulfilled the policy. - /// true when the the policy has been fulfilled; otherwise false. + /// true when the policy has been fulfilled; otherwise false. /// /// /// Resource is an optional parameter and may be null. Please ensure that you check it is not diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs index 60fd66b85c..6f0b8293f8 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization.Infrastructure { /// - /// Infrastructre class which allows an to + /// Infrastructure class which allows an to /// be its own . /// public class PassThroughAuthorizationHandler : IAuthorizationHandler From c8a99e580683b6d9d999d066d56cceeac301c091 Mon Sep 17 00:00:00 2001 From: Damir Ainullin Date: Mon, 28 Aug 2017 20:12:27 +0300 Subject: [PATCH 795/900] Removed redundant if checks (#1390) --- .../AuthenticationHandler.cs | 2 +- test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index d1d09f0746..812ba2f1a8 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -142,7 +142,7 @@ namespace Microsoft.AspNetCore.Authentication Logger.AuthenticationSchemeNotAuthenticated(Scheme.Name); } } - else if (result?.Failure != null) + else { Logger.AuthenticationSchemeNotAuthenticatedWithFailure(Scheme.Name, result.Failure.Message); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index d346c68d7f..789f5ede9c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -1325,11 +1325,11 @@ namespace Microsoft.AspNetCore.Authentication.Cookies res.StatusCode = 200; res.ContentType = "text/xml"; var xml = new XElement("xml"); - if (result != null && result?.Ticket?.Principal != null) + if (result?.Ticket?.Principal != null) { xml.Add(result.Ticket.Principal.Claims.Select(claim => new XElement("claim", new XAttribute("type", claim.Type), new XAttribute("value", claim.Value)))); } - if (result != null && result?.Ticket?.Properties != null) + if (result?.Ticket?.Properties != null) { xml.Add(result.Ticket.Properties.Items.Select(extra => new XElement("extra", new XAttribute("type", extra.Key), new XAttribute("value", extra.Value)))); } From bf685de16be9949d67e93cc058ef4393f005756b Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 24 Aug 2017 11:52:57 -0700 Subject: [PATCH 796/900] Using WebEncoders' Base64Url encode/decode functionality --- src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs b/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs index c0663295cf..1f7ecc7184 100644 --- a/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs +++ b/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Authentication /// Base64 encoded string modified with non-URL encodable characters public static string Encode(byte[] data) { - return WebUtilities.Base64UrlTextEncoder.Encode(data); + return WebUtilities.WebEncoders.Base64UrlEncode(data); } /// @@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Authentication /// The decoded data. public static byte[] Decode(string text) { - return WebUtilities.Base64UrlTextEncoder.Decode(text); + return WebUtilities.WebEncoders.Base64UrlDecode(text); } } } From 724be48ee90e0ed895f09a27b7219365b097197f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 29 Aug 2017 15:24:01 -0700 Subject: [PATCH 797/900] Use Directory.Build.props/targets --- appveyor.yml => .appveyor.yml | 0 build/common.props => Directory.Build.props | 13 ++++--------- Directory.Build.targets | 2 ++ Security.sln | 11 +++++++++-- samples/CookieSample/CookieSample.csproj | 4 +--- .../CookieSessionSample/CookieSessionSample.csproj | 4 +--- samples/JwtBearerSample/JwtBearerSample.csproj | 4 +--- .../OpenIdConnect.AzureAdSample.csproj | 2 -- .../OpenIdConnectSample/OpenIdConnectSample.csproj | 2 -- samples/SocialSample/SocialSample.csproj | 2 -- samples/SocialSample/Startup.cs | 10 +++++----- src/Directory.Build.props | 7 +++++++ ...crosoft.AspNetCore.Authentication.Cookies.csproj | 2 -- ...rosoft.AspNetCore.Authentication.Facebook.csproj | 2 -- ...icrosoft.AspNetCore.Authentication.Google.csproj | 2 -- ...osoft.AspNetCore.Authentication.JwtBearer.csproj | 3 +-- ...spNetCore.Authentication.MicrosoftAccount.csproj | 2 -- ...Microsoft.AspNetCore.Authentication.OAuth.csproj | 4 +--- ...t.AspNetCore.Authentication.OpenIdConnect.csproj | 3 +-- ...crosoft.AspNetCore.Authentication.Twitter.csproj | 2 -- .../Microsoft.AspNetCore.Authentication.csproj | 2 -- ...Microsoft.AspNetCore.Authorization.Policy.csproj | 4 +--- .../Microsoft.AspNetCore.Authorization.csproj | 4 +--- .../Microsoft.AspNetCore.CookiePolicy.csproj | 2 -- .../Microsoft.Owin.Security.Interop.csproj | 2 -- test/Directory.Build.props | 12 ++++++++++++ .../Microsoft.AspNetCore.Authentication.Test.csproj | 7 ------- .../Microsoft.AspNetCore.Authorization.Test.csproj | 6 ------ ...etCore.ChunkingCookieManager.Sources.Test.csproj | 5 ----- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 6 +----- .../Microsoft.Owin.Security.Interop.Test.csproj | 13 +++---------- 31 files changed, 51 insertions(+), 93 deletions(-) rename appveyor.yml => .appveyor.yml (100%) rename build/common.props => Directory.Build.props (59%) create mode 100644 Directory.Build.targets create mode 100644 src/Directory.Build.props create mode 100644 test/Directory.Build.props diff --git a/appveyor.yml b/.appveyor.yml similarity index 100% rename from appveyor.yml rename to .appveyor.yml diff --git a/build/common.props b/Directory.Build.props similarity index 59% rename from build/common.props rename to Directory.Build.props index ea940214e6..e28500d6bd 100644 --- a/build/common.props +++ b/Directory.Build.props @@ -1,20 +1,15 @@ - - - + + + Microsoft ASP.NET Core https://github.com/aspnet/Security git - $(MSBuildThisFileDirectory)Key.snk + $(MSBuildThisFileDirectory)build\Key.snk true true $(VersionSuffix)-$(BuildNumber) true - - - - - diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000000..f75adf7e4d --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,2 @@ + + diff --git a/Security.sln b/Security.sln index 2e5ee56d00..811893c33a 100644 --- a/Security.sln +++ b/Security.sln @@ -1,14 +1,20 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26621.2 +VisualStudioVersion = 15.0.26730.10 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" + ProjectSection(SolutionItems) = preProject + src\Directory.Build.props = src\Directory.Build.props + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F8C0AA27-F3FB-4286-8E4C-47EF86B539FF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookieSample", "samples\CookieSample\CookieSample.csproj", "{558C2C2A-AED8-49DE-BB60-D5F8AE06C714}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{7BF11F3A-60B6-4796-B504-579C67FFBA34}" + ProjectSection(SolutionItems) = preProject + test\Directory.Build.props = test\Directory.Build.props + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SocialSample", "samples\SocialSample\SocialSample.csproj", "{8C73D216-332D-41D8-BFD0-45BC4BC36552}" EndProject @@ -56,8 +62,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Chunki EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86BD08B1-F978-4F58-9982-2A017807F01C}" ProjectSection(SolutionItems) = preProject - build\common.props = build\common.props build\dependencies.props = build\dependencies.props + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets build\Key.snk = build\Key.snk NuGet.config = NuGet.config build\repo.props = build\repo.props diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 64438de77d..52e6efb492 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,6 +1,4 @@ - - - + net461;netcoreapp2.0 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index cb07f4385b..5cb7e9c09d 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,6 +1,4 @@ - - - + net461;netcoreapp2.0 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index fe2a5fa9d9..6c9bd99dc9 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,6 +1,4 @@ - - - + net461;netcoreapp2.0 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index cd8b6976f2..9ad1abc425 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,7 +1,5 @@  - - net461;netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index b3d875d474..301828b01e 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,7 +1,5 @@  - - net461;netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index d35796f759..02f214557e 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,7 +1,5 @@  - - net461;netcoreapp2.0 aspnet5-SocialSample-20151210111056 diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 36a53b38ae..a0b193b8e2 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -415,7 +415,7 @@ namespace SocialSample } await response.WriteAsync("Tokens:
"); - + await response.WriteAsync("Access Token: " + await context.GetTokenAsync("access_token") + "
"); await response.WriteAsync("Refresh Token: " + await context.GetTokenAsync("refresh_token") + "
"); await response.WriteAsync("Token Type: " + await context.GetTokenAsync("token_type") + "
"); @@ -426,19 +426,19 @@ namespace SocialSample }); } - private async Task GetOAuthOptionsAsync(HttpContext context, string currentAuthType) + private Task GetOAuthOptionsAsync(HttpContext context, string currentAuthType) { if (string.Equals(GoogleDefaults.AuthenticationScheme, currentAuthType)) { - return context.RequestServices.GetRequiredService>().Get(currentAuthType); + return Task.FromResult(context.RequestServices.GetRequiredService>().Get(currentAuthType)); } else if (string.Equals(MicrosoftAccountDefaults.AuthenticationScheme, currentAuthType)) { - return context.RequestServices.GetRequiredService>().Get(currentAuthType); + return Task.FromResult(context.RequestServices.GetRequiredService>().Get(currentAuthType)); } else if (string.Equals(FacebookDefaults.AuthenticationScheme, currentAuthType)) { - return context.RequestServices.GetRequiredService>().Get(currentAuthType); + return Task.FromResult(context.RequestServices.GetRequiredService>().Get(currentAuthType)); } throw new NotImplementedException(currentAuthType); diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000000..d704a37df9 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 712aa81772..b188a58e08 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core middleware that enables an application to use cookie based authentication. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index a9ec571996..62aee1367f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index 805de682fd..de8867f91a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index fe0bda1647..5de668e1a3 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -1,5 +1,4 @@ - - + ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 9437b57276..0eddc6f764 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index a15a75ee6f..318c18e743 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -1,6 +1,4 @@ - - - + ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index ae8ffd8d59..413d5d0257 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -1,5 +1,4 @@ - - + ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index d9c5cd0b37..f720d08f04 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 8a1f970423..8f48bf6854 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core common types used by the various authentication middleware components. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index 83530a2bed..17a027690d 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core authorization policy helper classes. netstandard2.0 @@ -16,7 +14,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 15100fbbcc..01e1dd3149 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -1,6 +1,4 @@ - - - + ASP.NET Core authorization classes. diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 5dc2cd9281..80fd59eb4a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core cookie policy classes to control the behavior of cookies. netstandard2.0 diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index 10a8be30f5..71c07fa140 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -1,7 +1,5 @@  - - A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication. net461 diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 0000000000..b9ef98116d --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index fc73325e0b..7f3e739f33 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0;net461 netcoreapp2.0 @@ -21,11 +19,6 @@ - - - - - diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 6eb74aeebf..5192ee4fe5 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0;net461 netcoreapp2.0 @@ -14,12 +12,8 @@ - - - - diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index b578f5dcfa..d75c0a47d2 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0;net461 netcoreapp2.0 @@ -13,9 +11,6 @@ - - - diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index f513de4b35..96db2b38f3 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -1,6 +1,5 @@ - + - netcoreapp2.0;net461 netcoreapp2.0 @@ -14,9 +13,6 @@ - - - diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 14c0aa2f1f..5e1e2eb92c 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -1,7 +1,5 @@  - - net461 @@ -9,17 +7,12 @@ - - - - - - - - + + + From a53bf093a7d86b35e019c80515c92d7626982325 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 29 Aug 2017 15:26:04 -0700 Subject: [PATCH 798/900] Use PackageLineup to manage PackageReference versions --- Directory.Build.props | 1 - Directory.Build.targets | 14 +++++++++++++- NuGet.config | 1 - build/dependencies.props | 17 ----------------- build/repo.props | 6 ++++-- samples/CookieSample/CookieSample.csproj | 12 ++++++------ .../CookieSessionSample.csproj | 12 ++++++------ samples/JwtBearerSample/JwtBearerSample.csproj | 12 ++++++------ .../OpenIdConnect.AzureAdSample.csproj | 14 +++++++------- .../OpenIdConnectSample.csproj | 18 +++++++++--------- samples/SocialSample/SocialSample.csproj | 18 +++++++++--------- src/Directory.Build.props | 2 +- ....AspNetCore.Authentication.JwtBearer.csproj | 8 +++++++- ...soft.AspNetCore.Authentication.OAuth.csproj | 5 ++++- ...NetCore.Authentication.OpenIdConnect.csproj | 8 +++++++- .../Microsoft.AspNetCore.Authentication.csproj | 16 ++++++++-------- ...soft.AspNetCore.Authorization.Policy.csproj | 4 ++-- .../Microsoft.AspNetCore.Authorization.csproj | 4 ++-- .../Microsoft.AspNetCore.CookiePolicy.csproj | 4 ++-- .../Microsoft.Owin.Security.Interop.csproj | 4 ++-- test/Directory.Build.props | 12 ++++++------ ...osoft.AspNetCore.Authentication.Test.csproj | 2 +- ...rosoft.AspNetCore.Authorization.Test.csproj | 6 +++--- ...e.ChunkingCookieManager.Sources.Test.csproj | 2 +- ...crosoft.AspNetCore.CookiePolicy.Test.csproj | 4 ++-- ...Microsoft.Owin.Security.Interop.Test.csproj | 6 +++--- 26 files changed, 111 insertions(+), 101 deletions(-) delete mode 100644 build/dependencies.props diff --git a/Directory.Build.props b/Directory.Build.props index e28500d6bd..2490e42443 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,4 @@  - diff --git a/Directory.Build.targets b/Directory.Build.targets index f75adf7e4d..bc118fd907 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,2 +1,14 @@ - + + + + <_BootstrapperFile Condition=" $([MSBuild]::IsOSUnixLike()) ">build.sh + <_BootstrapperFile Condition="! $([MSBuild]::IsOSUnixLike()) ">build.cmd + <_BootstrapperError> + Package references have not been pinned. Run './$(_BootstrapperFile) /t:Pin'. + Also, you can run './$(_BootstrapperFile) /t:Restore' which will pin *and* restore packages. '$(_BootstrapperFile)' can be found in '$(MSBuildThisFileDirectory)'. + + + + + diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de1..20060c934e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,7 +3,6 @@ - diff --git a/build/dependencies.props b/build/dependencies.props deleted file mode 100644 index 0f73dd1b42..0000000000 --- a/build/dependencies.props +++ /dev/null @@ -1,17 +0,0 @@ - - - 2.1.0-* - 4.4.0-* - 3.14.1 - 2.1.4 - 2.1.1-* - 10.0.1 - 2.0.0-* - 2.0.0-* - 3.0.1 - 2.0.0-* - 15.3.0 - 0.6.1 - 2.3.0-beta4-build3742 - - diff --git a/build/repo.props b/build/repo.props index d4bab3eebd..7866974bc2 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,5 +1,7 @@ - + - + + + diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 52e6efb492..34af273c47 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 5cb7e9c09d..6e6bd0e796 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 6c9bd99dc9..2b3f9c3c98 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -10,12 +10,12 @@ - - - - - - + + + + + + diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 9ad1abc425..64d90423ba 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -11,13 +11,13 @@ - - - - - - - + + + + + + + diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 301828b01e..bc54cbf3df 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -15,15 +15,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 02f214557e..a1706f4d1f 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -22,15 +22,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d704a37df9..9d9a3de33a 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,6 +2,6 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 5de668e1a3..8526fcd397 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -1,4 +1,5 @@  + ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. netstandard2.0 @@ -6,8 +7,13 @@ true aspnetcore;authentication;security + - + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 318c18e743..a7af0b7f3f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -10,7 +10,10 @@ - + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 413d5d0257..a8f0077488 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -1,4 +1,5 @@  + ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. netstandard2.0 @@ -6,8 +7,13 @@ true aspnetcore;authentication;security + - + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 8f48bf6854..a156fa549f 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -9,14 +9,14 @@ - - - - - - - - + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index 17a027690d..087645ee02 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 01e1dd3149..3b2ada85f9 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -13,8 +13,8 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute - - + + diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 80fd59eb4a..c6021e012a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index 71c07fa140..67f8c94209 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index b9ef98116d..724f34b0bb 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,11 +2,11 @@ - - - - - - + + + + + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 7f3e739f33..ae8789e11b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 5192ee4fe5..b133522f09 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index d75c0a47d2..49bbbd91fe 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -10,7 +10,7 @@ - + diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index 96db2b38f3..7d50d86a31 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 5e1e2eb92c..779d8c141f 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -10,9 +10,9 @@ - - - + + +
From 863846bb2a0bfd77a47ccb7726d57ab376020766 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 14 Sep 2017 10:59:59 -0700 Subject: [PATCH 799/900] Cleanup resx (#1424) --- .../Properties/Resources.Designer.cs | 6 ++-- .../Properties/Resources.Designer.cs | 12 +++---- .../Properties/Resources.Designer.cs | 12 +++---- .../Properties/Resources.Designer.cs | 18 ++++------ .../Properties/Resources.Designer.cs | 12 +++---- .../Properties/Resources.Designer.cs | 36 +++++++------------ .../Properties/Resources.Designer.cs | 12 +++---- .../Properties/Resources.Designer.cs | 24 +++++-------- .../Properties/Resources.Designer.cs | 18 ++++------ 9 files changed, 50 insertions(+), 100 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs index a3a2f28745..655da24a30 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs @@ -15,16 +15,14 @@ namespace Microsoft.AspNetCore.Authentication.Facebook ///
internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs index 690c5a2803..03448b408c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs @@ -15,32 +15,28 @@ namespace Microsoft.AspNetCore.Authentication.Google ///
internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string Exception_ValidatorHandlerMismatch { - get { return GetString("Exception_ValidatorHandlerMismatch"); } + get => GetString("Exception_ValidatorHandlerMismatch"); } /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string FormatException_ValidatorHandlerMismatch() - { - return GetString("Exception_ValidatorHandlerMismatch"); - } + => GetString("Exception_ValidatorHandlerMismatch"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs index ef1d784f22..e95b8e061b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs @@ -15,32 +15,28 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string Exception_ValidatorHandlerMismatch { - get { return GetString("Exception_ValidatorHandlerMismatch"); } + get => GetString("Exception_ValidatorHandlerMismatch"); } /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string FormatException_ValidatorHandlerMismatch() - { - return GetString("Exception_ValidatorHandlerMismatch"); - } + => GetString("Exception_ValidatorHandlerMismatch"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs index 618d143eed..7ef5acecb2 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs @@ -15,48 +15,42 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount /// internal static string Exception_MissingId { - get { return GetString("Exception_MissingId"); } + get => GetString("Exception_MissingId"); } /// /// The user does not have an id. /// internal static string FormatException_MissingId() - { - return GetString("Exception_MissingId"); - } + => GetString("Exception_MissingId"); /// /// The '{0}' option must be provided. /// internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string Exception_ValidatorHandlerMismatch { - get { return GetString("Exception_ValidatorHandlerMismatch"); } + get => GetString("Exception_ValidatorHandlerMismatch"); } /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string FormatException_ValidatorHandlerMismatch() - { - return GetString("Exception_ValidatorHandlerMismatch"); - } + => GetString("Exception_ValidatorHandlerMismatch"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs index 00c7b848b5..5a38ade0b9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs @@ -15,32 +15,28 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string Exception_ValidatorHandlerMismatch { - get { return GetString("Exception_ValidatorHandlerMismatch"); } + get => GetString("Exception_ValidatorHandlerMismatch"); } /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string FormatException_ValidatorHandlerMismatch() - { - return GetString("Exception_ValidatorHandlerMismatch"); - } + => GetString("Exception_ValidatorHandlerMismatch"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs index 65a9273a0d..753373ece4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs @@ -15,96 +15,84 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// internal static string MessageStateIsNullOrEmpty { - get { return GetString("MessageStateIsNullOrEmpty"); } + get => GetString("MessageStateIsNullOrEmpty"); } /// /// OpenIdConnectAuthenticationHandler: message.State is null or empty. /// internal static string FormatMessageStateIsNullOrEmpty() - { - return GetString("MessageStateIsNullOrEmpty"); - } + => GetString("MessageStateIsNullOrEmpty"); /// /// Unable to unprotect the message.State. /// internal static string MessageStateIsInvalid { - get { return GetString("MessageStateIsInvalid"); } + get => GetString("MessageStateIsInvalid"); } /// /// Unable to unprotect the message.State. /// internal static string FormatMessageStateIsInvalid() - { - return GetString("MessageStateIsInvalid"); - } + => GetString("MessageStateIsInvalid"); /// /// Message contains error: '{0}', error_description: '{1}', error_uri: '{2}'. /// internal static string MessageContainsError { - get { return GetString("MessageContainsError"); } + get => GetString("MessageContainsError"); } /// /// Message contains error: '{0}', error_description: '{1}', error_uri: '{2}'. /// internal static string FormatMessageContainsError(object p0, object p1, object p2) - { - return string.Format(CultureInfo.CurrentCulture, GetString("MessageContainsError"), p0, p1, p2); - } + => string.Format(CultureInfo.CurrentCulture, GetString("MessageContainsError"), p0, p1, p2); /// /// The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{0}'. /// internal static string ValidatedSecurityTokenNotJwt { - get { return GetString("ValidatedSecurityTokenNotJwt"); } + get => GetString("ValidatedSecurityTokenNotJwt"); } /// /// The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{0}'. /// internal static string FormatValidatedSecurityTokenNotJwt(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("ValidatedSecurityTokenNotJwt"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("ValidatedSecurityTokenNotJwt"), p0); /// /// Unable to validate the 'id_token', no suitable ISecurityTokenValidator was found for: '{0}'." /// internal static string UnableToValidateToken { - get { return GetString("UnableToValidateToken"); } + get => GetString("UnableToValidateToken"); } /// /// Unable to validate the 'id_token', no suitable ISecurityTokenValidator was found for: '{0}'." /// internal static string FormatUnableToValidateToken(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("UnableToValidateToken"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("UnableToValidateToken"), p0); /// /// Cannot process the message. Both id_token and code are missing. /// internal static string IdTokenCodeMissing { - get { return GetString("IdTokenCodeMissing"); } + get => GetString("IdTokenCodeMissing"); } /// /// Cannot process the message. Both id_token and code are missing. /// internal static string FormatIdTokenCodeMissing() - { - return GetString("IdTokenCodeMissing"); - } + => GetString("IdTokenCodeMissing"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs index d60c2fc734..2eabfff298 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs @@ -15,32 +15,28 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string Exception_ValidatorHandlerMismatch { - get { return GetString("Exception_ValidatorHandlerMismatch"); } + get => GetString("Exception_ValidatorHandlerMismatch"); } /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string FormatException_ValidatorHandlerMismatch() - { - return GetString("Exception_ValidatorHandlerMismatch"); - } + => GetString("Exception_ValidatorHandlerMismatch"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs index 11e2e45868..4f3f147e00 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs @@ -15,64 +15,56 @@ namespace Microsoft.AspNetCore.Authentication /// internal static string Exception_DefaultDpapiRequiresAppNameKey { - get { return GetString("Exception_DefaultDpapiRequiresAppNameKey"); } + get => GetString("Exception_DefaultDpapiRequiresAppNameKey"); } /// /// The default data protection provider may only be used when the IApplicationBuilder.Properties contains an appropriate 'host.AppName' key. /// internal static string FormatException_DefaultDpapiRequiresAppNameKey() - { - return GetString("Exception_DefaultDpapiRequiresAppNameKey"); - } + => GetString("Exception_DefaultDpapiRequiresAppNameKey"); /// /// The state passed to UnhookAuthentication may only be the return value from HookAuthentication. /// internal static string Exception_UnhookAuthenticationStateType { - get { return GetString("Exception_UnhookAuthenticationStateType"); } + get => GetString("Exception_UnhookAuthenticationStateType"); } /// /// The state passed to UnhookAuthentication may only be the return value from HookAuthentication. /// internal static string FormatException_UnhookAuthenticationStateType() - { - return GetString("Exception_UnhookAuthenticationStateType"); - } + => GetString("Exception_UnhookAuthenticationStateType"); /// /// The AuthenticationTokenProvider's required synchronous events have not been registered. /// internal static string Exception_AuthenticationTokenDoesNotProvideSyncMethods { - get { return GetString("Exception_AuthenticationTokenDoesNotProvideSyncMethods"); } + get => GetString("Exception_AuthenticationTokenDoesNotProvideSyncMethods"); } /// /// The AuthenticationTokenProvider's required synchronous events have not been registered. /// internal static string FormatException_AuthenticationTokenDoesNotProvideSyncMethods() - { - return GetString("Exception_AuthenticationTokenDoesNotProvideSyncMethods"); - } + => GetString("Exception_AuthenticationTokenDoesNotProvideSyncMethods"); /// /// The '{0}' option must be provided. /// internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs index 116001e659..c83fa9ea5e 100644 --- a/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs @@ -15,48 +15,42 @@ namespace Microsoft.AspNetCore.Authorization /// internal static string Exception_AuthorizationPolicyEmpty { - get { return GetString("Exception_AuthorizationPolicyEmpty"); } + get => GetString("Exception_AuthorizationPolicyEmpty"); } /// /// AuthorizationPolicy must have at least one requirement. /// internal static string FormatException_AuthorizationPolicyEmpty() - { - return GetString("Exception_AuthorizationPolicyEmpty"); - } + => GetString("Exception_AuthorizationPolicyEmpty"); /// /// The AuthorizationPolicy named: '{0}' was not found. /// internal static string Exception_AuthorizationPolicyNotFound { - get { return GetString("Exception_AuthorizationPolicyNotFound"); } + get => GetString("Exception_AuthorizationPolicyNotFound"); } /// /// The AuthorizationPolicy named: '{0}' was not found. /// internal static string FormatException_AuthorizationPolicyNotFound(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_AuthorizationPolicyNotFound"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_AuthorizationPolicyNotFound"), p0); /// /// At least one role must be specified. /// internal static string Exception_RoleRequirementEmpty { - get { return GetString("Exception_RoleRequirementEmpty"); } + get => GetString("Exception_RoleRequirementEmpty"); } /// /// At least one role must be specified. /// internal static string FormatException_RoleRequirementEmpty() - { - return GetString("Exception_RoleRequirementEmpty"); - } + => GetString("Exception_RoleRequirementEmpty"); private static string GetString(string name, params string[] formatterNames) { From b9d9418f6d4fecd8e3b0c60538bb985c15e31fcc Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 15 Sep 2017 14:22:03 -0700 Subject: [PATCH 800/900] Block SignInScheme = self --- .../AuthenticationBuilder.cs | 8 +++- .../Properties/Resources.Designer.cs | 14 ++++++ .../Resources.resx | 3 ++ .../FacebookTests.cs | 48 +++++++++++++++++++ .../GoogleTests.cs | 15 +++++- .../MicrosoftAccountTests.cs | 13 +++++ .../OAuthTests.cs | 21 ++++++++ .../OpenIdConnectConfigurationTests.cs | 15 +++++- .../TwitterTests.cs | 13 +++++ 9 files changed, 145 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs index c29bdeae29..54b4818851 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Authentication return AddScheme(authenticationScheme, displayName, configureOptions: configureOptions); } - // Used to ensure that there's always a default data protection provider + // Used to ensure that there's always a default sign in scheme that's not itself private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { private readonly AuthenticationOptions _authOptions; @@ -96,7 +96,11 @@ namespace Microsoft.AspNetCore.Authentication public void PostConfigure(string name, TOptions options) { - options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme; + options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme ?? _authOptions.DefaultScheme; + if (string.Equals(options.SignInScheme, name, StringComparison.Ordinal)) + { + throw new InvalidOperationException(Resources.Exception_RemoteSignInSchemeCannotBeSelf); + } } } } diff --git a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs index 4f3f147e00..b1941a7dca 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs @@ -66,6 +66,20 @@ namespace Microsoft.AspNetCore.Authentication internal static string FormatException_OptionMustBeProvided(object p0) => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); + /// + /// The SignInScheme for a remote authentication handler cannot be set to itself. If it was not explicitly set, the AuthenticationOptions.DefaultSignInScheme or DefaultScheme is used. + /// + internal static string Exception_RemoteSignInSchemeCannotBeSelf + { + get => GetString("Exception_RemoteSignInSchemeCannotBeSelf"); + } + + /// + /// The SignInScheme for a remote authentication handler cannot be set to itself. If it was not explicitly set, the AuthenticationOptions.DefaultSignInScheme or DefaultScheme is used. + /// + internal static string FormatException_RemoteSignInSchemeCannotBeSelf() + => GetString("Exception_RemoteSignInSchemeCannotBeSelf"); + private static string GetString(string name, params string[] formatterNames) { var value = _resourceManager.GetString(name); diff --git a/src/Microsoft.AspNetCore.Authentication/Resources.resx b/src/Microsoft.AspNetCore.Authentication/Resources.resx index 54d22bcc94..9e831dc74f 100644 --- a/src/Microsoft.AspNetCore.Authentication/Resources.resx +++ b/src/Microsoft.AspNetCore.Authentication/Resources.resx @@ -129,4 +129,7 @@ The '{0}' option must be provided. + + The SignInScheme for a remote authentication handler cannot be set to itself. If it was not explicitly set, the AuthenticationOptions.DefaultSignInScheme or DefaultScheme is used. + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 75de0652e4..81373403bd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -24,6 +24,54 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { public class FacebookTests { + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer( + app => { }, + services => services.AddAuthentication().AddFacebook(o => o.SignInScheme = FacebookDefaults.AuthenticationScheme), + context => + { + // Gross + context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + return true; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultScheme() + { + var server = CreateServer( + app => { }, + services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(), + context => + { + // Gross + context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + return true; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultSignInScheme() + { + var server = CreateServer( + app => { }, + services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(), + context => + { + // Gross + context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + return true; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index f1038bb51d..8f2cc52f91 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -15,10 +15,8 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; using Newtonsoft.Json; using Xunit; @@ -26,6 +24,19 @@ namespace Microsoft.AspNetCore.Authentication.Google { public class GoogleTests { + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.SignInScheme = GoogleDefaults.AuthenticationScheme; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 2e249a833a..b2854e344e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -27,6 +27,19 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { public class MicrosoftAccountTests { + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.SignInScheme = MicrosoftAccountDefaults.AuthenticationScheme; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index aeb313daa3..30c33eb1d7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -16,6 +16,27 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { public class OAuthTests { + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer( + app => { }, + services => services.AddAuthentication().AddOAuth("weeblie", o => + { + o.SignInScheme = "weeblie"; + o.ClientId = "whatever"; + o.ClientSecret = "whatever"; + }), + context => + { + // REVIEW: Gross. + context.ChallengeAsync("weeblie").GetAwaiter().GetResult(); + return true; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 74f00c8f95..d0d1c26096 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; -using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -46,6 +45,20 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } + [Fact] + public Task ThrowsWhenSignInSchemeIsSetToSelf() + { + return TestConfigurationException( + o => + { + o.SignInScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.Authority = TestServerBuilder.DefaultAuthority; + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + }, + ex => Assert.Contains("cannot be set to itself", ex.Message)); + } + [Fact] public Task ThrowsWhenClientIdIsMissing() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 746dfee6ab..6c661af45c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -17,6 +17,19 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { public class TwitterTests { + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + o.SignInScheme = TwitterDefaults.AuthenticationScheme; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + [Fact] public async Task VerifySchemeDefaults() { From eff1b42d6e4c90f6173ce5643a3f12b000206158 Mon Sep 17 00:00:00 2001 From: Anders Abel Date: Sat, 16 Sep 2017 19:41:52 +0200 Subject: [PATCH 801/900] Fix comment (#1436) Fix comment, it's setting sign in scheme (old left-over from copy-paste?) --- .../AuthenticationServiceCollectionExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index e1beea7b6e..38fa47857a 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -85,7 +85,7 @@ namespace Microsoft.Extensions.DependencyInjection return services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); } - // Used to ensure that there's always a default data protection provider + // Used to ensure that there's always a sign in scheme private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { private readonly AuthenticationOptions _authOptions; From 241880eadc0216918b1f879b403567ff6cb4d03c Mon Sep 17 00:00:00 2001 From: agoretsky Date: Tue, 19 Sep 2017 19:14:49 +0300 Subject: [PATCH 802/900] Minor improvements (#1403) * Fixed exception overwriting due to possible NullReferenceException * Removed unused local variables --- .../CookieAuthenticationHandler.cs | 5 ++--- .../RemoteAuthenticationHandler.cs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 996c334a73..754c91f1e8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -132,7 +132,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } var currentUtc = Clock.UtcNow; - var issuedUtc = ticket.Properties.IssuedUtc; var expiresUtc = ticket.Properties.ExpiresUtc; if (expiresUtc != null && expiresUtc.Value < currentUtc) @@ -246,7 +245,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies _signInCalled = true; // Process the request cookie to initialize members like _sessionKey. - var result = await EnsureCookieTicket(); + await EnsureCookieTicket(); var cookieOptions = BuildCookieOptions(); var signInContext = new CookieSigningInContext( @@ -328,7 +327,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies _signOutCalled = true; // Process the request cookie to initialize members like _sessionKey. - var ticket = await EnsureCookieTicket(); + await EnsureCookieTicket(); var cookieOptions = BuildCookieOptions(); if (Options.SessionStore != null && _sessionKey != null) { diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index bcd5983642..1134566d88 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.Authentication new InvalidOperationException("Invalid return state, unable to redirect."); } - ticket = authResult.Ticket; + ticket = authResult?.Ticket; } catch (Exception ex) { From 1367a5d3858d4446c126940fe5c26267d0ac2512 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 14 Sep 2017 14:57:40 -0700 Subject: [PATCH 803/900] Make all handlers public --- .../FacebookHandler.cs | 2 +- src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs | 2 +- .../JwtBearerHandler.cs | 2 +- .../MicrosoftAccountHandler.cs | 2 +- .../TwitterHandler.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 9004fc09cd..db664e2ee1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -16,7 +16,7 @@ using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.Facebook { - internal class FacebookHandler : OAuthHandler + public class FacebookHandler : OAuthHandler { public FacebookHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 7a2e1a2d14..155691a4ba 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -16,7 +16,7 @@ using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.Google { - internal class GoogleHandler : OAuthHandler + public class GoogleHandler : OAuthHandler { public GoogleHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 9cf73182ba..f894a97d0c 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -18,7 +18,7 @@ using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - internal class JwtBearerHandler : AuthenticationHandler + public class JwtBearerHandler : AuthenticationHandler { private OpenIdConnectConfiguration _configuration; diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 8204bf07b9..f4c06300c2 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -13,7 +13,7 @@ using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { - internal class MicrosoftAccountHandler : OAuthHandler + public class MicrosoftAccountHandler : OAuthHandler { public MicrosoftAccountHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 1e1dd08d87..e8a961df39 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -19,7 +19,7 @@ using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.Twitter { - internal class TwitterHandler : RemoteAuthenticationHandler + public class TwitterHandler : RemoteAuthenticationHandler { private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); private const string RequestTokenEndpoint = "https://api.twitter.com/oauth/request_token"; From 648bb1e8101beb6d0f2d8069a0b57e165318a52a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 19 Sep 2017 16:46:39 -0700 Subject: [PATCH 804/900] Obsolete old AddSchemes --- .../AuthenticationServiceCollectionExtensions.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 38fa47857a..b274eaace4 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -46,7 +46,7 @@ namespace Microsoft.Extensions.DependencyInjection return builder; } - // REMOVE below once callers have been updated + [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureScheme, Action configureOptions) where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler @@ -67,16 +67,19 @@ namespace Microsoft.Extensions.DependencyInjection return services; } + [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, Action configureOptions) where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler => services.AddScheme(authenticationScheme, displayName: null, configureScheme: null, configureOptions: configureOptions); + [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureOptions) where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler => services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); + [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] public static IServiceCollection AddRemoteScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureOptions) where TOptions : RemoteAuthenticationOptions, new() where THandler : RemoteAuthenticationHandler From 31dd4ebd9c0c26fc9592aa08d7fb3804bf34011b Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Thu, 21 Sep 2017 17:58:29 -0700 Subject: [PATCH 805/900] Increase Minimum Version of Visual Studio to 15.3.0 --- Security.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Security.sln b/Security.sln index 811893c33a..f88d8576b3 100644 --- a/Security.sln +++ b/Security.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.10 -MinimumVisualStudioVersion = 10.0.40219.1 +MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" ProjectSection(SolutionItems) = preProject src\Directory.Build.props = src\Directory.Build.props From 13fdbac48fabd723aed7819669d7f9c5bb8e3da2 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 21 Sep 2017 12:28:24 -0700 Subject: [PATCH 806/900] #942 Add the SignedOutCallbackRedirect event for OIDC --- .../Events/OpenIdConnectEvents.cs | 7 + .../LoggingExtensions.cs | 20 + .../OpenIdConnectHandler.cs | 44 +- .../RemoteAuthenticationHandler.cs | 4 + .../OpenIdConnect/OpenIdConnectEventTests.cs | 1151 ++++++++--------- 5 files changed, 643 insertions(+), 583 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index d8467be8d7..2a48d250bb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -38,6 +38,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// public Func OnRedirectToIdentityProviderForSignOut { get; set; } = context => Task.CompletedTask; + /// + /// Invoked before redirecting to the at the end of a remote sign-out flow. + /// + public Func OnSignedOutCallbackRedirect { get; set; } = context => Task.CompletedTask; + /// /// Invoked when a request is received on the RemoteSignOutPath. /// @@ -68,6 +73,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect public virtual Task RedirectToIdentityProviderForSignOut(RedirectContext context) => OnRedirectToIdentityProviderForSignOut(context); + public virtual Task SignedOutCallbackRedirect(RemoteSignOutContext context) => OnSignedOutCallbackRedirect(context); + public virtual Task RemoteSignOut(RemoteSignOutContext context) => OnRemoteSignOut(context); public virtual Task TokenResponseReceived(TokenResponseReceivedContext context) => OnTokenResponseReceived(context); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs index 458cfd73ee..224af87b6f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -9,6 +9,8 @@ namespace Microsoft.Extensions.Logging { private static Action _redirectToIdentityProviderForSignOutHandledResponse; private static Action _redirectToIdentityProviderHandledResponse; + private static Action _signoutCallbackRedirectHandledResponse; + private static Action _signoutCallbackRedirectSkipped; private static Action _updatingConfiguration; private static Action _receivedIdToken; private static Action _redeemingCodeForTokens; @@ -248,6 +250,14 @@ namespace Microsoft.Extensions.Logging eventId: 49, logLevel: LogLevel.Information, formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); + _signoutCallbackRedirectHandledResponse = LoggerMessage.Define( + eventId: 50, + logLevel: LogLevel.Debug, + formatString: "RedirectToSignedOutRedirectUri.HandledResponse"); + _signoutCallbackRedirectSkipped = LoggerMessage.Define( + eventId: 51, + logLevel: LogLevel.Debug, + formatString: "RedirectToSignedOutRedirectUri.Skipped"); } public static void UpdatingConfiguration(this ILogger logger) @@ -345,6 +355,16 @@ namespace Microsoft.Extensions.Logging _redirectToIdentityProviderHandledResponse(logger, null); } + public static void SignoutCallbackRedirectHandledResponse(this ILogger logger) + { + _signoutCallbackRedirectHandledResponse(logger, null); + } + + public static void SignoutCallbackRedirectSkipped(this ILogger logger) + { + _signoutCallbackRedirectSkipped(logger, null); + } + public static void UserInformationReceivedHandledResponse(this ILogger logger) { _userInformationReceivedHandledResponse(logger, null); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 65e1e1951e..bf365ceca0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -122,6 +122,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Logger.RemoteSignOutSkipped(); return false; } + if (remoteSignOutContext.Result.Failure != null) + { + throw new InvalidOperationException("An error was returned from the RemoteSignOut event.", remoteSignOutContext.Result.Failure); + } } if (message == null) @@ -273,18 +277,46 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// Response to the callback from OpenId provider after session ended. /// /// A task executing the callback procedure - protected virtual Task HandleSignOutCallbackAsync() + protected async virtual Task HandleSignOutCallbackAsync() { - if (Request.Query.TryGetValue(OpenIdConnectParameterNames.State, out StringValues protectedState)) + var message = new OpenIdConnectMessage(Request.Query.Select(pair => new KeyValuePair(pair.Key, pair.Value))); + AuthenticationProperties properties = null; + if (!string.IsNullOrEmpty(message.State)) { - var properties = Options.StateDataFormat.Unprotect(protectedState); - if (!string.IsNullOrEmpty(properties?.RedirectUri)) + properties = Options.StateDataFormat.Unprotect(message.State); + } + + var signOut = new RemoteSignOutContext(Context, Scheme, Options, message) + { + Properties = properties, + }; + + await Events.SignedOutCallbackRedirect(signOut); + if (signOut.Result != null) + { + if (signOut.Result.Handled) { - Response.Redirect(properties.RedirectUri); + Logger.SignoutCallbackRedirectHandledResponse(); + return true; + } + if (signOut.Result.Skipped) + { + Logger.SignoutCallbackRedirectSkipped(); + return false; + } + if (signOut.Result.Failure != null) + { + throw new InvalidOperationException("An error was returned from the SignedOutCallbackRedirect event.", signOut.Result.Failure); } } - return Task.FromResult(true); + properties = signOut.Properties; + if (!string.IsNullOrEmpty(properties?.RedirectUri)) + { + Response.Redirect(properties.RedirectUri); + } + + return true; } /// diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 1134566d88..4051ee6664 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -93,6 +93,10 @@ namespace Microsoft.AspNetCore.Authentication { return false; } + else if (errorContext.Result.Failure != null) + { + throw new InvalidOperationException("An error was returned from the RemoteFailure event.", errorContext.Result.Failure); + } } throw exception; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index ed20d2f5ac..f3fc261879 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -16,11 +16,12 @@ using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Primitives; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect @@ -37,32 +38,22 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect private readonly Func FailureNotImpl = context => { throw new NotImplementedException("Failure", context.Failure); }; private readonly Func RedirectNotImpl = context => { throw new NotImplementedException("Redirect"); }; private readonly Func RemoteSignOutNotImpl = context => { throw new NotImplementedException("Remote"); }; + private readonly Func SignedOutCallbackNotImpl = context => { throw new NotImplementedException("SingedOut"); }; private readonly RequestDelegate AppNotImpl = context => { throw new NotImplementedException("App"); }; [Fact] public async Task OnMessageReceived_Skip_NoMoreEventsRun() { var messageReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnTokenValidated = TokenNotImpl, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - OnRemoteFailure = FailureNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -80,30 +71,20 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { var messageReceived = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnTokenValidated = TokenNotImpl, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -124,27 +105,16 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect public async Task OnMessageReceived_Handled_NoMoreEventsRun() { var messageReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnTokenValidated = TokenNotImpl, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", ""); @@ -159,30 +129,20 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { var messageReceived = false; var tokenValidated = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -202,34 +162,25 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var messageReceived = false; var tokenValidated = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -252,32 +203,22 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { var messageReceived = false; var tokenValidated = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.HandleResponse(); context.Principal = null; context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); @@ -295,36 +236,27 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var messageReceived = false; var tokenValidated = false; var ticketReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.Success(); return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); @@ -342,34 +274,25 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var messageReceived = false; var tokenValidated = false; var codeReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -391,38 +314,30 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenValidated = false; var codeReceived = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -447,36 +362,27 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var messageReceived = false; var tokenValidated = false; var codeReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; context.HandleResponse(); context.Principal = null; context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -495,40 +401,32 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenValidated = false; var codeReceived = false; var ticketReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; context.Success(); return Task.FromResult(0); - }, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -548,38 +446,30 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenValidated = false; var codeReceived = false; var tokenResponseReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -603,42 +493,35 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var codeReceived = false; var tokenResponseReceived = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -665,40 +548,32 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenValidated = false; var codeReceived = false; var tokenResponseReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -719,44 +594,37 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var codeReceived = false; var ticketReceived = false; var tokenResponseReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; context.Success(); return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -777,38 +645,30 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var codeReceived = false; var tokenResponseReceived = false; var tokenValidated = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -832,42 +692,35 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenResponseReceived = false; var tokenValidated = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -894,40 +747,32 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var codeReceived = false; var tokenResponseReceived = false; var tokenValidated = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); @@ -948,44 +793,37 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var ticketReceived = false; var tokenResponseReceived = false; var tokenValidated = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.Success(); return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); @@ -1007,42 +845,35 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var codeReceived = false; var tokenResponseReceived = false; var userInfoReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1068,46 +899,40 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenResponseReceived = false; var userInfoReceived = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1136,44 +961,37 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var codeReceived = false; var tokenResponseReceived = false; var userInfoReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1196,49 +1014,43 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var ticketReceived = false; var tokenResponseReceived = false; var userInfoReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; // context.Ticket = null; context.Success(); return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1262,47 +1074,41 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenResponseReceived = false; var userInfoReceived = false; var authFailed = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); context.SkipHandler(); return Task.FromResult(0); - }, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1330,51 +1136,46 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var userInfoReceived = false; var authFailed = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1405,34 +1206,34 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenResponseReceived = false; var userInfoReceived = false; var authFailed = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); @@ -1440,14 +1241,8 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1472,34 +1267,34 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenResponseReceived = false; var userInfoReceived = false; var authFailed = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); @@ -1515,20 +1310,15 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); context.Success(); return Task.FromResult(0); - }, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1554,52 +1344,47 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var userInfoReceived = false; var authFailed = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); context.SkipHandler(); return Task.FromResult(0); - }, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1628,53 +1413,48 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var userInfoReceived = false; var authFailed = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1699,46 +1479,40 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenResponseReceived = false; var userInfoReceived = false; var ticektReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticektReceived = true; context.SkipHandler(); return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1765,47 +1539,41 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var tokenResponseReceived = false; var userInfoReceived = false; var ticektReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticektReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1820,23 +1588,250 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.True(ticektReceived); } + [Fact] + public async Task OnRedirectToIdentityProviderForSignOut_Invoked() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnRedirectToIdentityProviderForSignOut = context => + { + forSignOut = true; + return Task.CompletedTask; + }; + }), + context => + { + return context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); + }); + + var client = server.CreateClient(); + var response = await client.GetAsync("/"); + + Assert.Equal(HttpStatusCode.Found, response.StatusCode); + Assert.Equal("http://testhost/end", response.Headers.Location.GetLeftPart(UriPartial.Path)); + Assert.True(forSignOut); + } + + [Fact] + public async Task OnRedirectToIdentityProviderForSignOut_Handled_RedirectNotInvoked() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnRedirectToIdentityProviderForSignOut = context => + { + forSignOut = true; + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + }), + context => + { + return context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); + }); + + var client = server.CreateClient(); + var response = await client.GetAsync("/"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Null(response.Headers.Location); + Assert.True(forSignOut); + } + + [Fact] + public async Task OnRemoteSignOut_Invoked() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnRemoteSignOut = context => + { + forSignOut = true; + return Task.CompletedTask; + }; + }), + AppNotImpl); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-oidc"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(forSignOut); + Assert.True(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); + Assert.True(SetCookieHeaderValue.TryParseStrictList(values.ToList(), out var parsedValues)); + Assert.Equal(1, parsedValues.Count); + Assert.True(StringSegment.IsNullOrEmpty(parsedValues.Single().Value)); + } + + [Fact] + public async Task OnRemoteSignOut_Handled_NoSignout() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnRemoteSignOut = context => + { + forSignOut = true; + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + }), + AppNotImpl); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-oidc"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.True(forSignOut); + Assert.False(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); + } + + [Fact] + public async Task OnRemoteSignOut_Skip_NoSignout() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnRemoteSignOut = context => + { + forSignOut = true; + context.SkipHandler(); + return Task.CompletedTask; + }; + }), + context => + { + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.CompletedTask; + }); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-oidc"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.True(forSignOut); + Assert.False(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); + } + + [Fact] + public async Task OnRedirectToSignedOutRedirectUri_Invoked() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnSignedOutCallbackRedirect = context => + { + forSignOut = true; + return Task.CompletedTask; + }; + }), + AppNotImpl); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-callback-oidc?state=protected_state"); + + Assert.Equal(HttpStatusCode.Found, response.StatusCode); + Assert.Equal("http://testhost/redirect", response.Headers.Location.AbsoluteUri); + Assert.True(forSignOut); + } + + [Fact] + public async Task OnRedirectToSignedOutRedirectUri_Handled_NoRedirect() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnSignedOutCallbackRedirect = context => + { + forSignOut = true; + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + }), + AppNotImpl); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-callback-oidc?state=protected_state"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Null(response.Headers.Location); + Assert.True(forSignOut); + } + + [Fact] + public async Task OnRedirectToSignedOutRedirectUri_Skipped_NoRedirect() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnSignedOutCallbackRedirect = context => + { + forSignOut = true; + context.SkipHandler(); + return Task.CompletedTask; + }; + }), + context => + { + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.CompletedTask; + }); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-callback-oidc?state=protected_state"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Null(response.Headers.Location); + Assert.True(forSignOut); + } + + private OpenIdConnectEvents CreateNotImpEvents(Action configureEvents) + { + var events = new OpenIdConnectEvents() + { + OnMessageReceived = MessageNotImpl, + OnTokenValidated = TokenNotImpl, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + OnRemoteFailure = FailureNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + OnSignedOutCallbackRedirect = SignedOutCallbackNotImpl, + }; + configureEvents(events); + return events; + } + private TestServer CreateServer(OpenIdConnectEvents events, RequestDelegate appCode) { var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddAuthentication() + services.AddAuthentication(auth => + { + auth.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + auth.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; + }) .AddCookie() .AddOpenIdConnect(o => { o.Events = events; - o.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; o.ClientId = "ClientId"; o.GetClaimsFromUserInfoEndpoint = true; o.Configuration = new OpenIdConnectConfiguration() { TokenEndpoint = "http://testhost/tokens", UserInfoEndpoint = "http://testhost/user", + EndSessionEndpoint = "http://testhost/end" }; o.StateDataFormat = new TestStateDataFormat(); o.SecurityTokenValidator = new TestTokenValidator(); @@ -1868,7 +1863,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect public string Protect(AuthenticationProperties data) { - throw new NotImplementedException(); + return "protected_state"; } public string Protect(AuthenticationProperties data, string purpose) @@ -1879,11 +1874,13 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect public AuthenticationProperties Unprotect(string protectedText) { Assert.Equal("protected_state", protectedText); - return new AuthenticationProperties(new Dictionary() + var properties = new AuthenticationProperties(new Dictionary() { { ".xsrf", "corrilationId" }, { OpenIdConnectDefaults.RedirectUriForCodePropertiesKey, "redirect_uri" } }); + properties.RedirectUri = "http://testhost/redirect"; + return properties; } public AuthenticationProperties Unprotect(string protectedText, string purpose) From 5abcfe7e3d78f777d45503b50de5cea17cf9aa5e Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 22 Sep 2017 17:10:59 -0700 Subject: [PATCH 807/900] Update API check baselines to 2.0 --- .../baseline.netcore.json | 1962 +++++------ .../breakingchanges.netcore.json | 47 - .../baseline.netcore.json | 461 +-- .../breakingchanges.netcore.json | 19 - .../baseline.netcore.json | 273 +- .../breakingchanges.netcore.json | 40 - .../baseline.netcore.json | 398 ++- .../breakingchanges.netcore.json | 43 - .../baseline.netcore.json | 253 +- .../breakingchanges.netcore.json | 19 - .../baseline.netcore.json | 1661 ++++++--- .../breakingchanges.netcore.json | 35 - .../baseline.netcore.json | 1297 ++++--- .../breakingchanges.netcore.json | 68 - .../baseline.netcore.json | 424 +-- .../breakingchanges.netcore.json | 45 - .../baseline.netcore.json | 3102 ++++++++--------- .../breakingchanges.netcore.json | 116 - .../baseline.netcore.json | 211 ++ .../baseline.netcore.json | 390 ++- .../baseline.netcore.json | 26 +- .../baseline.netframework.json | 5 +- 22 files changed, 5802 insertions(+), 5093 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json index 56e48d3fed..1f1115460b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json @@ -1,6 +1,121 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ + { + "Name": "Microsoft.Extensions.DependencyInjection.CookieExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddCookie", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddCookie", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddCookie", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddCookie", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddCookie", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", "Visibility": "Public", @@ -35,7 +150,7 @@ }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" } ], "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", @@ -48,113 +163,260 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "CookiePrefix", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "LoginPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "LogoutPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessDeniedPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "ReturnUrlParameter", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"Cookies\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", "ImplementedInterfaces": [ - "Microsoft.Extensions.Options.IOptions" + "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler" ], "Members": [ { "Kind": "Method", - "Name": "get_CookieName", + "Name": "get_Events", "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_CookieName", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "System.String" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents" } ], "ReturnType": "System.Void", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_CookieDomain", + "Name": "InitializeHandlerAsync", "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_CookieDomain", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FinishResponseAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignInAsync", "Parameters": [ { - "Name": "value", - "Type": "System.String" + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_CookiePath", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookiePath", + "Name": "SignOutAsync", "Parameters": [ { - "Name": "value", - "Type": "System.String" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_CookieHttpOnly", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieHttpOnly", + "Name": "HandleForbiddenAsync", "Parameters": [ { - "Name": "value", - "Type": "System.Boolean" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Void", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_CookieSecure", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Cookie", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_CookieSecure", + "Name": "set_Cookie", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" } ], "ReturnType": "System.Void", @@ -182,27 +444,6 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "get_ExpireTimeSpan", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ExpireTimeSpan", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "get_SlidingExpiration", @@ -312,7 +553,7 @@ "Kind": "Method", "Name": "get_Events", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -322,7 +563,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents" } ], "ReturnType": "System.Void", @@ -350,27 +591,6 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "get_CookieManager", @@ -413,39 +633,21 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" - ], - "Members": [ { "Kind": "Method", - "Name": "get_ChunkSize", + "Name": "get_ExpireTimeSpan", "Parameters": [], - "ReturnType": "System.Nullable", + "ReturnType": "System.TimeSpan", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ChunkSize", + "Name": "set_ExpireTimeSpan", "Parameters": [ { "Name": "value", - "Type": "System.Nullable" + "Type": "System.TimeSpan" } ], "ReturnType": "System.Void", @@ -454,7 +656,70 @@ }, { "Kind": "Method", - "Name": "get_ThrowForPartialCookies", + "Name": "get_CookieName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieDomain", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieDomain", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookiePath", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookiePath", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CookieHttpOnly", "Parameters": [], "ReturnType": "System.Boolean", "Visibility": "Public", @@ -462,7 +727,7 @@ }, { "Kind": "Method", - "Name": "set_ThrowForPartialCookies", + "Name": "set_CookieHttpOnly", "Parameters": [ { "Name": "value", @@ -475,80 +740,363 @@ }, { "Kind": "Method", - "Name": "GetRequestCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Name": "get_CookieSecure", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AppendResponseCookie", + "Name": "set_CookieSecure", "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, { "Name": "value", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" + "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" } ], "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnValidatePrincipal", + "Parameters": [], + "ReturnType": "System.Func", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "DeleteCookie", + "Name": "set_OnValidatePrincipal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSigningIn", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSigningIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSignedIn", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSignedIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSigningOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSigningOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToLogin", + "Parameters": [], + "ReturnType": "System.Func, System.Threading.Tasks.Task>", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToLogin", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func, System.Threading.Tasks.Task>" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToAccessDenied", + "Parameters": [], + "ReturnType": "System.Func, System.Threading.Tasks.Task>", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToAccessDenied", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func, System.Threading.Tasks.Task>" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToLogout", + "Parameters": [], + "ReturnType": "System.Func, System.Threading.Tasks.Task>", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToLogout", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func, System.Threading.Tasks.Task>" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToReturnUrl", + "Parameters": [], + "ReturnType": "System.Func, System.Threading.Tasks.Task>", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToReturnUrl", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func, System.Threading.Tasks.Task>" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidatePrincipal", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SigningIn", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignedIn", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SigningOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToLogout", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToLogin", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToReturnUrl", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAccessDenied", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PrincipalContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "key", - "Type": "System.String" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" } ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -556,93 +1104,31 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults", + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext", "Visibility": "Public", "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "CookiePrefix", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "LoginPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "LogoutPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessDeniedPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "ReturnUrlParameter", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Cookies\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "BaseType": "Microsoft.AspNetCore.Authentication.PrincipalContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "CreateHandler", + "Name": "get_CookieOptions", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieOptions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { @@ -650,24 +1136,163 @@ "Name": ".ctor", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "urlEncoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "cookieOptions", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_CookieOptions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieOptions", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "cookieOptions", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PrincipalContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ShouldRenew", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ShouldRenew", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReplacePrincipal", + "Parameters": [ + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RejectPrincipal", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], "Visibility": "Public", @@ -809,436 +1434,30 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", + "Name": "Microsoft.AspNetCore.Authentication.Cookies.PostConfigureCookieAuthenticationOptions", "Visibility": "Public", "Kind": "Class", "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" + "Microsoft.Extensions.Options.IPostConfigureOptions" ], "Members": [ { "Kind": "Method", - "Name": "get_OnValidatePrincipal", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnValidatePrincipal", + "Name": "PostConfigure", "Parameters": [ { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnSigningIn", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnSigningIn", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnSignedIn", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnSignedIn", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnSigningOut", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnSigningOut", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToLogin", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToLogin", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToAccessDenied", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToAccessDenied", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToLogout", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToLogout", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToReturnUrl", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToReturnUrl", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ValidatePrincipal", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignedIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogout", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogin", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToReturnUrl", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAccessDenied", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RedirectUri", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "redirectUri", + "Name": "name", "Type": "System.String" }, { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" } ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", "Visibility": "Public", "GenericParameter": [] }, @@ -1247,24 +1466,8 @@ "Name": ".ctor", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" - }, - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" } ], "Visibility": "Public", @@ -1274,140 +1477,28 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext", + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieOptions", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieOptions", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" - }, - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "cookieOptions", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_CookieOptions", + "Name": "get_ChunkSize", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "ReturnType": "System.Nullable", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_CookieOptions", + "Name": "set_ChunkSize", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" + "Type": "System.Nullable" } ], "ReturnType": "System.Void", @@ -1416,78 +1507,7 @@ }, { "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "cookieOptions", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ShouldRenew", + "Name": "get_ThrowForPartialCookies", "Parameters": [], "ReturnType": "System.Boolean", "Visibility": "Public", @@ -1495,7 +1515,7 @@ }, { "Kind": "Method", - "Name": "set_ShouldRenew", + "Name": "set_ThrowForPartialCookies", "Parameters": [ { "Name": "value", @@ -1508,154 +1528,96 @@ }, { "Kind": "Method", - "Name": "ReplacePrincipal", - "Parameters": [ - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RejectPrincipal", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", + "Name": "GetRequestCookie", "Parameters": [ { "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AppendResponseCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Type": "Microsoft.AspNetCore.Http.CookieOptions" } ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "ValidatePrincipal", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] }, { "Kind": "Method", - "Name": "SigningIn", + "Name": "DeleteCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "SignedIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "RedirectToLogout", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogin", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToReturnUrl", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAccessDenied", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] + "Kind": "Field", + "Name": "DefaultChunkSize", + "Parameters": [], + "ReturnType": "System.Int32", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "4050" } ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json deleted file mode 100644 index 91781d2dd2..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json +++ /dev/null @@ -1,47 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext : Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents : Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.CookieAuthenticationOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions, Microsoft.Extensions.Options.IOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseCookieAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json index 1e070fc7ff..82a48a6bf4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json @@ -1,6 +1,102 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ + { + "Name": "Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddFacebook", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddFacebook", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddFacebook", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddFacebook", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults", "Visibility": "Public", @@ -10,6 +106,16 @@ "Sealed": true, "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Field", "Name": "AuthorizationEndpoint", @@ -55,318 +161,22 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookHelper", + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions", "Visibility": "Public", "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetAgeRangeMin", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetAgeRangeMax", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetBirthday", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetFirstName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetGender", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLastName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLink", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLocation", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLocale", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetMiddleName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTimeZone", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", + "Name": "Validate", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ReturnType": "System.Void", "Virtual": true, "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseFacebookAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "UseFacebookAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.FacebookOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.FacebookOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ { "Kind": "Method", "Name": "get_AppId", @@ -447,7 +257,52 @@ } ], "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseFacebookAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseFacebookAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json deleted file mode 100644 index f64e6b8342..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json +++ /dev/null @@ -1,19 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.FacebookOptions : Microsoft.AspNetCore.Builder.OAuthOptions", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Facebook.FacebookHelper", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseFacebookAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.FacebookOptions options)", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json index 647633afa8..61aae649d3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json @@ -1,6 +1,102 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ + { + "Name": "Microsoft.Extensions.DependencyInjection.GoogleExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddGoogle", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddGoogle", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddGoogle", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddGoogle", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", "Visibility": "Public", @@ -10,6 +106,16 @@ "Sealed": true, "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Field", "Name": "AuthorizationEndpoint", @@ -63,76 +169,6 @@ "Sealed": true, "ImplementedInterfaces": [], "Members": [ - { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetGivenName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetFamilyName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetProfile", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "GetEmail", @@ -151,51 +187,37 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "CreateHandler", + "Name": "get_AccessType", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AccessType", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -236,7 +258,7 @@ }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.GoogleOptions" + "Type": "Microsoft.AspNetCore.Authentication.Google.GoogleOptions" } ], "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", @@ -247,45 +269,6 @@ } ], "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.GoogleOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AccessType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AccessType", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json deleted file mode 100644 index db3d1fcf0c..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json +++ /dev/null @@ -1,40 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Google.GoogleMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.GoogleOptions : Microsoft.AspNetCore.Builder.OAuthOptions", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.GoogleAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseGoogleAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.GoogleOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "MemberId": "public static System.String GetFamilyName(Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "MemberId": "public static System.String GetGivenName(Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "MemberId": "public static System.String GetId(Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "MemberId": "public static System.String GetName(Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "MemberId": "public static System.String GetProfile(Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json index 37e18e53ed..997cf7bdf1 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json @@ -1,8 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults", + "Name": "Microsoft.Extensions.DependencyInjection.JwtBearerExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -11,57 +11,132 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddJwtBearer", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Bearer\"" + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddJwtBearer", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddJwtBearer", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddJwtBearer", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware", + "Name": "Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Abstract": true, + "Static": true, + "Sealed": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", + "Name": "UseJwtBearerAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "UseJwtBearerAuthentication", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" }, { "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" } ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -72,7 +147,7 @@ "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", "ImplementedInterfaces": [], "Members": [ { @@ -105,42 +180,12 @@ "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.JwtBearerOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" } ], "Visibility": "Public", @@ -149,79 +194,13 @@ ], "GenericParameters": [] }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Challenge", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, { "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", "ImplementedInterfaces": [], "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "get_AuthenticateFailure", @@ -306,6 +285,22 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_Handled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -314,13 +309,17 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -333,9 +332,7 @@ "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" - ], + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", @@ -432,7 +429,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -447,7 +443,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -462,7 +457,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -477,7 +471,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -495,7 +488,7 @@ "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", "ImplementedInterfaces": [], "Members": [ { @@ -527,9 +520,13 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" } ], "Visibility": "Public", @@ -542,7 +539,7 @@ "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", "ImplementedInterfaces": [], "Members": [ { @@ -574,9 +571,13 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" } ], "Visibility": "Public", @@ -586,7 +587,7 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -595,47 +596,24 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "UseJwtBearerAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", "Static": true, - "Extension": true, "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseJwtBearerAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [], + "Constant": true, + "Literal": "\"Bearer\"" } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.JwtBearerOptions", + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", "ImplementedInterfaces": [], "Members": [ { @@ -747,7 +725,7 @@ "Kind": "Method", "Name": "get_Events", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -757,7 +735,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents" } ], "ReturnType": "System.Void", @@ -869,27 +847,6 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "get_SecurityTokenValidators", @@ -970,7 +927,44 @@ } ], "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerPostConfigureOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json deleted file mode 100644 index 223ff401b4..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json +++ /dev/null @@ -1,43 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents : Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.JwtBearerOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJwtBearerAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json index 06b3cd0d53..5791297b27 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json @@ -1,6 +1,102 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ + { + "Name": "Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddMicrosoftAccount", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddMicrosoftAccount", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddMicrosoftAccount", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddMicrosoftAccount", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults", "Visibility": "Public", @@ -10,6 +106,16 @@ "Sealed": true, "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Field", "Name": "AuthorizationEndpoint", @@ -55,133 +161,16 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions", "Visibility": "Public", "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", "ImplementedInterfaces": [], "Members": [ - { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDisplayName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetGivenName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetSurname", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -222,7 +211,7 @@ }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions" + "Type": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions" } ], "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", @@ -233,24 +222,6 @@ } ], "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json deleted file mode 100644 index 66f2a77b4e..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json +++ /dev/null @@ -1,19 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.MicrosoftAccountOptions : Microsoft.AspNetCore.Builder.OAuthOptions", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.MicrosoftAccountAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseMicrosoftAccountAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.MicrosoftAccountOptions options)", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json index d485aedb17..ffda3cbafe 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json @@ -1,6 +1,724 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ + { + "Name": "Microsoft.Extensions.DependencyInjection.OAuthExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddOAuth", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddOAuth", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddOAuth", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler" + ] + } + ] + }, + { + "Kind": "Method", + "Name": "AddOAuth", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler" + ] + } + ] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Extensions.DependencyInjection.OAuthPostConfigureOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "T0" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseOAuthAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseOAuthAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimActionCollectionMapExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "MapJsonKey", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapJsonKey", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapJsonSubKey", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + }, + { + "Name": "subKey", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapJsonSubKey", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + }, + { + "Name": "subKey", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapCustomJson", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "resolver", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapCustomJson", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "Name": "resolver", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteClaim", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_User", + "Parameters": [], + "ReturnType": "Newtonsoft.Json.Linq.JObject", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenResponse", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ExpiresIn", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Identity", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RunClaimActions", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RunClaimActions", + "Parameters": [ + { + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + }, + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + }, + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + }, + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnCreatingTicket", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnCreatingTicket", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToAuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.Func, System.Threading.Tasks.Task>", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func, System.Threading.Tasks.Task>" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreatingTicket", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", "Visibility": "Public", @@ -16,11 +734,42 @@ "Visibility": "Protected", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "HandleRemoteAuthenticateAsync", "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, "Override": true, "Visibility": "Protected", @@ -54,7 +803,7 @@ }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "tokens", @@ -68,14 +817,14 @@ }, { "Kind": "Method", - "Name": "HandleUnauthorizedAsync", + "Name": "HandleChallengeAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, "Override": true, "Visibility": "Protected", @@ -87,7 +836,7 @@ "Parameters": [ { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "redirectUri", @@ -113,63 +862,11 @@ "Name": ".ctor", "Parameters": [ { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.OAuthOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" }, { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", + "Name": "logger", "Type": "Microsoft.Extensions.Logging.ILoggerFactory" }, { @@ -177,12 +874,8 @@ "Type": "System.Text.Encodings.Web.UrlEncoder" }, { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" } ], "Visibility": "Public", @@ -195,11 +888,201 @@ "ParameterPosition": 0, "New": true, "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.OAuthOptions" + "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" ] } ] }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClientId", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClientId", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClientSecret", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ClientSecret", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AuthorizationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UserInformationEndpoint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UserInformationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClaimActions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Scope", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StateDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", "Visibility": "Public", @@ -364,75 +1247,15 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext", + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "Abstract": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_User", - "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenResponse", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessToken", + "Name": "get_ClaimType", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -440,7 +1263,7 @@ }, { "Kind": "Method", - "Name": "get_TokenType", + "Name": "get_ValueType", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -448,112 +1271,38 @@ }, { "Kind": "Method", - "Name": "get_RefreshToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ExpiresIn", - "Parameters": [], - "ReturnType": "System.Nullable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Ticket", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Ticket", + "Name": "Run", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Identity", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsIdentity", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - }, - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "tokens", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" - } - ], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - }, - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "tokens", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" - }, - { - "Name": "user", + "Name": "userData", "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Abstract": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" } ], "Visibility": "Public", @@ -563,29 +1312,28 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" + "System.Collections.Generic.IEnumerable" ], "Members": [ { "Kind": "Method", - "Name": "get_OnCreatingTicket", + "Name": "Clear", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnCreatingTicket", + "Name": "Remove", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "claimType", + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -594,19 +1342,11 @@ }, { "Kind": "Method", - "Name": "get_OnRedirectToAuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToAuthorizationEndpoint", + "Name": "Add", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "action", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction" } ], "ReturnType": "System.Void", @@ -615,72 +1355,60 @@ }, { "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "GetEnumerator", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerator", + "Sealed": true, "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "ImplementedInterface": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.CustomJsonClaimAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Resolver", + "Parameters": [], + "ReturnType": "System.Func", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", + "Name": "Run", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Override": true, "Visibility": "Public", "GenericParameter": [] }, @@ -689,19 +1417,60 @@ "Name": ".ctor", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "claimType", + "Type": "System.String" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + "Name": "valueType", + "Type": "System.String" }, { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "resolver", + "Type": "System.Func" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.DeleteClaimAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Run", + "Parameters": [ + { + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" }, { - "Name": "redirectUri", + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "claimType", "Type": "System.String" } ], @@ -712,45 +1481,60 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonKeyClaimAction", "Visibility": "Public", "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "UseOAuthAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, + "Name": "get_JsonKey", + "Parameters": [], + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "UseOAuthAuthentication", + "Name": "Run", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -758,15 +1542,15 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.OAuthOptions", + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonSubKeyClaimAction", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonKeyClaimAction", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_ClientId", + "Name": "get_SubKey", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -774,182 +1558,53 @@ }, { "Kind": "Method", - "Name": "set_ClientId", + "Name": "Run", "Parameters": [ { - "Name": "value", + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", "Type": "System.String" } ], "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClientSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthorizationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_UserInformationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Scope", - "Parameters": [], - "ReturnType": "System.Collections.Generic.ICollection", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_StateDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_StateDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + }, + { + "Name": "subKey", + "Type": "System.String" + } + ], "Visibility": "Public", "GenericParameter": [] } ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json deleted file mode 100644 index 3124d7fe70..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json +++ /dev/null @@ -1,35 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext : Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler : Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.OAuthOptions", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware where T0 : Microsoft.AspNetCore.Builder.OAuthOptions, new()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.OAuthOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOAuthAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OAuthOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json index 64cb79487d..9623b214e8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json @@ -1,8 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", + "Name": "Microsoft.Extensions.DependencyInjection.OpenIdConnectExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -11,302 +11,196 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "AuthenticationPropertiesKey", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddOpenIdConnect", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "Caption", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddOpenIdConnect", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "CookieNoncePrefix", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddOpenIdConnect", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "RedirectUriForCodePropertiesKey", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddOpenIdConnect", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "UserstatePropertiesKey", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"OpenIdConnect\"" } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler", + "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HtmlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteSignOutAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", - "Parameters": [ - { - "Name": "signout", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleUnauthorizedAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedeemAuthorizationCodeAsync", - "Parameters": [ - { - "Name": "tokenEndpointRequest", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetUserInformationAsync", - "Parameters": [ - { - "Name": "message", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - }, - { - "Name": "jwt", - "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "htmlEncoder", - "Type": "System.Text.Encodings.Web.HtmlEncoder" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HtmlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "services", - "Type": "System.IServiceProvider" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "htmlEncoder", - "Type": "System.Text.Encodings.Web.HtmlEncoder" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", - "Visibility": "Public", - "Kind": "Enumeration", + "Abstract": true, + "Static": true, "Sealed": true, "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "RedirectGet", - "Parameters": [], - "GenericParameter": [], - "Literal": "0" + "Kind": "Method", + "Name": "UseOpenIdConnectAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] }, { - "Kind": "Field", - "Name": "FormPost", - "Parameters": [], - "GenericParameter": [], - "Literal": "1" + "Kind": "Method", + "Name": "UseOpenIdConnectAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimActionCollectionUniqueExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "MapUniqueJsonKey", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapUniqueJsonKey", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] } ], "GenericParameters": [] @@ -315,9 +209,30 @@ "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Exception", @@ -347,9 +262,13 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" } ], "Visibility": "Public", @@ -362,24 +281,24 @@ "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Properties", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Properties", + "Name": "set_ProtocolMessage", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], "ReturnType": "System.Void", @@ -511,9 +430,17 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -523,20 +450,12 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "get_ProtocolMessage", @@ -558,152 +477,6 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizationCodeReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToIdentityProvider", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToIdentityProviderForSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RemoteSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenResponseReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UserInformationReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ { "Kind": "Method", "Name": "get_Token", @@ -725,27 +498,6 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Constructor", "Name": ".ctor", @@ -754,9 +506,17 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -770,9 +530,7 @@ "Visibility": "Public", "Kind": "Class", "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" - ], + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", @@ -974,7 +732,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -989,7 +746,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1004,7 +760,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1019,7 +774,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1034,7 +788,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1049,7 +802,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1064,7 +816,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1079,7 +830,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1094,7 +844,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1112,14 +861,43 @@ "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Properties", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Handled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, @@ -1131,13 +909,17 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -1150,9 +932,30 @@ "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -1161,9 +964,13 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" }, { "Name": "message", @@ -1180,14 +987,27 @@ "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Properties", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, @@ -1220,13 +1040,21 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -1239,24 +1067,24 @@ "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Properties", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Properties", + "Name": "set_ProtocolMessage", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], "ReturnType": "System.Void", @@ -1334,9 +1162,21 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -1349,9 +1189,30 @@ "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_User", @@ -1381,9 +1242,21 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -1393,45 +1266,268 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", "Visibility": "Public", "Kind": "Class", "Abstract": true, "Static": true, "Sealed": true, "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "AuthenticationPropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "CookieNoncePrefix", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "RedirectUriForCodePropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "UserstatePropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"OpenIdConnect\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" + ], "Members": [ { "Kind": "Method", - "Name": "UseOpenIdConnectAuthentication", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HtmlEncoder", + "Parameters": [], + "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "UseOpenIdConnectAuthentication", + "Name": "HandleRemoteSignOutAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignOutAsync", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutCallbackAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedeemAuthorizationCodeAsync", + "Parameters": [ + { + "Name": "tokenEndpointRequest", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetUserInformationAsync", + "Parameters": [ + { + "Name": "message", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + }, + { + "Name": "jwt", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "htmlEncoder", + "Type": "System.Text.Encodings.Web.HtmlEncoder" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -1439,12 +1535,22 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Authority", @@ -1571,6 +1677,14 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ClaimActions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_RequireHttpsMetadata", @@ -1617,7 +1731,7 @@ "Kind": "Method", "Name": "get_Events", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1627,7 +1741,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents" } ], "ReturnType": "System.Void", @@ -1657,7 +1771,28 @@ }, { "Kind": "Method", - "Name": "get_PostLogoutRedirectUri", + "Name": "get_SignedOutCallbackPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignedOutCallbackPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignedOutRedirectUri", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -1665,7 +1800,7 @@ }, { "Kind": "Method", - "Name": "set_PostLogoutRedirectUri", + "Name": "set_SignedOutRedirectUri", "Parameters": [ { "Name": "value", @@ -1835,7 +1970,7 @@ "Kind": "Method", "Name": "get_StateDataFormat", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, @@ -1845,7 +1980,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" } ], "ReturnType": "System.Void", @@ -1959,19 +2094,40 @@ }, { "Kind": "Method", - "Name": "get_SystemClock", + "Name": "get_DisableTelemetry", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SystemClock", + "Name": "set_DisableTelemetry", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_NonceCookie", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_NonceCookie", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" } ], "ReturnType": "System.Void", @@ -1984,13 +2140,121 @@ "Parameters": [], "Visibility": "Public", "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectPostConfigureOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", "Parameters": [ { - "Name": "authenticationScheme", + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "RedirectGet", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "FormPost", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.Claims.UniqueJsonKeyClaimAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonKeyClaimAction", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Run", + "Parameters": [ + { + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "Name": "jsonKey", "Type": "System.String" } ], @@ -2000,6 +2264,5 @@ ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json deleted file mode 100644 index 931a7b079d..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json +++ /dev/null @@ -1,68 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler : Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.OpenIdConnectOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOpenIdConnectAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", - "MemberId": "public static readonly System.String Caption", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json index c35232a310..b577f07eb1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json @@ -1,8 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterDefaults", + "Name": "Microsoft.Extensions.DependencyInjection.TwitterExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -11,99 +11,86 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddTwitter", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Twitter\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.TwitterOptions", + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "AddTwitter", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + "Name": "configureOptions", + "Type": "System.Action" } ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddTwitter", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddTwitter", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -111,36 +98,46 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Name": "Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", "Visibility": "Public", - "Kind": "Interface", + "Kind": "Class", "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "CreatingTicket", + "Name": "UseTwitterAuthentication", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", + "Name": "UseTwitterAuthentication", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", "GenericParameter": [] } ], @@ -150,7 +147,7 @@ "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", "ImplementedInterfaces": [], "Members": [ { @@ -193,48 +190,6 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Constructor", "Name": ".ctor", @@ -243,9 +198,21 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "userId", @@ -279,9 +246,7 @@ "Visibility": "Public", "Kind": "Class", "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" - ], + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", @@ -308,7 +273,7 @@ "Kind": "Method", "Name": "get_OnRedirectToAuthorizationEndpoint", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func, System.Threading.Tasks.Task>", "Visibility": "Public", "GenericParameter": [] }, @@ -318,7 +283,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func, System.Threading.Tasks.Task>" } ], "ReturnType": "System.Void", @@ -336,7 +301,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -346,12 +310,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -365,56 +328,6 @@ ], "GenericParameters": [] }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "redirectUri", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, { "Name": "Microsoft.AspNetCore.Authentication.Twitter.AccessToken", "Visibility": "Public", @@ -547,7 +460,7 @@ "Kind": "Method", "Name": "get_Properties", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", "Visibility": "Public", "GenericParameter": [] }, @@ -557,7 +470,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Void", @@ -655,7 +568,7 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterDefaults", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -664,47 +577,34 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "UseTwitterAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", "Static": true, - "Extension": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "UseTwitterAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", "Static": true, - "Extension": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [], + "Constant": true, + "Literal": "\"Twitter\"" } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.TwitterOptions", + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", "ImplementedInterfaces": [], "Members": [ { @@ -770,6 +670,14 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ClaimActions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_StateDataFormat", @@ -795,7 +703,7 @@ "Kind": "Method", "Name": "get_Events", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -805,7 +713,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents" } ], "ReturnType": "System.Void", @@ -814,19 +722,19 @@ }, { "Kind": "Method", - "Name": "get_SystemClock", + "Name": "get_StateCookie", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SystemClock", + "Name": "set_StateCookie", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" } ], "ReturnType": "System.Void", @@ -842,7 +750,49 @@ } ], "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterPostConfigureOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json deleted file mode 100644 index 6b84409111..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json +++ /dev/null @@ -1,45 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext : Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.TwitterOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseTwitterAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.TwitterOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json index 1f69da5a8f..6db7d2c81d 100644 --- a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json @@ -1,488 +1,140 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Visibility": "Public", "Kind": "Class", - "Abstract": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_AuthenticationScheme", + "Name": "get_Services", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_AuthenticationScheme", + "Name": "AddScheme", "Parameters": [ { - "Name": "value", + "Name": "authenticationScheme", "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AutomaticAuthenticate", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AutomaticAuthenticate", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AutomaticChallenge", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AutomaticChallenge", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClaimsIssuer", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClaimsIssuer", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Description", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Description", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" }, { - "Name": "transform", - "Type": "System.Func>" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "displayName", + "Type": "System.String" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Virtual": true, "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Transformer", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] }, { "Kind": "Method", - "Name": "set_Transformer", + "Name": "AddScheme", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Virtual": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] + }, + { + "Kind": "Method", + "Name": "AddRemoteScheme", + "Parameters": [ + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler" + ] + } + ] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_BackchannelTimeout", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelTimeout", "Parameters": [ { - "Name": "value", - "Type": "System.TimeSpan" + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" } ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_BackchannelHttpHandler", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpMessageHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelHttpHandler", - "Parameters": [ - { - "Name": "value", - "Type": "System.Net.Http.HttpMessageHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CallbackPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CallbackPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SignInScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignInScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_DisplayName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_DisplayName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RemoteAuthenticationTimeout", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RemoteAuthenticationTimeout", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SaveTokens", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SaveTokens", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Succeeded", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Ticket", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Failure", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Success", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Skip", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Fail", - "Parameters": [ - { - "Name": "failure", - "Type": "System.Exception" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Fail", - "Parameters": [ - { - "Name": "failureMessage", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, "Visibility": "Public", "GenericParameter": [] } @@ -495,70 +147,23 @@ "Kind": "Class", "Abstract": true, "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + "Microsoft.AspNetCore.Authentication.IAuthenticationHandler" ], "Members": [ { "Kind": "Method", - "Name": "get_SignInAccepted", + "Name": "get_Scheme", "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationScheme", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SignInAccepted", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SignOutAccepted", + "Name": "get_Options", "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignOutAccepted", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ChallengeCalled", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ChallengeCalled", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", + "ReturnType": "T0", + "Visibility": "Public", "GenericParameter": [] }, { @@ -587,7 +192,7 @@ }, { "Kind": "Method", - "Name": "get_OriginalPathBase", + "Name": "get_OriginalPath", "Parameters": [], "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Protected", @@ -595,7 +200,7 @@ }, { "Kind": "Method", - "Name": "get_OriginalPath", + "Name": "get_OriginalPathBase", "Parameters": [], "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Protected", @@ -619,23 +224,50 @@ }, { "Kind": "Method", - "Name": "get_PriorHandler", + "Name": "get_Clock", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_PriorHandler", + "Name": "get_OptionsMonitor", + "Parameters": [], + "ReturnType": "Microsoft.Extensions.Options.IOptionsMonitor", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "System.Object", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + "Type": "System.Object" } ], "ReturnType": "System.Void", - "Visibility": "Public", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClaimsIssuer", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { @@ -648,35 +280,49 @@ }, { "Kind": "Method", - "Name": "get_Options", + "Name": "InitializeAsync", + "Parameters": [ + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "InitializeEventsAsync", "Parameters": [], - "ReturnType": "T0", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "InitializeAsync", - "Parameters": [ - { - "Name": "options", - "Type": "T0" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "logger", - "Type": "Microsoft.Extensions.Logging.ILogger" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - } - ], + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "InitializeHandlerAsync", + "Parameters": [], "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { @@ -692,70 +338,14 @@ "Visibility": "Protected", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "FinishResponseAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDescriptions", - "Parameters": [ - { - "Name": "describeContext", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ShouldHandleScheme", - "Parameters": [ - { - "Name": "authenticationScheme", - "Type": "System.String" - }, - { - "Name": "handleAutomatic", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "AuthenticateAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Sealed": true, "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, @@ -767,6 +357,14 @@ "Visibility": "Protected", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "HandleAuthenticateOnceSafeAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Protected", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "HandleAuthenticateAsync", @@ -777,90 +375,30 @@ "Visibility": "Protected", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "SignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "HandleForbiddenAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "HandleUnauthorizedAsync", + "Name": "HandleChallengeAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, "Visibility": "Protected", "GenericParameter": [] @@ -870,168 +408,52 @@ "Name": "ChallengeAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Threading.Tasks.Task", "Sealed": true, "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.AuthenticationOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_AuthenticationScheme", + "Name": "ForbidAsync", "Parameters": [ { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "T0", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "T0" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Logger", - "Parameters": [], - "ReturnType": "Microsoft.Extensions.Logging.ILogger", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Logger", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.Extensions.Logging.ILogger" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_UrlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.UrlEncoder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_UrlEncoder", - "Parameters": [ - { - "Name": "value", - "Type": "System.Text.Encodings.Web.UrlEncoder" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Invoke", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Sealed": true, "Virtual": true, - "Abstract": true, - "Visibility": "Protected", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, { "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" }, { - "Name": "loggerFactory", + "Name": "logger", "Type": "Microsoft.Extensions.Logging.ILoggerFactory" }, { "Name": "encoder", "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" } ], "Visibility": "Protected", @@ -1044,347 +466,32 @@ "ParameterPosition": 0, "New": true, "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.AuthenticationOptions" + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" ] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", "Visibility": "Public", "Kind": "Class", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_AuthenticationScheme", + "Name": "get_Schemes", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationToken", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Name", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Name", + "Name": "set_Schemes", "Parameters": [ { "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Value", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Value", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Context", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_PriorHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PriorHandler", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthenticateAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ChallengeAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDescriptions", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RegisterAuthenticationHandler", - "Parameters": [ - { - "Name": "auth", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UnregisterAuthenticationHandler", - "Parameters": [ - { - "Name": "auth", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "transform", - "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - }, - { - "Name": "httpContext", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" + "Type": "Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider" } ], "ReturnType": "System.Void", @@ -1413,8 +520,8 @@ "Type": "Microsoft.AspNetCore.Http.RequestDelegate" }, { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "schemes", + "Type": "Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider" } ], "Visibility": "Public", @@ -1424,245 +531,23 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformer", + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnTransform", - "Parameters": [], - "ReturnType": "System.Func>", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTransform", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func>" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TransformAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "TransformAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_UtcNow", + "Name": "Validate", "Parameters": [], - "ReturnType": "System.DateTimeOffset", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteCallbackAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleForbiddenAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GenerateCorrelationId", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], "ReturnType": "System.Void", "Virtual": true, - "Visibility": "Protected", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ValidateCorrelationId", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Boolean", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_SignInScheme", + "Name": "get_ClaimsIssuer", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -1670,7 +555,7 @@ }, { "Kind": "Method", - "Name": "set_SignInScheme", + "Name": "set_ClaimsIssuer", "Parameters": [ { "Name": "value", @@ -1681,146 +566,52 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SystemClock", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.ISystemClock" - ], - "Members": [ { "Kind": "Method", - "Name": "get_UtcNow", + "Name": "get_Events", "Parameters": [], - "ReturnType": "System.DateTimeOffset", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISystemClock", + "ReturnType": "System.Object", "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ { "Kind": "Method", - "Name": "StoreTokens", + "Name": "set_Events", "Parameters": [ { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokens", - "Type": "System.Collections.Generic.IEnumerable" + "Name": "value", + "Type": "System.Object" } ], "ReturnType": "System.Void", - "Static": true, - "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetTokenValue", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Static": true, - "Extension": true, + "Name": "get_EventsType", + "Parameters": [], + "ReturnType": "System.Type", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetTokens", + "Name": "set_EventsType", "Parameters": [ { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "value", + "Type": "System.Type" } ], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Static": true, - "Extension": true, + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetTokenAsync", - "Parameters": [ - { - "Name": "manager", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTokenAsync", - "Parameters": [ - { - "Name": "manager", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" - }, - { - "Name": "signInScheme", - "Type": "System.String" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -1943,7 +734,7 @@ "Name": "Microsoft.AspNetCore.Authentication.PropertiesDataFormat", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", + "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", "ImplementedInterfaces": [], "Members": [ { @@ -1966,7 +757,7 @@ "Visibility": "Public", "Kind": "Class", "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" + "Microsoft.AspNetCore.Authentication.IDataSerializer" ], "Members": [ { @@ -1984,12 +775,12 @@ "Parameters": [ { "Name": "model", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Byte[]", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, @@ -2002,9 +793,9 @@ "Type": "System.Byte[]" } ], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, @@ -2018,7 +809,7 @@ }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Void", @@ -2035,7 +826,7 @@ "Type": "System.IO.BinaryReader" } ], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", "Virtual": true, "Visibility": "Public", "GenericParameter": [] @@ -2375,12 +1166,28 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.BaseContext", + "Name": "Microsoft.AspNetCore.Authentication.BaseContext", "Visibility": "Public", "Kind": "Class", "Abstract": true, "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "get_Scheme", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationScheme", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Options", + "Parameters": [], + "ReturnType": "T0", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_HttpContext", @@ -2412,56 +1219,56 @@ { "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" } ], "Visibility": "Protected", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_State", + "Name": "get_Result", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.EventResultState", + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_State", + "Name": "set_Result", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.EventResultState" + "Type": "Microsoft.AspNetCore.Authentication.HandleRequestResult" } ], "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HandledResponse", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { @@ -2474,47 +1281,12 @@ }, { "Kind": "Method", - "Name": "SkipToNextMiddleware", + "Name": "SkipHandler", "Parameters": [], "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "get_Ticket", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Ticket", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CheckEventResult", - "Parameters": [ - { - "Name": "result", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Direction": "Out" - } - ], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Constructor", "Name": ".ctor", @@ -2522,67 +1294,184 @@ { "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" } ], "Visibility": "Protected", "GenericParameter": [] } ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.EventResultState", - "Visibility": "Public", - "Kind": "Enumeration", - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ + "GenericParameters": [ { - "Kind": "Field", - "Name": "Continue", - "Parameters": [], - "GenericParameter": [], - "Literal": "0" - }, - { - "Kind": "Field", - "Name": "Skipped", - "Parameters": [], - "GenericParameter": [], - "Literal": "1" - }, - { - "Kind": "Field", - "Name": "HandledResponse", - "Parameters": [], - "GenericParameter": [], - "Literal": "2" + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] } - ], - "GenericParameters": [] + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.FailureContext", + "Name": "Microsoft.AspNetCore.Authentication.PrincipalContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Failure", + "Name": "get_Principal", "Parameters": [], - "ReturnType": "System.Exception", + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Failure", + "Name": "set_Principal", "Parameters": [ { "Name": "value", - "Type": "System.Exception" + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PropertiesContext", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.RedirectContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_RedirectUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RedirectUri", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -2598,63 +1487,168 @@ "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "failure", - "Type": "System.Exception" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" } ], "Visibility": "Public", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "Visibility": "Public", - "Kind": "Interface", + "Kind": "Class", "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.HandleRequestContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "RemoteFailure", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.FailureContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TicketReceived", + "Name": "set_Principal", + "Parameters": [ + { + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Success", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failure", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Protected", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] }, { "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", "Name": "get_OnRemoteFailure", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func", "Visibility": "Public", "GenericParameter": [] }, @@ -2664,7 +1658,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func" } ], "ReturnType": "System.Void", @@ -2698,12 +1692,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.FailureContext" + "Type": "Microsoft.AspNetCore.Authentication.RemoteFailureContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -2718,7 +1711,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -2733,10 +1725,66 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.TicketReceivedContext", + "Name": "Microsoft.AspNetCore.Authentication.RemoteFailureContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "BaseType": "Microsoft.AspNetCore.Authentication.HandleRequestContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Failure", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Failure", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + }, + { + "Name": "failure", + "Type": "System.Exception" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ResultContext", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", "ImplementedInterfaces": [], "Members": [ { @@ -2764,7 +1812,7 @@ "Kind": "Method", "Name": "get_Properties", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", "Visibility": "Public", "GenericParameter": [] }, @@ -2774,7 +1822,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Void", @@ -2783,25 +1831,92 @@ }, { "Kind": "Method", - "Name": "get_Options", + "Name": "get_Result", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Options", + "Name": "Success", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "NoResult", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + "Name": "failure", + "Type": "System.Exception" } ], "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" + } + ], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.TicketReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", "Name": "get_ReturnUri", @@ -2831,9 +1946,13 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" }, { "Name": "ticket", @@ -2846,6 +1965,621 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_SignInScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ShouldHandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleForbiddenAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GenerateCorrelationId", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ValidateCorrelationId", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Boolean", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Protected", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_BackchannelTimeout", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_BackchannelTimeout", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_BackchannelHttpHandler", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpMessageHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_BackchannelHttpHandler", + "Parameters": [ + { + "Name": "value", + "Type": "System.Net.Http.HttpMessageHandler" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Backchannel", + "Parameters": [ + { + "Name": "value", + "Type": "System.Net.Http.HttpClient" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_DataProtectionProvider", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DataProtectionProvider", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CallbackPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CallbackPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignInScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignInScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RemoteAuthenticationTimeout", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RemoteAuthenticationTimeout", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SaveTokens", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SaveTokens", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CorrelationCookie", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CorrelationCookie", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Handled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Skipped", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Success", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failure", + "Type": "System.Exception" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Handle", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SystemClock", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.ISystemClock" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Internal.RequestPathBaseCookieBuilder", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Http.CookieBuilder", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AdditionalPath", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Build", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "expiresFrom", + "Type": "System.DateTimeOffset" + } + ], + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.AuthAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", "Visibility": "Public", @@ -2864,7 +2598,26 @@ "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" } ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddAuthentication", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "defaultScheme", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, "Extension": true, "Visibility": "Public", @@ -2880,18 +2633,189 @@ }, { "Name": "configureOptions", - "Type": "System.Action" + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddScheme", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureScheme", + "Type": "System.Action" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", "Static": true, "Extension": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] + }, + { + "Kind": "Method", + "Name": "AddScheme", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] + }, + { + "Kind": "Method", + "Name": "AddScheme", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] + }, + { + "Kind": "Method", + "Name": "AddRemoteScheme", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler" + ] + } + ] } ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json deleted file mode 100644 index 81dc1133e2..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json +++ /dev/null @@ -1,116 +0,0 @@ - [ - { - "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.AuthenticationHandler : Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.AuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.AuthenticationMiddleware where T0 : Microsoft.AspNetCore.Builder.AuthenticationOptions, new()", - "Kind": "Removal" - }, - { - "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public abstract class Microsoft.AspNetCore.Builder.AuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticationToken", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler : Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformer : Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.PropertiesDataFormat : Microsoft.AspNetCore.Authentication.SecureDataFormat", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.PropertiesSerializer : Microsoft.AspNetCore.Authentication.IDataSerializer", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", - "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configureOptions)", - "Kind": "Removal" - }, - { - "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.FailureContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", - "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)", - "Kind": "Removal" - }, - { - "TypeId": "public enum Microsoft.AspNetCore.Authentication.EventResultState", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json new file mode 100644 index 0000000000..0bad3ed62c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json @@ -0,0 +1,211 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AuthenticateAsync", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + }, + { + "Name": "authenticationResult", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "resource", + "Type": "System.Object" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Challenged", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Forbidden", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Succeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Challenge", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Forbid", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Success", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Policy.PolicyEvaluator", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator" + ], + "Members": [ + { + "Kind": "Method", + "Name": "AuthenticateAsync", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + }, + { + "Name": "authenticationResult", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "resource", + "Type": "System.Object" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "authorization", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Extensions.DependencyInjection.PolicyServiceCollectionExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddAuthorizationPolicyEvaluator", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json index 8ae585270c..6108db6d29 100644 --- a/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.AuthorizationServiceCollectionExtensions", @@ -66,6 +66,54 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationFailure", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_FailCalled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_FailedRequirements", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExplicitFail", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationFailure", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Failed", + "Parameters": [ + { + "Name": "failed", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationFailure", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", "Visibility": "Public", @@ -208,6 +256,7 @@ "Name": "get_Requirements", "Parameters": [], "ReturnType": "System.Collections.Generic.IEnumerable", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -216,6 +265,7 @@ "Name": "get_User", "Parameters": [], "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -224,6 +274,7 @@ "Name": "get_Resource", "Parameters": [], "ReturnType": "System.Object", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -232,6 +283,7 @@ "Name": "get_PendingRequirements", "Parameters": [], "ReturnType": "System.Collections.Generic.IEnumerable", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -240,6 +292,7 @@ "Name": "get_HasFailed", "Parameters": [], "ReturnType": "System.Boolean", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -248,6 +301,7 @@ "Name": "get_HasSucceeded", "Parameters": [], "ReturnType": "System.Boolean", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -256,6 +310,7 @@ "Name": "Fail", "Parameters": [], "ReturnType": "System.Void", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -269,6 +324,7 @@ } ], "ReturnType": "System.Void", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -301,6 +357,27 @@ "Kind": "Class", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "get_InvokeHandlersAfterFailure", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_InvokeHandlersAfterFailure", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_DefaultPolicy", @@ -714,6 +791,63 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Succeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Failure", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationFailure", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Success", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Failed", + "Parameters": [ + { + "Name": "failure", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationFailure" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Failed", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authorization.AuthorizationServiceExtensions", "Visibility": "Public", @@ -744,7 +878,7 @@ "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Static": true, "Extension": true, "Visibility": "Public", @@ -771,7 +905,7 @@ "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Static": true, "Extension": true, "Visibility": "Public", @@ -794,7 +928,7 @@ "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Static": true, "Extension": true, "Visibility": "Public", @@ -817,7 +951,7 @@ "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Static": true, "Extension": true, "Visibility": "Public", @@ -891,7 +1025,7 @@ }, { "Kind": "Method", - "Name": "get_ActiveAuthenticationSchemes", + "Name": "get_AuthenticationSchemes", "Parameters": [], "ReturnType": "System.String", "Sealed": true, @@ -900,6 +1034,30 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "set_AuthenticationSchemes", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ActiveAuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "set_ActiveAuthenticationSchemes", @@ -910,9 +1068,6 @@ } ], "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", "Visibility": "Public", "GenericParameter": [] }, @@ -938,6 +1093,120 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationEvaluator", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationEvaluator" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Evaluate", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationEvaluator", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationHandlerContextFactory", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerContextFactory" + ], + "Members": [ + { + "Kind": "Method", + "Name": "CreateContext", + "Parameters": [ + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerContextFactory", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationHandlerProvider", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "GetHandlersAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task>", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "handlers", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationPolicyProvider", "Visibility": "Public", @@ -1012,7 +1281,7 @@ "Type": "System.Collections.Generic.IEnumerable" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Sealed": true, "Virtual": true, "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", @@ -1036,7 +1305,7 @@ "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Sealed": true, "Virtual": true, "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", @@ -1053,11 +1322,23 @@ }, { "Name": "handlers", - "Type": "System.Collections.Generic.IEnumerable" + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerProvider" }, { "Name": "logger", "Type": "Microsoft.Extensions.Logging.ILogger" + }, + { + "Name": "contextFactory", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerContextFactory" + }, + { + "Name": "evaluator", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationEvaluator" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" } ], "Visibility": "Public", @@ -1075,6 +1356,28 @@ "Members": [], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationEvaluator", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Evaluate", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", "Visibility": "Public", @@ -1097,6 +1400,58 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerContextFactory", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateContext", + "Parameters": [ + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerProvider", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetHandlersAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task>", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", "Visibility": "Public", @@ -1159,7 +1514,7 @@ "Type": "System.Collections.Generic.IEnumerable" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "GenericParameter": [] }, { @@ -1179,7 +1534,7 @@ "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "GenericParameter": [] } ], @@ -1232,14 +1587,14 @@ }, { "Kind": "Method", - "Name": "get_ActiveAuthenticationSchemes", + "Name": "get_AuthenticationSchemes", "Parameters": [], "ReturnType": "System.String", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ActiveAuthenticationSchemes", + "Name": "set_AuthenticationSchemes", "Parameters": [ { "Name": "value", @@ -1588,6 +1943,5 @@ ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json index 8eef347eb6..97da7ea5c6 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", @@ -53,6 +53,27 @@ "Kind": "Class", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "get_MinimumSameSitePolicy", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.SameSiteMode", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MinimumSameSitePolicy", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.SameSiteMode" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_HttpOnly", @@ -387,6 +408,5 @@ ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json index 1fc242ec55..a55bf8f339 100644 --- a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json +++ b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", @@ -368,6 +368,5 @@ ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file From 144ee21696e838c1f96676573ffe30e8f2ba8bd6 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 6 Jul 2017 12:36:34 -0700 Subject: [PATCH 808/900] #1188 Add AuthenticationProperties to HandleRequestResult and RemoteFailureContext --- samples/SocialSample/Startup.cs | 59 +++++-- .../OAuthHandler.cs | 38 ++--- .../OpenIdConnectHandler.cs | 43 +++-- .../TwitterHandler.cs | 9 +- .../Events/RemoteFailureContext.cs | 5 + ...cationResult.cs => HandleRequestResult.cs} | 24 ++- .../RemoteAuthenticationHandler.cs | 19 ++- .../GoogleTests.cs | 36 +++- .../OAuthTests.cs | 156 ++++++++++-------- .../OpenIdConnect/OpenIdConnectEventTests.cs | 18 +- .../TwitterTests.cs | 117 ++++++++----- 11 files changed, 346 insertions(+), 178 deletions(-) rename src/Microsoft.AspNetCore.Authentication/{RemoteAuthenticationResult.cs => HandleRequestResult.cs} (72%) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index a0b193b8e2..35896e84b1 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -67,6 +67,10 @@ namespace SocialSample o.Fields.Add("name"); o.Fields.Add("email"); o.SaveTokens = true; + o.Events = new OAuthEvents() + { + OnRemoteFailure = HandleOnRemoteFailure + }; }) // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project @@ -81,6 +85,10 @@ namespace SocialSample o.Scope.Add("profile"); o.Scope.Add("email"); o.SaveTokens = true; + o.Events = new OAuthEvents() + { + OnRemoteFailure = HandleOnRemoteFailure + }; }) // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project @@ -93,12 +101,7 @@ namespace SocialSample o.SaveTokens = true; o.Events = new OAuthEvents() { - OnRemoteFailure = ctx => - { - ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); - ctx.HandleResponse(); - return Task.FromResult(0); - } + OnRemoteFailure = HandleOnRemoteFailure }; o.ClaimActions.MapJsonSubKey("urn:google:image", "image", "url"); o.ClaimActions.Remove(ClaimTypes.GivenName); @@ -116,12 +119,7 @@ namespace SocialSample o.ClaimActions.MapJsonKey("urn:twitter:profilepicture", "profile_image_url", ClaimTypes.Uri); o.Events = new TwitterEvents() { - OnRemoteFailure = ctx => - { - ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); - ctx.HandleResponse(); - return Task.FromResult(0); - } + OnRemoteFailure = HandleOnRemoteFailure }; }) /* Azure AD app model v2 has restrictions that prevent the use of plain HTTP for redirect URLs. @@ -139,6 +137,10 @@ namespace SocialSample o.TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; o.Scope.Add("https://graph.microsoft.com/user.read"); o.SaveTokens = true; + o.Events = new OAuthEvents() + { + OnRemoteFailure = HandleOnRemoteFailure + }; }) // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. // https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/ @@ -148,6 +150,10 @@ namespace SocialSample o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; o.SaveTokens = true; o.Scope.Add("offline_access"); + o.Events = new OAuthEvents() + { + OnRemoteFailure = HandleOnRemoteFailure + }; }) // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ @@ -159,6 +165,10 @@ namespace SocialSample o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; o.TokenEndpoint = "https://github.com/login/oauth/access_token"; o.SaveTokens = true; + o.Events = new OAuthEvents() + { + OnRemoteFailure = HandleOnRemoteFailure + }; }) // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ @@ -180,6 +190,7 @@ namespace SocialSample o.ClaimActions.MapJsonKey("urn:github:url", "url"); o.Events = new OAuthEvents { + OnRemoteFailure = HandleOnRemoteFailure, OnCreatingTicket = async context => { // Get the GitHub user @@ -198,6 +209,30 @@ namespace SocialSample }); } + private async Task HandleOnRemoteFailure(RemoteFailureContext context) + { + context.Response.StatusCode = 500; + context.Response.ContentType = "text/html"; + await context.Response.WriteAsync(""); + await context.Response.WriteAsync("A remote failure has occurred: " + UrlEncoder.Default.Encode(context.Failure.Message) + "
"); + + if (context.Properties != null) + { + await context.Response.WriteAsync("Properties:
"); + foreach (var pair in context.Properties.Items) + { + await context.Response.WriteAsync($"-{ UrlEncoder.Default.Encode(pair.Key)}={ UrlEncoder.Default.Encode(pair.Value)}
"); + } + } + + await context.Response.WriteAsync("Home"); + await context.Response.WriteAsync(""); + + // context.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(context.Failure.Message)); + + context.HandleResponse(); + } + public void Configure(IApplicationBuilder app) { app.UseDeveloperExceptionPage(); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 007d7dbefd..80680a7cf8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -44,9 +44,22 @@ namespace Microsoft.AspNetCore.Authentication.OAuth protected override async Task HandleRemoteAuthenticateAsync() { - AuthenticationProperties properties = null; var query = Request.Query; + var state = query["state"]; + var properties = Options.StateDataFormat.Unprotect(state); + + if (properties == null) + { + return HandleRequestResult.Fail("The oauth state was missing or invalid."); + } + + // OAuth2 10.12 CSRF + if (!ValidateCorrelationId(properties)) + { + return HandleRequestResult.Fail("Correlation failed.", properties); + } + var error = query["error"]; if (!StringValues.IsNullOrEmpty(error)) { @@ -63,39 +76,26 @@ namespace Microsoft.AspNetCore.Authentication.OAuth failureMessage.Append(";Uri=").Append(errorUri); } - return HandleRequestResult.Fail(failureMessage.ToString()); + return HandleRequestResult.Fail(failureMessage.ToString(), properties); } var code = query["code"]; - var state = query["state"]; - - properties = Options.StateDataFormat.Unprotect(state); - if (properties == null) - { - return HandleRequestResult.Fail("The oauth state was missing or invalid."); - } - - // OAuth2 10.12 CSRF - if (!ValidateCorrelationId(properties)) - { - return HandleRequestResult.Fail("Correlation failed."); - } if (StringValues.IsNullOrEmpty(code)) { - return HandleRequestResult.Fail("Code was not found."); + return HandleRequestResult.Fail("Code was not found.", properties); } var tokens = await ExchangeCodeAsync(code, BuildRedirectUri(Options.CallbackPath)); if (tokens.Error != null) { - return HandleRequestResult.Fail(tokens.Error); + return HandleRequestResult.Fail(tokens.Error, properties); } if (string.IsNullOrEmpty(tokens.AccessToken)) { - return HandleRequestResult.Fail("Failed to retrieve access token."); + return HandleRequestResult.Fail("Failed to retrieve access token.", properties); } var identity = new ClaimsIdentity(ClaimsIssuer); @@ -141,7 +141,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth } else { - return HandleRequestResult.Fail("Failed to retrieve user information from remote server."); + return HandleRequestResult.Fail("Failed to retrieve user information from remote server.", properties); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index bf365ceca0..7f65afdcec 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -491,13 +491,10 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return HandleRequestResult.Fail("No message."); } + AuthenticationProperties properties = null; try { - AuthenticationProperties properties = null; - if (!string.IsNullOrEmpty(authorizationResponse.State)) - { - properties = Options.StateDataFormat.Unprotect(authorizationResponse.State); - } + properties = ReadPropertiesAndClearState(authorizationResponse); var messageReceivedContext = await RunMessageReceivedEventAsync(authorizationResponse, properties); if (messageReceivedContext.Result != null) @@ -521,8 +518,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return HandleRequestResult.Fail(Resources.MessageStateIsNullOrEmpty); } - // if state exists and we failed to 'unprotect' this is not a message we should process. - properties = Options.StateDataFormat.Unprotect(authorizationResponse.State); + properties = ReadPropertiesAndClearState(authorizationResponse); } if (properties == null) @@ -533,21 +529,20 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // Not for us? return HandleRequestResult.SkipHandler(); } + + // if state exists and we failed to 'unprotect' this is not a message we should process. return HandleRequestResult.Fail(Resources.MessageStateIsInvalid); } - properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out string userstate); - authorizationResponse.State = userstate; - if (!ValidateCorrelationId(properties)) { - return HandleRequestResult.Fail("Correlation failed."); + return HandleRequestResult.Fail("Correlation failed.", properties); } // if any of the error fields are set, throw error null if (!string.IsNullOrEmpty(authorizationResponse.Error)) { - return HandleRequestResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null)); + return HandleRequestResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null), properties); } if (_configuration == null && Options.ConfigurationManager != null) @@ -635,8 +630,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // At least a cursory validation is required on the new IdToken, even if we've already validated the one from the authorization response. // And we'll want to validate the new JWT in ValidateTokenResponse. - JwtSecurityToken tokenEndpointJwt; - var tokenEndpointUser = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out tokenEndpointJwt); + var tokenEndpointUser = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out var tokenEndpointJwt); // Avoid reading & deleting the nonce cookie, running the event, etc, if it was already done as part of the authorization response validation. if (user == null) @@ -722,10 +716,27 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect return authenticationFailedContext.Result; } - return HandleRequestResult.Fail(exception); + return HandleRequestResult.Fail(exception, properties); } } + private AuthenticationProperties ReadPropertiesAndClearState(OpenIdConnectMessage message) + { + AuthenticationProperties properties = null; + if (!string.IsNullOrEmpty(message.State)) + { + properties = Options.StateDataFormat.Unprotect(message.State); + + if (properties != null) + { + // If properties can be decoded from state, clear the message state. + properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out var userstate); + message.State = userstate; + } + } + return properties; + } + private void PopulateSessionProperties(OpenIdConnectMessage message, AuthenticationProperties properties) { if (!string.IsNullOrEmpty(message.SessionState)) @@ -830,7 +841,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } else { - return HandleRequestResult.Fail("Unknown response type: " + contentType.MediaType); + return HandleRequestResult.Fail("Unknown response type: " + contentType.MediaType, properties); } var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(principal, properties, message, user); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index e8a961df39..acfd765d9c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -46,7 +46,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter protected override async Task HandleRemoteAuthenticateAsync() { - AuthenticationProperties properties = null; var query = Request.Query; var protectedRequestToken = Request.Cookies[Options.StateCookie.Name]; @@ -57,25 +56,25 @@ namespace Microsoft.AspNetCore.Authentication.Twitter return HandleRequestResult.Fail("Invalid state cookie."); } - properties = requestToken.Properties; + var properties = requestToken.Properties; // REVIEW: see which of these are really errors var returnedToken = query["oauth_token"]; if (StringValues.IsNullOrEmpty(returnedToken)) { - return HandleRequestResult.Fail("Missing oauth_token"); + return HandleRequestResult.Fail("Missing oauth_token", properties); } if (!string.Equals(returnedToken, requestToken.Token, StringComparison.Ordinal)) { - return HandleRequestResult.Fail("Unmatched token"); + return HandleRequestResult.Fail("Unmatched token", properties); } var oauthVerifier = query["oauth_verifier"]; if (StringValues.IsNullOrEmpty(oauthVerifier)) { - return HandleRequestResult.Fail("Missing or blank oauth_verifier"); + return HandleRequestResult.Fail("Missing or blank oauth_verifier", properties); } var cookieOptions = Options.StateCookie.Build(Context, Clock.UtcNow); diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs index becdfb5439..6b3598f40a 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs @@ -25,5 +25,10 @@ namespace Microsoft.AspNetCore.Authentication /// User friendly error message for the error. ///
public Exception Failure { get; set; } + + /// + /// Additional state values for the authentication session. + /// + public AuthenticationProperties Properties { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs similarity index 72% rename from src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs rename to src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs index 8bcd2be01d..3f6c2d9177 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs @@ -46,15 +46,33 @@ namespace Microsoft.AspNetCore.Authentication return new HandleRequestResult() { Failure = failure }; } + /// + /// Indicates that there was a failure during authentication. + /// + /// The failure exception. + /// Additional state values for the authentication session. + /// The result. + public static new HandleRequestResult Fail(Exception failure, AuthenticationProperties properties) + { + return new HandleRequestResult() { Failure = failure, Properties = properties }; + } + /// /// Indicates that there was a failure during authentication. /// /// The failure message. /// The result. public static new HandleRequestResult Fail(string failureMessage) - { - return new HandleRequestResult() { Failure = new Exception(failureMessage) }; - } + => Fail(new Exception(failureMessage)); + + /// + /// Indicates that there was a failure during authentication. + /// + /// The failure message. + /// Additional state values for the authentication session. + /// The result. + public static new HandleRequestResult Fail(string failureMessage, AuthenticationProperties properties) + => Fail(new Exception(failureMessage), properties); /// /// Discontinue all processing for this request and return to the client. diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 4051ee6664..bea4895d62 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -49,6 +49,7 @@ namespace Microsoft.AspNetCore.Authentication AuthenticationTicket ticket = null; Exception exception = null; + AuthenticationProperties properties = null; try { var authResult = await HandleRemoteAuthenticateAsync(); @@ -66,8 +67,8 @@ namespace Microsoft.AspNetCore.Authentication } else if (!authResult.Succeeded) { - exception = authResult.Failure ?? - new InvalidOperationException("Invalid return state, unable to redirect."); + exception = authResult.Failure ?? new InvalidOperationException("Invalid return state, unable to redirect."); + properties = authResult.Properties; } ticket = authResult?.Ticket; @@ -80,7 +81,10 @@ namespace Microsoft.AspNetCore.Authentication if (exception != null) { Logger.RemoteAuthenticationError(exception.Message); - var errorContext = new RemoteFailureContext(Context, Scheme, Options, exception); + var errorContext = new RemoteFailureContext(Context, Scheme, Options, exception) + { + Properties = properties + }; await Events.RemoteFailure(errorContext); if (errorContext.Result != null) @@ -95,11 +99,14 @@ namespace Microsoft.AspNetCore.Authentication } else if (errorContext.Result.Failure != null) { - throw new InvalidOperationException("An error was returned from the RemoteFailure event.", errorContext.Result.Failure); + throw new Exception("An error was returned from the RemoteFailure event.", errorContext.Result.Failure); } } - throw exception; + if (errorContext.Failure != null) + { + throw new Exception("An error was encountered while handling the remote login.", errorContext.Failure); + } } // We have a ticket if we get here @@ -107,7 +114,7 @@ namespace Microsoft.AspNetCore.Authentication { ReturnUri = ticket.Properties.RedirectUri }; - // REVIEW: is this safe or good? + ticket.Properties.RedirectUri = null; // Mark which provider produced this identity so we can cross-check later in HandleAuthenticateAsync diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 8f2cc52f91..51bc67cc38 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -253,6 +253,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { o.ClientId = "Test Id"; o.ClientSecret = "Test Secret"; + o.StateDataFormat = new TestStateDataFormat(); o.Events = redirect ? new OAuthEvents() { OnRemoteFailure = ctx => @@ -263,7 +264,8 @@ namespace Microsoft.AspNetCore.Authentication.Google } } : new OAuthEvents(); }); - var sendTask = server.SendAsync("https://example.com/signin-google?error=OMG&error_description=SoBad&error_uri=foobar"); + var sendTask = server.SendAsync("https://example.com/signin-google?error=OMG&error_description=SoBad&error_uri=foobar&state=protected_state", + ".AspNetCore.Correlation.Google.corrilationId=N"); if (redirect) { var transaction = await sendTask; @@ -1075,5 +1077,37 @@ namespace Microsoft.AspNetCore.Authentication.Google }); return new TestServer(builder); } + + private class TestStateDataFormat : ISecureDataFormat + { + private AuthenticationProperties Data { get; set; } + + public string Protect(AuthenticationProperties data) + { + return "protected_state"; + } + + public string Protect(AuthenticationProperties data, string purpose) + { + throw new NotImplementedException(); + } + + public AuthenticationProperties Unprotect(string protectedText) + { + Assert.Equal("protected_state", protectedText); + var properties = new AuthenticationProperties(new Dictionary() + { + { ".xsrf", "corrilationId" }, + { "testkey", "testvalue" } + }); + properties.RedirectUri = "http://testhost/redirect"; + return properties; + } + + public AuthenticationProperties Unprotect(string protectedText, string purpose) + { + throw new NotImplementedException(); + } + } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 30c33eb1d7..81d2360ec7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; @@ -10,6 +11,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.OAuth @@ -20,20 +22,13 @@ namespace Microsoft.AspNetCore.Authentication.OAuth public async Task VerifySignInSchemeCannotBeSetToSelf() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "weeblie"; o.ClientId = "whatever"; o.ClientSecret = "whatever"; - }), - context => - { - // REVIEW: Gross. - context.ChallengeAsync("weeblie").GetAwaiter().GetResult(); - return true; - }); - var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + })); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/")); Assert.Contains("cannot be set to itself", error.Message); } @@ -54,7 +49,6 @@ namespace Microsoft.AspNetCore.Authentication.OAuth public async Task ThrowsIfClientIdMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "whatever"; @@ -62,22 +56,14 @@ namespace Microsoft.AspNetCore.Authentication.OAuth o.ClientSecret = "whatever"; o.TokenEndpoint = "/"; o.AuthorizationEndpoint = "/"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("ClientId", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + })); + await Assert.ThrowsAsync("ClientId", () => server.SendAsync("http://example.com/")); } [Fact] public async Task ThrowsIfClientSecretMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "whatever"; @@ -85,22 +71,14 @@ namespace Microsoft.AspNetCore.Authentication.OAuth o.CallbackPath = "/"; o.TokenEndpoint = "/"; o.AuthorizationEndpoint = "/"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("ClientSecret", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + })); + await Assert.ThrowsAsync("ClientSecret", () => server.SendAsync("http://example.com/")); } [Fact] public async Task ThrowsIfCallbackPathMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; @@ -108,22 +86,14 @@ namespace Microsoft.AspNetCore.Authentication.OAuth o.TokenEndpoint = "/"; o.AuthorizationEndpoint = "/"; o.SignInScheme = "eh"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("CallbackPath", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + })); + await Assert.ThrowsAsync("CallbackPath", () => server.SendAsync("http://example.com/")); } [Fact] public async Task ThrowsIfTokenEndpointMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; @@ -131,22 +101,14 @@ namespace Microsoft.AspNetCore.Authentication.OAuth o.CallbackPath = "/"; o.AuthorizationEndpoint = "/"; o.SignInScheme = "eh"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("TokenEndpoint", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + })); + await Assert.ThrowsAsync("TokenEndpoint", () => server.SendAsync("http://example.com/")); } [Fact] public async Task ThrowsIfAuthorizationEndpointMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; @@ -154,22 +116,14 @@ namespace Microsoft.AspNetCore.Authentication.OAuth o.CallbackPath = "/"; o.TokenEndpoint = "/"; o.SignInScheme = "eh"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("AuthorizationEndpoint", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + })); + await Assert.ThrowsAsync("AuthorizationEndpoint", () => server.SendAsync("http://example.com/")); } [Fact] public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallBackPath() { var server = CreateServer( - app => { }, s => s.AddAuthentication().AddOAuth( "Weblie", opt => @@ -181,9 +135,9 @@ namespace Microsoft.AspNetCore.Authentication.OAuth opt.TokenEndpoint = "https://example.com/provider/token"; opt.CallbackPath = "/oauth-callback"; }), - ctx => + async ctx => { - ctx.ChallengeAsync("Weblie").ConfigureAwait(false).GetAwaiter().GetResult(); + await ctx.ChallengeAsync("Weblie"); return true; }); @@ -201,7 +155,6 @@ namespace Microsoft.AspNetCore.Authentication.OAuth public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOverriden() { var server = CreateServer( - app => { }, s => s.AddAuthentication().AddOAuth( "Weblie", opt => @@ -214,9 +167,9 @@ namespace Microsoft.AspNetCore.Authentication.OAuth opt.CallbackPath = "/oauth-callback"; opt.CorrelationCookie.Path = "/"; }), - ctx => + async ctx => { - ctx.ChallengeAsync("Weblie").ConfigureAwait(false).GetAwaiter().GetResult(); + await ctx.ChallengeAsync("Weblie"); return true; }); @@ -230,15 +183,50 @@ namespace Microsoft.AspNetCore.Authentication.OAuth Assert.Contains("path=/", correlation); } - private static TestServer CreateServer(Action configure, Action configureServices, Func handler) + [Fact] + public async Task RemoteAuthenticationFailed_OAuthError_IncludesProperties() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + opt.ClientId = "Test Id"; + opt.ClientSecret = "secret"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.AuthorizationEndpoint = "https://example.com/provider/login"; + opt.TokenEndpoint = "https://example.com/provider/token"; + opt.CallbackPath = "/oauth-callback"; + opt.StateDataFormat = new TestStateDataFormat(); + opt.Events = new OAuthEvents() + { + OnRemoteFailure = context => + { + Assert.Contains("declined", context.Failure.Message); + Assert.Equal("testvalue", context.Properties.Items["testkey"]); + context.Response.StatusCode = StatusCodes.Status406NotAcceptable; + context.HandleResponse(); + return Task.CompletedTask; + } + }; + })); + + var transaction = await server.SendAsync("https://www.example.com/oauth-callback?error=declined&state=protected_state", + ".AspNetCore.Correlation.Weblie.corrilationId=N"); + + Assert.Equal(HttpStatusCode.NotAcceptable, transaction.Response.StatusCode); + Assert.Null(transaction.Response.Headers.Location); + } + + private static TestServer CreateServer(Action configureServices, Func> handler = null) { var builder = new WebHostBuilder() .Configure(app => { - configure?.Invoke(app); + app.UseAuthentication(); app.Use(async (context, next) => { - if (handler == null || !handler(context)) + if (handler == null || ! await handler(context)) { await next(); } @@ -247,5 +235,37 @@ namespace Microsoft.AspNetCore.Authentication.OAuth .ConfigureServices(configureServices); return new TestServer(builder); } + + private class TestStateDataFormat : ISecureDataFormat + { + private AuthenticationProperties Data { get; set; } + + public string Protect(AuthenticationProperties data) + { + return "protected_state"; + } + + public string Protect(AuthenticationProperties data, string purpose) + { + throw new NotImplementedException(); + } + + public AuthenticationProperties Unprotect(string protectedText) + { + Assert.Equal("protected_state", protectedText); + var properties = new AuthenticationProperties(new Dictionary() + { + { ".xsrf", "corrilationId" }, + { "testkey", "testvalue" } + }); + properties.RedirectUri = "http://testhost/redirect"; + return properties; + } + + public AuthenticationProperties Unprotect(string protectedText, string purpose) + { + throw new NotImplementedException(); + } + } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index f3fc261879..87bdc3f3ca 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -95,7 +95,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect return PostAsync(server, "signin-oidc", ""); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(remoteFailure); @@ -191,7 +191,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(tokenValidated); @@ -348,7 +348,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(tokenValidated); @@ -532,7 +532,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(tokenValidated); @@ -731,7 +731,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect return PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(codeReceived); @@ -943,7 +943,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(tokenValidated); @@ -1186,7 +1186,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(tokenValidated); @@ -1450,6 +1450,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); + Assert.Equal("testvalue", context.Properties.Items["testkey"]); context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); @@ -1877,7 +1878,8 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var properties = new AuthenticationProperties(new Dictionary() { { ".xsrf", "corrilationId" }, - { OpenIdConnectDefaults.RedirectUriForCodePropertiesKey, "redirect_uri" } + { OpenIdConnectDefaults.RedirectUriForCodePropertiesKey, "redirect_uri" }, + { "testkey", "testvalue" } }); properties.RedirectUri = "http://testhost/redirect"; return properties; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 6c661af45c..735cb33146 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; +using System.Linq; using System.Net; using System.Net.Http; using System.Security.Claims; @@ -11,6 +12,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -60,26 +62,12 @@ namespace Microsoft.AspNetCore.Authentication.Twitter }; o.BackchannelHttpHandler = new TestHttpMessageHandler { - Sender = req => - { - if (req.RequestUri.AbsoluteUri == "https://api.twitter.com/oauth/request_token") - { - return new HttpResponseMessage(HttpStatusCode.OK) - { - Content = - new StringContent("oauth_callback_confirmed=true&oauth_token=test_oauth_token&oauth_token_secret=test_oauth_token_secret", - Encoding.UTF8, - "application/x-www-form-urlencoded") - }; - } - return null; - } + Sender = BackchannelRequestToken }; }, - context => + async context => { - // REVIEW: Gross - context.ChallengeAsync("Twitter").GetAwaiter().GetResult(); + await context.ChallengeAsync("Twitter"); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -168,7 +156,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } - [Fact] public async Task ChallengeWillTriggerRedirection() { @@ -178,35 +165,70 @@ namespace Microsoft.AspNetCore.Authentication.Twitter o.ConsumerSecret = "Test Consumer Secret"; o.BackchannelHttpHandler = new TestHttpMessageHandler { - Sender = req => - { - if (req.RequestUri.AbsoluteUri == "https://api.twitter.com/oauth/request_token") - { - return new HttpResponseMessage(HttpStatusCode.OK) - { - Content = - new StringContent("oauth_callback_confirmed=true&oauth_token=test_oauth_token&oauth_token_secret=test_oauth_token_secret", - Encoding.UTF8, - "application/x-www-form-urlencoded") - }; - } - return null; - } + Sender = BackchannelRequestToken }; }, - context => - { - // REVIEW: gross - context.ChallengeAsync("Twitter").GetAwaiter().GetResult(); - return true; - }); + async context => + { + await context.ChallengeAsync("Twitter"); + return true; + }); var transaction = await server.SendAsync("http://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); } - private static TestServer CreateServer(Action options, Func handler = null) + [Fact] + public async Task BadCallbackCallsRemoteAuthFailedWithState() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + o.BackchannelHttpHandler = new TestHttpMessageHandler + { + Sender = BackchannelRequestToken + }; + o.Events = new TwitterEvents() + { + OnRemoteFailure = context => + { + Assert.NotNull(context.Failure); + Assert.NotNull(context.Properties); + Assert.Equal("testvalue", context.Properties.Items["testkey"]); + context.Response.StatusCode = StatusCodes.Status406NotAcceptable; + context.HandleResponse(); + return Task.CompletedTask; + } + }; + }, + async context => + { + var properties = new AuthenticationProperties(); + properties.Items["testkey"] = "testvalue"; + await context.ChallengeAsync("Twitter", properties); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + var location = transaction.Response.Headers.Location.AbsoluteUri; + Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); + Assert.True(transaction.Response.Headers.TryGetValues(HeaderNames.SetCookie, out var setCookie)); + Assert.True(SetCookieHeaderValue.TryParseList(setCookie.ToList(), out var setCookieValues)); + Assert.Single(setCookieValues); + var setCookieValue = setCookieValues.Single(); + var cookie = new CookieHeaderValue(setCookieValue.Name, setCookieValue.Value); + + var request = new HttpRequestMessage(HttpMethod.Get, "/signin-twitter"); + request.Headers.Add(HeaderNames.Cookie, cookie.ToString()); + var client = server.CreateClient(); + var response = await client.SendAsync(request); + + Assert.Equal(HttpStatusCode.NotAcceptable, response.StatusCode); + } + + private static TestServer CreateServer(Action options, Func> handler = null) { var builder = new WebHostBuilder() .Configure(app => @@ -228,7 +250,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { await Assert.ThrowsAsync(() => context.ForbidAsync("Twitter")); } - else if (handler == null || !handler(context)) + else if (handler == null || ! await handler(context)) { await next(); } @@ -247,5 +269,20 @@ namespace Microsoft.AspNetCore.Authentication.Twitter }); return new TestServer(builder); } + + private HttpResponseMessage BackchannelRequestToken(HttpRequestMessage req) + { + if (req.RequestUri.AbsoluteUri == "https://api.twitter.com/oauth/request_token") + { + return new HttpResponseMessage(HttpStatusCode.OK) + { + Content = + new StringContent("oauth_callback_confirmed=true&oauth_token=test_oauth_token&oauth_token_secret=test_oauth_token_secret", + Encoding.UTF8, + "application/x-www-form-urlencoded") + }; + } + throw new NotImplementedException(req.RequestUri.AbsoluteUri); + } } } From 4a6c74f4f9e4bfa8bbfeacf6342230aec3e562c4 Mon Sep 17 00:00:00 2001 From: Gareth Brading Date: Thu, 28 Sep 2017 22:03:52 +0100 Subject: [PATCH 809/900] Added ability to set prompt parameter in OpenIdConnectOptions (#1401) --- .../OpenIdConnectHandler.cs | 1 + .../OpenIdConnectOptions.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 7f65afdcec..0b2419e2ab 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -349,6 +349,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect RedirectUri = BuildRedirectUri(Options.CallbackPath), Resource = Options.Resource, ResponseType = Options.ResponseType, + Prompt = Options.Prompt, Scope = string.Join(" ", Options.Scope) }; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index a8545e35a6..e589a2bc87 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -209,6 +209,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// public string ResponseType { get; set; } = OpenIdConnectResponseType.IdToken; + /// + /// Gets or sets the 'prompt'. + /// + public string Prompt { get; set; } + /// /// Gets the list of permissions to request. /// From 0959c941b40086b131b1e01d304fc23bb887fdc8 Mon Sep 17 00:00:00 2001 From: Josh Coulter Date: Mon, 2 Oct 2017 13:25:46 -0500 Subject: [PATCH 810/900] Cleaned up OAuth handler's exception messages (#1462) --- .../FacebookHandler.cs | 2 +- src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs | 2 +- .../MicrosoftAccountHandler.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index db664e2ee1..0f83c17196 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var response = await Backchannel.GetAsync(endpoint, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - throw new HttpRequestException($"Failed to retrieve Facebook user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Facebook Graph API is enabled."); + throw new HttpRequestException($"An error occurred when retrieving Facebook user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Facebook Graph API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 155691a4ba..091896f7cf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Authentication.Google var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - throw new HttpRequestException($"An error occurred when retrieving user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Google+ API is enabled."); + throw new HttpRequestException($"An error occurred when retrieving Google user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Google+ API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index f4c06300c2..bba5472774 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - throw new HttpRequestException($"Failed to retrived Microsoft user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Microsoft Account API is enabled."); + throw new HttpRequestException($"An error occurred when retrieving Microsoft user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Microsoft Account API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); From 54e4f6834e6fa0f1cf2cc8c2599674ffe017c890 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 5 Oct 2017 15:35:51 -0700 Subject: [PATCH 811/900] Minor test code changes to resolve xUnit2013 build error --- .../CookieChunkingTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs index 143e1d254c..69ead8fa64 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Internal string testString = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; new ChunkingCookieManager() { ChunkSize = null }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); var values = context.Response.Headers["Set-Cookie"]; - Assert.Equal(1, values.Count); + Assert.Single(values); Assert.Equal("TestCookie=" + testString + "; path=/; samesite=lax", values[0]); } From 3e7d1a7fd466623a90e6130b765f63501f6f8762 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 6 Oct 2017 16:09:26 -0700 Subject: [PATCH 812/900] React to updated IdentityModel version --- .../OpenIdConnect/TestSettings.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index bf9df40384..458f746c44 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -249,7 +249,13 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => - ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET", actualParams, errors, htmlEncoded); +#if NETCOREAPP2_0 + ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NETSTANDARD1_4", actualParams, errors, htmlEncoded); +#elif NET461 + ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET451", actualParams, errors, htmlEncoded); +#else +#error Invalid target framework. +#endif private void ValidateVersionTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => ValidateParameter(OpenIdConnectParameterNames.VersionTelemetry, typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualParams, errors, htmlEncoded); From e34a5f8fb8e97b32077e8587261590c3910ad181 Mon Sep 17 00:00:00 2001 From: OpenIDAuthority Date: Wed, 16 Aug 2017 21:13:23 -0700 Subject: [PATCH 813/900] Add MaxAge to OpenIdConnectOptions - max_age parameter added to the authentication request if MaxAge is not null - throws exception if MaxAge is set to a negative value - Fractions of seconds are ignored - See http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest for expected behavior Addresses #1233 --- .../OpenIdConnectHandler.cs | 8 ++++ .../OpenIdConnectOptions.cs | 12 ++++++ .../OpenIdConnectChallengeTests.cs | 41 +++++++++++++++++++ .../OpenIdConnectConfigurationTests.cs | 15 +++++++ .../OpenIdConnect/TestSettings.cs | 19 +++++++++ 5 files changed, 95 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 0b2419e2ab..0f60a558ad 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -353,6 +353,14 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect Scope = string.Join(" ", Options.Scope) }; + // Add the 'max_age' parameter to the authentication request if MaxAge is not null. + // See http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest + if (Options.MaxAge != null) + { + message.MaxAge = Convert.ToInt64(Math.Floor(((TimeSpan)Options.MaxAge).TotalSeconds)) + .ToString(CultureInfo.InvariantCulture); + } + // Omitting the response_mode parameter when it already corresponds to the default // response_mode used for the specified response_type is recommended by the specifications. // See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#ResponseModes diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index e589a2bc87..f6d914731a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -84,6 +84,11 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { base.Validate(); + if (MaxAge != null && MaxAge.Value < TimeSpan.Zero) + { + throw new InvalidOperationException("MaxAge must not be a negative TimeSpan."); + } + if (string.IsNullOrEmpty(ClientId)) { throw new ArgumentException("Options.ClientId must be provided", nameof(ClientId)); @@ -159,6 +164,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect set => base.Events = value; } + /// + /// Gets or sets the 'max_age'. If set the 'max_age' parameter will be sent with the authentication request. If the identity + /// provider has not actively authenticated the user within the length of time specified, the user will be prompted to + /// re-authenticate. By default no max_age is specified. + /// + public TimeSpan? MaxAge { get; set; } = null; + /// /// Gets or sets the that is used to ensure that the 'id_token' received /// is valid per: http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index fb08ae2786..4ff5aa9adb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -409,5 +409,46 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var exception = await Assert.ThrowsAsync(() => server.SendAsync(ChallengeEndpoint)); Assert.Equal("Cannot redirect to the authorization endpoint, the configuration may be missing or invalid.", exception.Message); } + + [Fact] + public async Task Challenge_WithDefaultMaxAge_HasExpectedMaxAgeParam() + { + var settings = new TestSettings( + opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + }); + + var server = settings.CreateTestServer(); + var transaction = await server.SendAsync(ChallengeEndpoint); + + var res = transaction.Response; + + settings.ValidateChallengeRedirect( + res.Headers.Location, + OpenIdConnectParameterNames.MaxAge); + } + + [Fact] + public async Task Challenge_WithSpecificMaxAge_HasExpectedMaxAgeParam() + { + var settings = new TestSettings( + opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.MaxAge = TimeSpan.FromMinutes(20); + }); + + var server = settings.CreateTestServer(); + var transaction = await server.SendAsync(ChallengeEndpoint); + + var res = transaction.Response; + + settings.ValidateChallengeRedirect( + res.Headers.Location, + OpenIdConnectParameterNames.MaxAge); + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index d0d1c26096..871ef9d08b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -115,6 +115,21 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect ); } + [Fact] + public Task ThrowsWhenMaxAgeIsNegative() + { + return TestConfigurationException( + o => + { + o.SignInScheme = "TestScheme"; + o.ClientId = "Test Id"; + o.Authority = TestServerBuilder.DefaultAuthority; + o.MaxAge = TimeSpan.FromSeconds(-1); + }, + ex => Assert.Equal("MaxAge must not be a negative TimeSpan.", ex.Message) + ); + } + private TestServer BuildTestServer(Action options) { var builder = new WebHostBuilder() diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 458f746c44..5b4ea23482 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -4,12 +4,14 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.Linq; using System.Reflection; using System.Text; using System.Text.Encodings.Web; using System.Xml.Linq; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.TestHost; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; @@ -197,6 +199,9 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect case OpenIdConnectParameterNames.PostLogoutRedirectUri: ValidatePostLogoutRedirectUri(actualValues, errors, htmlEncoded); break; + case OpenIdConnectParameterNames.MaxAge: + ValidateMaxAge(actualValues, errors, htmlEncoded); + break; default: throw new InvalidOperationException($"Unknown parameter \"{paramToValidate}\"."); } @@ -263,6 +268,20 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect private void ValidatePostLogoutRedirectUri(IDictionary actualParams, ICollection errors, bool htmlEncoded) => ValidateParameter(OpenIdConnectParameterNames.PostLogoutRedirectUri, "https://example.com/signout-callback-oidc", actualParams, errors, htmlEncoded); + private void ValidateMaxAge(IDictionary actualQuery, ICollection errors, bool htmlEncoded) + { + if(_options.MaxAge != null) + { + string expectedMaxAge = Convert.ToInt64(Math.Floor(((TimeSpan)_options.MaxAge).TotalSeconds)) + .ToString(CultureInfo.InvariantCulture); + ValidateParameter(OpenIdConnectParameterNames.MaxAge, expectedMaxAge, actualQuery, errors, htmlEncoded); + } + else if(actualQuery.ContainsKey(OpenIdConnectParameterNames.MaxAge)) + { + errors.Add($"Parameter {OpenIdConnectParameterNames.MaxAge} is present but it should be absent"); + } + } + private void ValidateParameter( string parameterName, string expectedValue, From 0904af8ff3c4f76f0d65bbec5a17ac40ac6a1f5b Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 9 Oct 2017 09:53:21 -0700 Subject: [PATCH 814/900] PR style cleanup --- .../OpenIdConnectHandler.cs | 4 ++-- .../OpenIdConnectOptions.cs | 6 +++--- .../OpenIdConnect/OpenIdConnectChallengeTests.cs | 8 ++++---- .../OpenIdConnect/OpenIdConnectConfigurationTests.cs | 4 ++-- .../OpenIdConnect/TestSettings.cs | 8 +++----- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 0f60a558ad..330d064c03 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -355,9 +355,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // Add the 'max_age' parameter to the authentication request if MaxAge is not null. // See http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest - if (Options.MaxAge != null) + if (Options.MaxAge.HasValue) { - message.MaxAge = Convert.ToInt64(Math.Floor(((TimeSpan)Options.MaxAge).TotalSeconds)) + message.MaxAge = Convert.ToInt64(Math.Floor((Options.MaxAge.Value).TotalSeconds)) .ToString(CultureInfo.InvariantCulture); } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index f6d914731a..a40d374356 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -84,9 +84,9 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { base.Validate(); - if (MaxAge != null && MaxAge.Value < TimeSpan.Zero) + if (MaxAge.HasValue && MaxAge.Value < TimeSpan.Zero) { - throw new InvalidOperationException("MaxAge must not be a negative TimeSpan."); + throw new ArgumentOutOfRangeException(nameof(MaxAge), MaxAge.Value, "The value must not be a negative TimeSpan."); } if (string.IsNullOrEmpty(ClientId)) @@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// provider has not actively authenticated the user within the length of time specified, the user will be prompted to /// re-authenticate. By default no max_age is specified. /// - public TimeSpan? MaxAge { get; set; } = null; + public TimeSpan? MaxAge { get; set; } /// /// Gets or sets the that is used to ensure that the 'id_token' received diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index 4ff5aa9adb..7ab81c9dd4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -414,8 +414,8 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect public async Task Challenge_WithDefaultMaxAge_HasExpectedMaxAgeParam() { var settings = new TestSettings( - opt => - { + opt => + { opt.ClientId = "Test Id"; opt.Authority = TestServerBuilder.DefaultAuthority; }); @@ -434,8 +434,8 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect public async Task Challenge_WithSpecificMaxAge_HasExpectedMaxAgeParam() { var settings = new TestSettings( - opt => - { + opt => + { opt.ClientId = "Test Id"; opt.Authority = TestServerBuilder.DefaultAuthority; opt.MaxAge = TimeSpan.FromMinutes(20); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 871ef9d08b..69ba758292 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -118,7 +118,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect [Fact] public Task ThrowsWhenMaxAgeIsNegative() { - return TestConfigurationException( + return TestConfigurationException( o => { o.SignInScheme = "TestScheme"; @@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect o.Authority = TestServerBuilder.DefaultAuthority; o.MaxAge = TimeSpan.FromSeconds(-1); }, - ex => Assert.Equal("MaxAge must not be a negative TimeSpan.", ex.Message) + ex => Assert.StartsWith("The value must not be a negative TimeSpan.", ex.Message) ); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 5b4ea23482..f174342aed 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -4,14 +4,12 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Globalization; using System.Linq; using System.Reflection; using System.Text; using System.Text.Encodings.Web; using System.Xml.Linq; using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.TestHost; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; @@ -270,10 +268,10 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect private void ValidateMaxAge(IDictionary actualQuery, ICollection errors, bool htmlEncoded) { - if(_options.MaxAge != null) + if(_options.MaxAge.HasValue) { - string expectedMaxAge = Convert.ToInt64(Math.Floor(((TimeSpan)_options.MaxAge).TotalSeconds)) - .ToString(CultureInfo.InvariantCulture); + Assert.Equal(TimeSpan.FromMinutes(20), _options.MaxAge.Value); + string expectedMaxAge = "1200"; ValidateParameter(OpenIdConnectParameterNames.MaxAge, expectedMaxAge, actualQuery, errors, htmlEncoded); } else if(actualQuery.ContainsKey(OpenIdConnectParameterNames.MaxAge)) From e0ad6ed6b9abbb73e3ca68c6abdf2a0126defec1 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 20 Sep 2017 13:23:33 -0700 Subject: [PATCH 815/900] Update bootstrappers --- .appveyor.yml | 4 +- build.cmd | 2 +- build.sh | 197 +------------------------------------- run.cmd | 2 + build.ps1 => run.ps1 | 56 +++++++---- run.sh | 223 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 266 insertions(+), 218 deletions(-) create mode 100644 run.cmd rename build.ps1 => run.ps1 (73%) create mode 100755 run.sh diff --git a/.appveyor.yml b/.appveyor.yml index 4f85bae466..c7b6e34316 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,4 +1,4 @@ -init: +init: - git config --global core.autocrlf true branches: only: @@ -8,7 +8,7 @@ branches: - /^(.*\/)?ci-.*$/ - /^rel\/.*/ build_script: - - ps: .\build.ps1 + - ps: .\run.ps1 default-build clone_depth: 1 environment: global: diff --git a/build.cmd b/build.cmd index b6c8d24864..c0050bda12 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh index 11cdbe5504..98a4b22765 100755 --- a/build.sh +++ b/build.sh @@ -1,199 +1,8 @@ #!/usr/bin/env bash set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -MAGENTA="\033[0;95m" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -config_file="$DIR/version.xml" -verbose=false -update=false -repo_path="$DIR" -channel='' -tools_source='' -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file TThe path to the configuration file that stores values. Defaults to version.xml." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source The base url where build tools can be downloaded. Overrides the value from the config file." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo "" - echo "Description:" - echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}$*${RESET}" 1>&2 -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;} - -# -# main -# - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -if [ -f "$config_file" ]; then - comment=false - while __read_dom; do - if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi - if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi - if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi - if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi - done < "$config_file" -fi - -[ -z "$channel" ] && channel='dev' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' - -get_korebuild -install_tools "$tools_source" "$DOTNET_HOME" -invoke_repository_build "$repo_path" "$@" +# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) +chmod +x "$DIR/run.sh"; sync +"$DIR/run.sh" default-build "$@" diff --git a/run.cmd b/run.cmd new file mode 100644 index 0000000000..d52d5c7e68 --- /dev/null +++ b/run.cmd @@ -0,0 +1,2 @@ +@ECHO OFF +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/build.ps1 b/run.ps1 similarity index 73% rename from build.ps1 rename to run.ps1 index d5eb4d5cf2..49c2899856 100644 --- a/build.ps1 +++ b/run.ps1 @@ -3,10 +3,13 @@ <# .SYNOPSIS -Build this repository +Executes KoreBuild commands. .DESCRIPTION -Downloads korebuild if required. Then builds the repository. +Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. + +.PARAMETER Command +The KoreBuild command to run. .PARAMETER Path The folder to build. Defaults to the folder containing this script. @@ -24,31 +27,32 @@ The base url where build tools can be downloaded. Overrides the value from the c Updates KoreBuild to the latest version even if a lock file is present. .PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to version.xml. +The path to the configuration file that stores values. Defaults to korebuild.json. -.PARAMETER MSBuildArgs -Arguments to be passed to MSBuild +.PARAMETER Arguments +Arguments to be passed to the command .NOTES This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. -The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well. +The $ConfigFile is expected to be an JSON file. It is optional, and the configuration values in it are optional as well. Any options set +in the file are overridden by command line parameters. .EXAMPLE Example config file: -```xml - - - - dev - https://aspnetcore.blob.core.windows.net/buildtools - - +```json +{ + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", + "channel": "dev", + "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" +} ``` #> [CmdletBinding(PositionalBinding = $false)] param( + [Parameter(Mandatory=$true, Position = 0)] + [string]$Command, [string]$Path = $PSScriptRoot, [Alias('c')] [string]$Channel, @@ -58,9 +62,9 @@ param( [string]$ToolsSource, [Alias('u')] [switch]$Update, - [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'), + [string]$ConfigFile, [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$MSBuildArgs + [string[]]$Arguments ) Set-StrictMode -Version 2 @@ -147,10 +151,20 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { # Load configuration or set defaults +$Path = Resolve-Path $Path +if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } + if (Test-Path $ConfigFile) { - [xml] $config = Get-Content $ConfigFile - if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' } - if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' } + try { + $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json + if ($config) { + if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } + if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} + } + } catch { + Write-Warning "$ConfigFile could not be read. Its settings will be ignored." + Write-Warning $Error[0] + } } if (!$DotNetHome) { @@ -169,8 +183,8 @@ $korebuildPath = Get-KoreBuild Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') try { - Install-Tools $ToolsSource $DotNetHome - Invoke-RepositoryBuild $Path @MSBuildArgs + Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile + Invoke-KoreBuildCommand $Command @Arguments } finally { Remove-Module 'KoreBuild' -ErrorAction Ignore diff --git a/run.sh b/run.sh new file mode 100755 index 0000000000..c278423acc --- /dev/null +++ b/run.sh @@ -0,0 +1,223 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# +# variables +# + +RESET="\033[0m" +RED="\033[0;31m" +YELLOW="\033[0;33m" +MAGENTA="\033[0;95m" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" +verbose=false +update=false +repo_path="$DIR" +channel='' +tools_source='' + +# +# Functions +# +__usage() { + echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" + echo "" + echo "Arguments:" + echo " command The command to be run." + echo " ... Arguments passed to the command. Variable number of arguments allowed." + echo "" + echo "Options:" + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo "" + echo "Description:" + echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." + echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." + + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 + fi +} + +get_korebuild() { + local version + local lock_file="$repo_path/korebuild-lock.txt" + if [ ! -f "$lock_file" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + fi + version="$(grep 'version:*' -m 1 "$lock_file")" + if [[ "$version" == '' ]]; then + __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + return 1 + fi + version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + + { + if [ ! -d "$korebuild_path" ]; then + mkdir -p "$korebuild_path" + local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" + tmpfile="$(mktemp)" + echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" + if __get_remote_file "$remote_path" "$tmpfile"; then + unzip -q -d "$korebuild_path" "$tmpfile" + fi + rm "$tmpfile" || true + fi + + source "$korebuild_path/KoreBuild.sh" + } || { + if [ -d "$korebuild_path" ]; then + echo "Cleaning up after failed installation" + rm -rf "$korebuild_path" || true + fi + return 1 + } +} + +__error() { + echo -e "${RED}error: $*${RESET}" 1>&2 +} + +__warn() { + echo -e "${YELLOW}warning: $*${RESET}" +} + +__machine_has() { + hash "$1" > /dev/null 2>&1 + return $? +} + +__get_remote_file() { + local remote_path=$1 + local local_path=$2 + + if [[ "$remote_path" != 'http'* ]]; then + cp "$remote_path" "$local_path" + return 0 + fi + + local failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + else + failed=true + fi + + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + fi + + if [ "$failed" = true ]; then + __error "Download failed: $remote_path" 1>&2 + return 1 + fi +} + +# +# main +# + +command="${1:-}" +shift + +while [[ $# -gt 0 ]]; do + case $1 in + -\?|-h|--help) + __usage --no-exit + exit 0 + ;; + -c|--channel|-Channel) + shift + channel="${1:-}" + [ -z "$channel" ] && __usage + ;; + --config-file|-ConfigFile) + shift + config_file="${1:-}" + [ -z "$config_file" ] && __usage + if [ ! -f "$config_file" ]; then + __error "Invalid value for --config-file. $config_file does not exist." + exit 1 + fi + ;; + -d|--dotnet-home|-DotNetHome) + shift + DOTNET_HOME="${1:-}" + [ -z "$DOTNET_HOME" ] && __usage + ;; + --path|-Path) + shift + repo_path="${1:-}" + [ -z "$repo_path" ] && __usage + ;; + -s|--tools-source|-ToolsSource) + shift + tools_source="${1:-}" + [ -z "$tools_source" ] && __usage + ;; + -u|--update|-Update) + update=true + ;; + --verbose|-Verbose) + verbose=true + ;; + --) + shift + break + ;; + *) + break + ;; + esac + shift +done + +if ! __machine_has unzip; then + __error 'Missing required command: unzip' + exit 1 +fi + +if ! __machine_has curl && ! __machine_has wget; then + __error 'Missing required command. Either wget or curl is required.' + exit 1 +fi + +[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" +if [ -f "$config_file" ]; then + if __machine_has jq ; then + if jq '.' "$config_file" >/dev/null ; then + config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" + config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" + else + __warn "$config_file is invalid JSON. Its settings will be ignored." + fi + elif __machine_has python ; then + if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then + config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" + config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" + else + __warn "$config_file is invalid JSON. Its settings will be ignored." + fi + else + __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' + fi + + [ ! -z "${config_channel:-}" ] && channel="$config_channel" + [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" +fi + +[ -z "$channel" ] && channel='dev' +[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' + +get_korebuild +set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" +invoke_korebuild_command "$command" "$@" From 02cd997e3258a4e928a2cf1cf28f7ccae66ec635 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 10 Oct 2017 13:51:07 -0700 Subject: [PATCH 816/900] Add Validate(scheme) and use for RemoteSignInScheme not self validation --- .../AuthenticationBuilder.cs | 4 ---- .../AuthenticationHandler.cs | 2 +- .../AuthenticationSchemeOptions.cs | 11 ++++++++--- .../RemoteAuthenticationOptions.cs | 13 +++++++++++++ .../FacebookTests.cs | 16 +++++++++++++--- .../OAuthTests.cs | 3 +++ 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs index 54b4818851..3bce55ea10 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -97,10 +97,6 @@ namespace Microsoft.AspNetCore.Authentication public void PostConfigure(string name, TOptions options) { options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme ?? _authOptions.DefaultScheme; - if (string.Equals(options.SignInScheme, name, StringComparison.Ordinal)) - { - throw new InvalidOperationException(Resources.Exception_RemoteSignInSchemeCannotBeSelf); - } } } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 812ba2f1a8..9728e5ff05 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.Authentication Context = context; Options = OptionsMonitor.Get(Scheme.Name) ?? new TOptions(); - Options.Validate(); + Options.Validate(Scheme.Name); await InitializeEventsAsync(); await InitializeHandlerAsync(); diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs index 0e86b3a9ff..18d4c97881 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -13,9 +13,14 @@ namespace Microsoft.AspNetCore.Authentication /// /// Check that the options are valid. Should throw an exception if things are not ok. /// - public virtual void Validate() - { - } + public virtual void Validate() { } + + /// + /// Checks that the options are valid for a specific scheme + /// + /// The scheme being validated. + public virtual void Validate(string scheme) + => Validate(); /// /// Gets or sets the issuer that should be used for any claims that are created diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 3b34cf43e9..daba1890fb 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -32,6 +32,19 @@ namespace Microsoft.AspNetCore.Authentication }; } + /// + /// Checks that the options are valid for a specific scheme + /// + /// The scheme being validated. + public override void Validate(string scheme) + { + base.Validate(scheme); + if (string.Equals(scheme, SignInScheme, StringComparison.Ordinal)) + { + throw new InvalidOperationException(Resources.Exception_RemoteSignInSchemeCannotBeSelf); + } + } + /// /// Check that the options are valid. Should throw an exception if things are not ok. /// diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 81373403bd..2314b6b3c9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -29,7 +29,11 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { var server = CreateServer( app => { }, - services => services.AddAuthentication().AddFacebook(o => o.SignInScheme = FacebookDefaults.AuthenticationScheme), + services => services.AddAuthentication().AddFacebook(o => { + o.AppId = "whatever"; + o.AppSecret = "whatever"; + o.SignInScheme = FacebookDefaults.AuthenticationScheme; + }), context => { // Gross @@ -45,7 +49,10 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { var server = CreateServer( app => { }, - services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(), + services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => { + o.AppId = "whatever"; + o.AppSecret = "whatever"; + }), context => { // Gross @@ -61,7 +68,10 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { var server = CreateServer( app => { }, - services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(), + services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => { + o.AppId = "whatever"; + o.AppSecret = "whatever"; + }), context => { // Gross diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 81d2360ec7..65d865b941 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -27,6 +27,9 @@ namespace Microsoft.AspNetCore.Authentication.OAuth o.SignInScheme = "weeblie"; o.ClientId = "whatever"; o.ClientSecret = "whatever"; + o.CallbackPath = "/whatever"; + o.AuthorizationEndpoint = "/whatever"; + o.TokenEndpoint = "/whatever"; })); var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/")); Assert.Contains("cannot be set to itself", error.Message); From bd07f8b683ce793490d108b2310fa6112953d172 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 11 Oct 2017 12:40:15 -0700 Subject: [PATCH 817/900] #1353 use a compliant Expires header value for expiration. --- .../CookieAuthenticationHandler.cs | 4 ++-- .../OpenIdConnectHandler.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 754c91f1e8..5d0afba46b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies IAuthenticationSignOutHandler { private const string HeaderValueNoCache = "no-cache"; - private const string HeaderValueMinusOne = "-1"; + private const string HeaderValueEpocDate = "Thu, 01 Jan 1970 00:00:00 GMT"; private const string SessionIdClaim = "Microsoft.AspNetCore.Authentication.Cookies-SessionId"; private bool _shouldRefresh; @@ -359,7 +359,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { Response.Headers[HeaderNames.CacheControl] = HeaderValueNoCache; Response.Headers[HeaderNames.Pragma] = HeaderValueNoCache; - Response.Headers[HeaderNames.Expires] = HeaderValueMinusOne; + Response.Headers[HeaderNames.Expires] = HeaderValueEpocDate; if (shouldRedirectToReturnUrl && Response.StatusCode == 200) { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 330d064c03..7981cafd18 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -32,6 +32,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect private const string NonceProperty = "N"; private const string UriSchemeDelimiter = "://"; + private const string HeaderValueEpocDate = "Thu, 01 Jan 1970 00:00:00 GMT"; private const string InputTagFormat = @""; private const string HtmlFormFormat = @" @@ -261,7 +262,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // Emit Cache-Control=no-cache to prevent client caching. Response.Headers[HeaderNames.CacheControl] = "no-cache"; Response.Headers[HeaderNames.Pragma] = "no-cache"; - Response.Headers[HeaderNames.Expires] = "-1"; + Response.Headers[HeaderNames.Expires] = HeaderValueEpocDate; await Response.Body.WriteAsync(buffer, 0, buffer.Length); } @@ -442,7 +443,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect // Emit Cache-Control=no-cache to prevent client caching. Response.Headers[HeaderNames.CacheControl] = "no-cache"; Response.Headers[HeaderNames.Pragma] = "no-cache"; - Response.Headers[HeaderNames.Expires] = "-1"; + Response.Headers[HeaderNames.Expires] = HeaderValueEpocDate; await Response.Body.WriteAsync(buffer, 0, buffer.Length); return; From 824539f47ac7f57a824092b04795e25198e1438f Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 11 Oct 2017 16:10:24 -0700 Subject: [PATCH 818/900] #1349 Don't throw for partial cookies --- .../ChunkingCookieManager.cs | 1 - src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs | 1 - .../CookieChunkingTests.cs | 3 ++- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs index 9b602383cf..7217e70d4f 100644 --- a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs +++ b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -44,7 +44,6 @@ namespace Microsoft.AspNetCore.Internal // See http://browsercookielimits.x64.me/. // Leave at least 40 in case CookiePolicy tries to add 'secure', 'samesite=strict' and/or 'httponly'. ChunkSize = DefaultChunkSize; - ThrowForPartialCookies = true; } /// diff --git a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs index b323258d9b..1ae4f00cdb 100644 --- a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs +++ b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs @@ -25,7 +25,6 @@ namespace Microsoft.Owin.Security.Interop // See http://browsercookielimits.x64.me/. // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. ChunkSize = 4070; - ThrowForPartialCookies = true; } /// diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs index 69ead8fa64..e645745b35 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs @@ -81,7 +81,8 @@ namespace Microsoft.AspNetCore.Internal "TestCookieC7=STUVWXYZ" }; - Assert.Throws(() => new ChunkingCookieManager().GetRequestCookie(context, "TestCookie")); + Assert.Throws(() => new ChunkingCookieManager() { ThrowForPartialCookies = true } + .GetRequestCookie(context, "TestCookie")); } [Fact] From a2a86ffc782d94ac3e54b66d3889b2d4259b3989 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Oct 2017 12:52:41 -0700 Subject: [PATCH 819/900] Add RepositoryRoot --- Directory.Build.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2490e42443..61b629ccce 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,10 +1,11 @@ - + Microsoft ASP.NET Core https://github.com/aspnet/Security git + $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true true From 794e9c79fd15ccd550737c6ee41dc96722a303f2 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 19 Oct 2017 12:38:15 -0700 Subject: [PATCH 820/900] Update cookie doc comments --- .../CookieAuthenticationOptions.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 0f2dbd3124..04c71ed1ef 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -80,11 +80,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies public bool SlidingExpiration { get; set; } /// - /// The LoginPath property informs the handler that it should change an outgoing 401 Unauthorized status - /// code into a 302 redirection onto the given login path. The current url which generated the 401 is added - /// to the LoginPath as a query string parameter named by the ReturnUrlParameter. Once a request to the - /// LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect the browser back - /// to the url which caused the original unauthorized status code. + /// The LoginPath property is used by the handler for the redirection target when handling ChallengeAsync. + /// The current url which is added to the LoginPath as a query string parameter named by the ReturnUrlParameter. + /// Once a request to the LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect + /// the browser back to the original url. /// public PathString LoginPath { get; set; } @@ -94,16 +93,14 @@ namespace Microsoft.AspNetCore.Authentication.Cookies public PathString LogoutPath { get; set; } /// - /// The AccessDeniedPath property informs the handler that it should change an outgoing 403 Forbidden status - /// code into a 302 redirection onto the given path. + /// The AccessDeniedPath property is used by the handler for the redirection target when handling ForbidAsync. /// public PathString AccessDeniedPath { get; set; } /// /// The ReturnUrlParameter determines the name of the query string parameter which is appended by the handler - /// when a 401 Unauthorized status code is changed to a 302 redirect onto the login path. This is also the query - /// string parameter looked for when a request arrives on the login path or logout path, in order to return to the - /// original url after the action is performed. + /// when during a Challenge. This is also the query string parameter looked for when a request arrives on the + /// login path or logout path, in order to return to the original url after the action is performed. /// public string ReturnUrlParameter { get; set; } From 88cb3df0ebdd524a8c56e74b740296941947fdff Mon Sep 17 00:00:00 2001 From: tstojecki Date: Tue, 31 Oct 2017 17:27:07 +0100 Subject: [PATCH 821/900] Added support for multiple values (arrays) in default claim action (#1501) * Added support for multiple values (arrays) in default claim action * Added tests to claim action update to support array values --- .../Claims/JsonKeyClaimAction.cs | 17 +++++- .../ClaimActionTests.cs | 55 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs index e628904de5..ccd1a965dc 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs @@ -32,7 +32,22 @@ namespace Microsoft.AspNetCore.Authentication.OAuth.Claims /// public override void Run(JObject userData, ClaimsIdentity identity, string issuer) { - var value = userData?.Value(JsonKey); + var value = userData?[JsonKey]; + if (value is JValue) + { + AddClaim(value?.ToString(), identity, issuer); + } + else if (value is JArray) + { + foreach (var v in value) + { + AddClaim(v?.ToString(), identity, issuer); + } + } + } + + private void AddClaim(string value, ClaimsIdentity identity, string issuer) + { if (!string.IsNullOrEmpty(value)) { identity.AddClaim(new Claim(ClaimType, value, ValueType, issuer)); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs new file mode 100644 index 0000000000..541e1edf28 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs @@ -0,0 +1,55 @@ +// 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.IO; +using System.Linq; +using System.Security.Claims; +using Microsoft.AspNetCore.Testing.xunit; +using Xunit; +using Microsoft.AspNetCore.Authentication.OAuth.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication +{ + public class ClaimActionTests + { + [Fact] + public void CanMapSingleValueUserDataToClaim() + { + var userData = new JObject + { + ["name"] = "test" + }; + + var identity = new ClaimsIdentity(); + + var action = new JsonKeyClaimAction("name", "name", "name"); + action.Run(userData, identity, "iss"); + + Assert.Equal("name", identity.FindFirst("name").Type); + Assert.Equal("test", identity.FindFirst("name").Value); + } + + [Fact] + public void CanMapArrayValueUserDataToClaims() + { + var userData = new JObject + { + ["role"] = new JArray { "role1", "role2" } + }; + + var identity = new ClaimsIdentity(); + + var action = new JsonKeyClaimAction("role", "role", "role"); + action.Run(userData, identity, "iss"); + + var roleClaims = identity.FindAll("role").ToList(); + Assert.Equal(2, roleClaims.Count); + Assert.Equal("role", roleClaims[0].Type); + Assert.Equal("role1", roleClaims[0].Value); + Assert.Equal("role", roleClaims[1].Type); + Assert.Equal("role2", roleClaims[1].Value); + } + } +} From 00c92101575c7c035efe4a23a4d9eeda43afd41d Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 26 Oct 2017 11:56:16 -0700 Subject: [PATCH 822/900] Refactor OIDC event tests --- .../OpenIdConnect/OpenIdConnectEventTests.cs | 1972 ++++++----------- 1 file changed, 684 insertions(+), 1288 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index 87bdc3f3ca..7530b00c31 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -28,67 +28,44 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { public class OpenIdConnectEventTests { - private readonly Func MessageNotImpl = context => { throw new NotImplementedException("Message"); }; - private readonly Func TokenNotImpl = context => { throw new NotImplementedException("Token"); }; - private readonly Func CodeNotImpl = context => { throw new NotImplementedException("Code"); }; - private readonly Func TokenResponseNotImpl = context => { throw new NotImplementedException("TokenResponse"); }; - private readonly Func UserNotImpl = context => { throw new NotImplementedException("User"); }; - private readonly Func FailedNotImpl = context => { throw new NotImplementedException("Failed", context.Exception); }; - private readonly Func TicketNotImpl = context => { throw new NotImplementedException("Ticket"); }; - private readonly Func FailureNotImpl = context => { throw new NotImplementedException("Failure", context.Failure); }; - private readonly Func RedirectNotImpl = context => { throw new NotImplementedException("Redirect"); }; - private readonly Func RemoteSignOutNotImpl = context => { throw new NotImplementedException("Remote"); }; - private readonly Func SignedOutCallbackNotImpl = context => { throw new NotImplementedException("SingedOut"); }; + private readonly RequestDelegate AppWritePath = context => context.Response.WriteAsync(context.Request.Path); private readonly RequestDelegate AppNotImpl = context => { throw new NotImplementedException("App"); }; [Fact] public async Task OnMessageReceived_Skip_NoMoreEventsRun() { - var messageReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + }; + events.OnMessageReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", ""); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); + events.ValidateExpectations(); } [Fact] public async Task OnMessageReceived_Fail_NoMoreEventsRun() { - var messageReceived = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectRemoteFailure = true, + }; + events.OnMessageReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -96,95 +73,68 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnMessageReceived_Handled_NoMoreEventsRun() { - var messageReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + }; + events.OnMessageReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", ""); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidated_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + }; + events.OnTokenValidated = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidated_Fail_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectRemoteFailure = true, + }; + events.OnTokenValidated = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -192,156 +142,108 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidated_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.HandleResponse(); - context.Principal = null; - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + }; + events.OnTokenValidated = context => + { + context.HandleResponse(); + context.Principal = null; + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); + events.ValidateExpectations(); } - // TODO: Do any other events depend on the presence of the ticket? It's strange we have to double handle this event. [Fact] public async Task OnTokenValidated_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var tokenValidated = false; - var ticketReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectTicketReceived = true, + }; + events.OnTokenValidated = context => + { + context.HandleResponse(); + context.Principal = null; + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + events.OnTokenValidated = context => + { + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + }; + events.OnAuthorizationCodeReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); + events.ValidateExpectations(); } [Fact] public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectRemoteFailure = true, + }; + events.OnAuthorizationCodeReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -349,183 +251,105 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnAuthorizationCodeReceived_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - context.HandleResponse(); - context.Principal = null; - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + }; + events.OnAuthorizationCodeReceived = context => + { + context.HandleResponse(); + context.Principal = null; + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); + events.ValidateExpectations(); } [Fact] public async Task OnAuthorizationCodeReceived_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var ticketReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTicketReceived = true, + }; + events.OnAuthorizationCodeReceived = context => + { + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + }; + events.OnTokenResponseReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectRemoteFailure = true, + }; + events.OnTokenResponseReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -533,198 +357,107 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnTokenResponseReceived_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - context.Principal = null; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + }; + events.OnTokenResponseReceived = context => + { + context.Principal = null; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTokenResponseReceived_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var ticketReceived = false; - var tokenResponseReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectTicketReceived = true, + }; + events.OnTokenResponseReceived = context => + { + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() { - var messageReceived = false; - var codeReceived = false; - var tokenResponseReceived = false; - var tokenValidated = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + }; + events.OnTokenValidated = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(tokenValidated); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() { - var messageReceived = false; - var codeReceived = false; - var tokenResponseReceived = false; - var tokenValidated = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectRemoteFailure = true, + }; + events.OnTokenValidated = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -732,211 +465,109 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(tokenValidated); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidatedBackchannel_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var codeReceived = false; - var tokenResponseReceived = false; - var tokenValidated = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.Principal = null; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + }; + events.OnTokenValidated = context => + { + context.Principal = null; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(tokenValidated); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidatedBackchannel_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var codeReceived = false; - var ticketReceived = false; - var tokenResponseReceived = false; - var tokenValidated = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectTicketReceived = true, + }; + events.OnTokenValidated = context => + { + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(tokenValidated); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + }; + events.OnUserInformationReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); + events.ValidateExpectations(); } [Fact] public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectRemoteFailure = true, + }; + events.OnUserInformationReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -944,242 +575,123 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnUserInformationReceived_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - context.Principal = null; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + }; + events.OnUserInformationReceived = context => + { + context.Principal = null; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); + events.ValidateExpectations(); } [Fact] public async Task OnUserInformationReceived_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var ticketReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - // context.Ticket = null; - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectTicketReceived = true, + }; + events.OnUserInformationReceived = context => + { + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + }; + events.OnUserInformationReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + throw new NotImplementedException("TestException"); + }; + events.OnAuthenticationFailed = context => + { + Assert.Equal("TestException", context.Exception.Message); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); + events.ValidateExpectations(); } [Fact] public async Task OnAuthenticationFailed_Fail_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + ExpectRemoteFailure = true, + }; + events.OnUserInformationReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + throw new NotImplementedException("TestException"); + }; + events.OnAuthenticationFailed = context => + { + Assert.Equal("TestException", context.Exception.Message); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -1187,420 +699,222 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - Assert.Null(context.Principal); - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + }; + events.OnUserInformationReceived = context => + { + throw new NotImplementedException("TestException"); + }; + events.OnAuthenticationFailed = context => + { + Assert.Equal("TestException", context.Exception.Message); + Assert.Null(context.Principal); + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); + events.ValidateExpectations(); } [Fact] public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var ticketReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - Assert.Null(context.Principal); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + ExpectTicketReceived = true, + }; + events.OnUserInformationReceived = context => + { + throw new NotImplementedException("TestException"); + }; + events.OnAuthenticationFailed = context => + { + Assert.Equal("TestException", context.Exception.Message); + Assert.Null(context.Principal); - var claims = new[] - { - new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), - new Claim(ClaimTypes.Email, "bob@contoso.com"), - new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") - }; - - context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => + var claims = new[] { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); + new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), + new Claim(ClaimTypes.Email, "bob@contoso.com"), + new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - }), - AppNotImpl); + + context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnRemoteFailure_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - Assert.Equal("TestException", context.Failure.Message); - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + ExpectRemoteFailure = true, + }; + events.OnUserInformationReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + throw new NotImplementedException("TestException"); + }; + events.OnAuthenticationFailed = context => + { + Assert.Equal("TestException", context.Exception.Message); + return Task.FromResult(0); + }; + events.OnRemoteFailure = context => + { + Assert.Equal("TestException", context.Failure.Message); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnRemoteFailure_Handled_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - Assert.Equal("TestException", context.Failure.Message); - Assert.Equal("testvalue", context.Properties.Items["testkey"]); - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + ExpectRemoteFailure = true, + }; + events.OnUserInformationReceived = context => + { + throw new NotImplementedException("TestException"); + }; + events.OnRemoteFailure = context => + { + Assert.Equal("TestException", context.Failure.Message); + Assert.Equal("testvalue", context.Properties.Items["testkey"]); + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnTicketReceived_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var ticektReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticektReceived = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectTicketReceived = true, + }; + events.OnTicketReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(ticektReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTicketReceived_Handled_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var ticektReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticektReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectTicketReceived = true, + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(ticektReceived); + events.ValidateExpectations(); } [Fact] public async Task OnRedirectToIdentityProviderForSignOut_Invoked() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnRedirectToIdentityProviderForSignOut = context => - { - forSignOut = true; - return Task.CompletedTask; - }; - }), + ExpectRedirectForSignOut = true, + }; + var server = CreateServer(events, context => { return context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); @@ -1611,23 +925,23 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.Equal(HttpStatusCode.Found, response.StatusCode); Assert.Equal("http://testhost/end", response.Headers.Location.GetLeftPart(UriPartial.Path)); - Assert.True(forSignOut); + events.ValidateExpectations(); } [Fact] public async Task OnRedirectToIdentityProviderForSignOut_Handled_RedirectNotInvoked() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnRedirectToIdentityProviderForSignOut = context => - { - forSignOut = true; - context.Response.StatusCode = StatusCodes.Status202Accepted; - context.HandleResponse(); - return Task.CompletedTask; - }; - }), + ExpectRedirectForSignOut = true, + }; + events.OnRedirectToIdentityProviderForSignOut = context => + { + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + var server = CreateServer(events, context => { return context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); @@ -1638,28 +952,23 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Null(response.Headers.Location); - Assert.True(forSignOut); + events.ValidateExpectations(); } [Fact] public async Task OnRemoteSignOut_Invoked() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnRemoteSignOut = context => - { - forSignOut = true; - return Task.CompletedTask; - }; - }), - AppNotImpl); + ExpectRemoteSignOut = true, + }; + var server = CreateServer(events, AppNotImpl); var client = server.CreateClient(); var response = await client.GetAsync("/signout-oidc"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.True(forSignOut); + events.ValidateExpectations(); Assert.True(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); Assert.True(SetCookieHeaderValue.TryParseStrictList(values.ToList(), out var parsedValues)); Assert.Equal(1, parsedValues.Count); @@ -1669,41 +978,39 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect [Fact] public async Task OnRemoteSignOut_Handled_NoSignout() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnRemoteSignOut = context => - { - forSignOut = true; - context.Response.StatusCode = StatusCodes.Status202Accepted; - context.HandleResponse(); - return Task.CompletedTask; - }; - }), - AppNotImpl); + ExpectRemoteSignOut = true, + }; + events.OnRemoteSignOut = context => + { + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + var server = CreateServer(events, AppNotImpl); var client = server.CreateClient(); var response = await client.GetAsync("/signout-oidc"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); - Assert.True(forSignOut); + events.ValidateExpectations(); Assert.False(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); } [Fact] public async Task OnRemoteSignOut_Skip_NoSignout() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnRemoteSignOut = context => - { - forSignOut = true; - context.SkipHandler(); - return Task.CompletedTask; - }; - }), - context => + ExpectRemoteSignOut = true, + }; + events.OnRemoteSignOut = context => + { + context.SkipHandler(); + return Task.CompletedTask; + }; + var server = CreateServer(events, context => { context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.CompletedTask; @@ -1713,69 +1020,63 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var response = await client.GetAsync("/signout-oidc"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); - Assert.True(forSignOut); + events.ValidateExpectations(); Assert.False(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); } [Fact] public async Task OnRedirectToSignedOutRedirectUri_Invoked() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnSignedOutCallbackRedirect = context => - { - forSignOut = true; - return Task.CompletedTask; - }; - }), - AppNotImpl); + ExpectRedirectToSignedOut = true, + }; + var server = CreateServer(events, AppNotImpl); var client = server.CreateClient(); var response = await client.GetAsync("/signout-callback-oidc?state=protected_state"); Assert.Equal(HttpStatusCode.Found, response.StatusCode); Assert.Equal("http://testhost/redirect", response.Headers.Location.AbsoluteUri); - Assert.True(forSignOut); + events.ValidateExpectations(); } [Fact] public async Task OnRedirectToSignedOutRedirectUri_Handled_NoRedirect() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnSignedOutCallbackRedirect = context => - { - forSignOut = true; - context.Response.StatusCode = StatusCodes.Status202Accepted; - context.HandleResponse(); - return Task.CompletedTask; - }; - }), - AppNotImpl); + ExpectRedirectToSignedOut = true, + }; + events.OnSignedOutCallbackRedirect = context => + { + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + var server = CreateServer(events, AppNotImpl); var client = server.CreateClient(); var response = await client.GetAsync("/signout-callback-oidc?state=protected_state"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Null(response.Headers.Location); - Assert.True(forSignOut); + events.ValidateExpectations(); } [Fact] public async Task OnRedirectToSignedOutRedirectUri_Skipped_NoRedirect() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnSignedOutCallbackRedirect = context => - { - forSignOut = true; - context.SkipHandler(); - return Task.CompletedTask; - }; - }), + ExpectRedirectToSignedOut = true, + }; + events.OnSignedOutCallbackRedirect = context => + { + context.SkipHandler(); + return Task.CompletedTask; + }; + var server = CreateServer(events, context => { context.Response.StatusCode = StatusCodes.Status202Accepted; @@ -1787,29 +1088,124 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Null(response.Headers.Location); - Assert.True(forSignOut); + events.ValidateExpectations(); } - private OpenIdConnectEvents CreateNotImpEvents(Action configureEvents) + private class ExpectedOidcEvents : OpenIdConnectEvents { - var events = new OpenIdConnectEvents() - { - OnMessageReceived = MessageNotImpl, - OnTokenValidated = TokenNotImpl, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - OnRemoteFailure = FailureNotImpl, + public bool ExpectMessageReceived { get; set; } + public bool InvokedMessageReceived { get; set; } - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - OnSignedOutCallbackRedirect = SignedOutCallbackNotImpl, - }; - configureEvents(events); - return events; + public bool ExpectTokenValidated { get; set; } + public bool InvokedTokenValidated { get; set; } + + public bool ExpectRemoteFailure { get; set; } + public bool InvokedRemoteFailure { get; set; } + + public bool ExpectTicketReceived { get; set; } + public bool InvokedTicketReceived { get; set; } + + public bool ExpectAuthorizationCodeReceived { get; set; } + public bool InvokedAuthorizationCodeReceived { get; set; } + + public bool ExpectTokenResponseReceived { get; set; } + public bool InvokedTokenResponseReceived { get; set; } + + public bool ExpectUserInfoReceived { get; set; } + public bool InvokedUserInfoReceived { get; set; } + + public bool ExpectAuthenticationFailed { get; set; } + public bool InvokeAuthenticationFailed { get; set; } + + public bool ExpectRedirectForSignOut { get; set; } + public bool InvokedRedirectForSignOut { get; set; } + + public bool ExpectRemoteSignOut { get; set; } + public bool InvokedRemoteSignOut { get; set; } + + public bool ExpectRedirectToSignedOut { get; set; } + public bool InvokedRedirectToSignedOut { get; set; } + + public override Task MessageReceived(MessageReceivedContext context) + { + InvokedMessageReceived = true; + return base.MessageReceived(context); + } + + public override Task TokenValidated(TokenValidatedContext context) + { + InvokedTokenValidated = true; + return base.TokenValidated(context); + } + + public override Task AuthorizationCodeReceived(AuthorizationCodeReceivedContext context) + { + InvokedAuthorizationCodeReceived = true; + return base.AuthorizationCodeReceived(context); + } + + public override Task TokenResponseReceived(TokenResponseReceivedContext context) + { + InvokedTokenResponseReceived = true; + return base.TokenResponseReceived(context); + } + + public override Task UserInformationReceived(UserInformationReceivedContext context) + { + InvokedUserInfoReceived = true; + return base.UserInformationReceived(context); + } + + public override Task AuthenticationFailed(AuthenticationFailedContext context) + { + InvokeAuthenticationFailed = true; + return base.AuthenticationFailed(context); + } + + public override Task TicketReceived(TicketReceivedContext context) + { + InvokedTicketReceived = true; + return base.TicketReceived(context); + } + + public override Task RemoteFailure(RemoteFailureContext context) + { + InvokedRemoteFailure = true; + return base.RemoteFailure(context); + } + + public override Task RedirectToIdentityProviderForSignOut(RedirectContext context) + { + InvokedRedirectForSignOut = true; + return base.RedirectToIdentityProviderForSignOut(context); + } + + public override Task RemoteSignOut(RemoteSignOutContext context) + { + InvokedRemoteSignOut = true; + return base.RemoteSignOut(context); + } + + public override Task SignedOutCallbackRedirect(RemoteSignOutContext context) + { + InvokedRedirectToSignedOut = true; + return base.SignedOutCallbackRedirect(context); + } + + public void ValidateExpectations() + { + Assert.Equal(ExpectMessageReceived, InvokedMessageReceived); + Assert.Equal(ExpectTokenValidated, InvokedTokenValidated); + Assert.Equal(ExpectAuthorizationCodeReceived, InvokedAuthorizationCodeReceived); + Assert.Equal(ExpectTokenResponseReceived, InvokedTokenResponseReceived); + Assert.Equal(ExpectUserInfoReceived, InvokedUserInfoReceived); + Assert.Equal(ExpectAuthenticationFailed, InvokeAuthenticationFailed); + Assert.Equal(ExpectTicketReceived, InvokedTicketReceived); + Assert.Equal(ExpectRemoteFailure, InvokedRemoteFailure); + Assert.Equal(ExpectRedirectForSignOut, InvokedRedirectForSignOut); + Assert.Equal(ExpectRemoteSignOut, InvokedRemoteSignOut); + Assert.Equal(ExpectRedirectToSignedOut, InvokedRedirectToSignedOut); + } } private TestServer CreateServer(OpenIdConnectEvents events, RequestDelegate appCode) From bd8ecd02684d490ece96c484e1092386f3515dec Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Nov 2017 16:37:42 -0700 Subject: [PATCH 823/900] Pin tool and package versions to make builds more repeatable Part of aspnet/Universe#575 --- .gitignore | 1 - Directory.Build.props | 6 +-- Directory.Build.targets | 17 ++----- NuGet.config | 1 + build/dependencies.props | 46 +++++++++++++++++++ build/repo.props | 8 +++- korebuild-lock.txt | 2 + korebuild.json | 4 ++ samples/CookieSample/CookieSample.csproj | 12 ++--- .../CookieSessionSample.csproj | 12 ++--- .../JwtBearerSample/JwtBearerSample.csproj | 12 ++--- .../OpenIdConnect.AzureAdSample.csproj | 14 +++--- .../OpenIdConnectSample.csproj | 18 ++++---- samples/SocialSample/SocialSample.csproj | 18 ++++---- src/Directory.Build.props | 2 +- ...AspNetCore.Authentication.JwtBearer.csproj | 2 +- ...oft.AspNetCore.Authentication.OAuth.csproj | 2 +- ...etCore.Authentication.OpenIdConnect.csproj | 2 +- ...Microsoft.AspNetCore.Authentication.csproj | 16 +++---- ...oft.AspNetCore.Authorization.Policy.csproj | 4 +- .../Microsoft.AspNetCore.Authorization.csproj | 4 +- .../Microsoft.AspNetCore.CookiePolicy.csproj | 4 +- .../Microsoft.Owin.Security.Interop.csproj | 4 +- test/Directory.Build.props | 12 ++--- ...soft.AspNetCore.Authentication.Test.csproj | 2 +- ...osoft.AspNetCore.Authorization.Test.csproj | 6 +-- ....ChunkingCookieManager.Sources.Test.csproj | 2 +- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 4 +- ...icrosoft.Owin.Security.Interop.Test.csproj | 6 +-- version.props | 10 ++++ version.xml | 8 ---- 31 files changed, 155 insertions(+), 106 deletions(-) create mode 100644 build/dependencies.props create mode 100644 korebuild-lock.txt create mode 100644 korebuild.json create mode 100644 version.props delete mode 100644 version.xml diff --git a/.gitignore b/.gitignore index bac5b75057..d5717b3f3f 100644 --- a/.gitignore +++ b/.gitignore @@ -30,4 +30,3 @@ project.lock.json /.vs/ .vscode/ global.json -korebuild-lock.txt diff --git a/Directory.Build.props b/Directory.Build.props index 61b629ccce..d277ef8629 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,6 @@ - - + + + Microsoft ASP.NET Core @@ -9,7 +10,6 @@ $(MSBuildThisFileDirectory)build\Key.snk true true - $(VersionSuffix)-$(BuildNumber) true diff --git a/Directory.Build.targets b/Directory.Build.targets index bc118fd907..e83ff95e39 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,14 +1,5 @@ - - - - <_BootstrapperFile Condition=" $([MSBuild]::IsOSUnixLike()) ">build.sh - <_BootstrapperFile Condition="! $([MSBuild]::IsOSUnixLike()) ">build.cmd - <_BootstrapperError> - Package references have not been pinned. Run './$(_BootstrapperFile) /t:Pin'. - Also, you can run './$(_BootstrapperFile) /t:Restore' which will pin *and* restore packages. '$(_BootstrapperFile)' can be found in '$(MSBuildThisFileDirectory)'. - - - - - + + + $(MicrosoftNETCoreApp20PackageVersion) + diff --git a/NuGet.config b/NuGet.config index 20060c934e..4e8a1f6de1 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,6 +3,7 @@ + diff --git a/build/dependencies.props b/build/dependencies.props new file mode 100644 index 0000000000..13ed63da13 --- /dev/null +++ b/build/dependencies.props @@ -0,0 +1,46 @@ + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + + 2.1.0-preview1-15550 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 3.14.1 + 5.2.0-preview1-408290725 + 2.0.0 + 15.3.0 + 3.0.1 + 3.0.1 + 3.0.1 + 10.0.1 + 0.7.0 + 2.3.0 + 2.3.0 + + + diff --git a/build/repo.props b/build/repo.props index 7866974bc2..598c7f5a31 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,7 +1,11 @@  - - + + + + Internal.AspNetCore.Universe.Lineup + https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json + diff --git a/korebuild-lock.txt b/korebuild-lock.txt new file mode 100644 index 0000000000..36d8056037 --- /dev/null +++ b/korebuild-lock.txt @@ -0,0 +1,2 @@ +version:2.1.0-preview1-15550 +commithash:0dd080d0d87b4d1966ec0af9961dc8bacc04f84f diff --git a/korebuild.json b/korebuild.json new file mode 100644 index 0000000000..bd5d51a51b --- /dev/null +++ b/korebuild.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", + "channel": "dev" +} diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 34af273c47..d8ebc437e1 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 6e6bd0e796..d480381765 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 2b3f9c3c98..2880ac9637 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -10,12 +10,12 @@ - - - - - - + + + + + + diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 64d90423ba..1e0a0f5e3f 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -11,13 +11,13 @@ - - - - - - - + + + + + + + diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index bc54cbf3df..84fb99c7be 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -15,15 +15,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index a1706f4d1f..7a8de5763d 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -22,15 +22,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9d9a3de33a..1e0980f663 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,6 +2,6 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 8526fcd397..e5bae5a3da 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index a7af0b7f3f..5c8a5e3a96 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index a8f0077488..b7f4c1704a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index a156fa549f..7e3ce4eb39 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -9,14 +9,14 @@ - - - - - - - - + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index 087645ee02..16e4aa2622 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 3b2ada85f9..ac4aa6c320 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -13,8 +13,8 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute - - + + diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index c6021e012a..1a42b04dde 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index 67f8c94209..a12bc65637 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 724f34b0bb..19544e342c 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,11 +2,11 @@ - - - - - - + + + + + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index ae8789e11b..2a43b216d0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index b133522f09..2b2cc69ba7 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 49bbbd91fe..e6f0b22934 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -10,7 +10,7 @@ - + diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index 7d50d86a31..951dac0c51 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 779d8c141f..f369f1f01a 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -10,9 +10,9 @@ - - - + + + diff --git a/version.props b/version.props new file mode 100644 index 0000000000..5c4a7c32d1 --- /dev/null +++ b/version.props @@ -0,0 +1,10 @@ + + + 2.1.0 + preview1 + $(VersionPrefix) + $(VersionPrefix)-$(VersionSuffix)-final + t000 + $(VersionSuffix)-$(BuildNumber) + + diff --git a/version.xml b/version.xml deleted file mode 100644 index 3c05022b7d..0000000000 --- a/version.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - dev - 2.1.0 - preview1 - - From 1927f65e976a6d81d5ed1fe734833aca578cd166 Mon Sep 17 00:00:00 2001 From: Dominick Baier Date: Fri, 3 Nov 2017 16:55:42 +0100 Subject: [PATCH 824/900] Change LogLevel from Information to Debug (see #1517) --- src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs index 46223d6471..8cba6c0d5e 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -39,7 +39,7 @@ namespace Microsoft.Extensions.Logging formatString: "{AuthenticationScheme} was not authenticated. Failure message: {FailureMessage}"); _authSchemeAuthenticated = LoggerMessage.Define( eventId: 8, - logLevel: LogLevel.Information, + logLevel: LogLevel.Debug, formatString: "AuthenticationScheme: {AuthenticationScheme} was successfully authenticated."); _authSchemeNotAuthenticated = LoggerMessage.Define( eventId: 9, From 72e1cb1385c982e6dba90c839d1a1455e2813e6c Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 6 Nov 2017 14:16:57 -0800 Subject: [PATCH 825/900] Add VirtualSchemes --- .../AuthenticationBuilder.cs | 41 +- .../AuthenticationHandler.cs | 18 +- .../VirtualAuthenticationHandler.cs | 71 +++ .../VirtualSchemeOptions.cs | 33 ++ .../GoogleTests.cs | 22 +- .../VirtualHandlerTests.cs | 525 ++++++++++++++++++ 6 files changed, 674 insertions(+), 36 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs index 3bce55ea10..7bf8fe96ee 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -25,18 +25,10 @@ namespace Microsoft.AspNetCore.Authentication /// public virtual IServiceCollection Services { get; } - /// - /// Adds a which can be used by . - /// - /// The type to configure the handler."/>. - /// The used to handle this scheme. - /// The name of this scheme. - /// The display name of this scheme. - /// Used to configure the scheme options. - /// The builder. - public virtual AuthenticationBuilder AddScheme(string authenticationScheme, string displayName, Action configureOptions) - where TOptions : AuthenticationSchemeOptions, new() - where THandler : AuthenticationHandler + + private AuthenticationBuilder AddSchemeHelper(string authenticationScheme, string displayName, Action configureOptions) + where TOptions : class, new() + where THandler : class, IAuthenticationHandler { Services.Configure(o => { @@ -53,6 +45,20 @@ namespace Microsoft.AspNetCore.Authentication return this; } + /// + /// Adds a which can be used by . + /// + /// The type to configure the handler."/>. + /// The used to handle this scheme. + /// The name of this scheme. + /// The display name of this scheme. + /// Used to configure the scheme options. + /// The builder. + public virtual AuthenticationBuilder AddScheme(string authenticationScheme, string displayName, Action configureOptions) + where TOptions : AuthenticationSchemeOptions, new() + where THandler : AuthenticationHandler + => AddSchemeHelper(authenticationScheme, displayName, configureOptions); + /// /// Adds a which can be used by . /// @@ -84,6 +90,17 @@ namespace Microsoft.AspNetCore.Authentication return AddScheme(authenticationScheme, displayName, configureOptions: configureOptions); } + /// + /// Adds a based authentication handler which can be used to + /// redirect to other authentication schemes. + /// + /// The name of this scheme. + /// The display name of this scheme. + /// Used to configure the scheme options. + /// The builder. + public virtual AuthenticationBuilder AddVirtualScheme(string authenticationScheme, string displayName, Action configureOptions) + => AddSchemeHelper(authenticationScheme, displayName, configureOptions); + // Used to ensure that there's always a default sign in scheme that's not itself private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 9728e5ff05..ef4292100a 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -22,12 +22,12 @@ namespace Microsoft.AspNetCore.Authentication protected HttpRequest Request { - get { return Context.Request; } + get => Context.Request; } protected HttpResponse Response { - get { return Context.Response; } + get => Context.Response; } protected PathString OriginalPath => Context.Features.Get()?.OriginalPath ?? Request.Path; @@ -52,10 +52,7 @@ namespace Microsoft.AspNetCore.Authentication protected string CurrentUri { - get - { - return Request.Scheme + "://" + Request.Host + Request.PathBase + Request.Path + Request.QueryString; - } + get => Request.Scheme + "://" + Request.Host + Request.PathBase + Request.Path + Request.QueryString; } protected AuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) @@ -116,15 +113,10 @@ namespace Microsoft.AspNetCore.Authentication /// Called after options/events have been initialized for the handler to finish initializing itself. /// /// A task - protected virtual Task InitializeHandlerAsync() - { - return Task.CompletedTask; - } + protected virtual Task InitializeHandlerAsync() => Task.CompletedTask; protected string BuildRedirectUri(string targetPath) - { - return Request.Scheme + "://" + Request.Host + OriginalPathBase + targetPath; - } + => Request.Scheme + "://" + Request.Host + OriginalPathBase + targetPath; public async Task AuthenticateAsync() { diff --git a/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs new file mode 100644 index 0000000000..4a023bec2c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs @@ -0,0 +1,71 @@ +// 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.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Forwards calls to another authentication scheme. + /// + public class VirtualAuthenticationHandler : IAuthenticationHandler, IAuthenticationSignInHandler + { + protected IOptionsMonitor OptionsMonitor { get; } + public AuthenticationScheme Scheme { get; private set; } + public VirtualSchemeOptions Options { get; private set; } + protected HttpContext Context { get; private set; } + + public VirtualAuthenticationHandler(IOptionsMonitor options) + { + OptionsMonitor = options; + } + + /// + /// Initialize the handler, resolve the options and validate them. + /// + /// + /// + /// A Task. + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + if (scheme == null) + { + throw new ArgumentNullException(nameof(scheme)); + } + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + Scheme = scheme; + Context = context; + + Options = OptionsMonitor.Get(Scheme.Name) ?? new VirtualSchemeOptions(); + Options.Validate(); + + return Task.CompletedTask; + } + + protected virtual string ResolveTarget(string scheme) + => scheme ?? Options.DefaultSelector?.Invoke(Context) ?? Options.Default; + + public virtual Task AuthenticateAsync() + => Context.AuthenticateAsync(ResolveTarget(Options.Authenticate)); + + public virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + => Context.SignInAsync(ResolveTarget(Options.SignIn), user, properties); + + public virtual Task SignOutAsync(AuthenticationProperties properties) + => Context.SignOutAsync(ResolveTarget(Options.SignOut), properties); + + public virtual Task ChallengeAsync(AuthenticationProperties properties) + => Context.ChallengeAsync(ResolveTarget(Options.Challenge), properties); + + public virtual Task ForbidAsync(AuthenticationProperties properties) + => Context.ForbidAsync(ResolveTarget(Options.Forbid), properties); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs new file mode 100644 index 0000000000..38d819bf59 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs @@ -0,0 +1,33 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Used to redirect authentication methods to another scheme + /// + public class VirtualSchemeOptions + { + public string Default { get; set; } + + public string Authenticate { get; set; } + public string Challenge { get; set; } + public string Forbid { get; set; } + public string SignIn { get; set; } + public string SignOut { get; set; } + + /// + /// Used to select a default scheme to target based on the request. + /// + public Func DefaultSelector { get; set; } + + + /// + /// Check that the options are valid. Should throw an exception if things are not ok. + /// + public virtual void Validate() { } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 51bc67cc38..944a4827c3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -990,7 +990,7 @@ namespace Microsoft.AspNetCore.Authentication.Google var res = context.Response; if (req.Path == new PathString("/challenge")) { - await context.ChallengeAsync("Google"); + await context.ChallengeAsync(); } else if (req.Path == new PathString("/challengeFacebook")) { @@ -1061,19 +1061,19 @@ namespace Microsoft.AspNetCore.Authentication.Google .ConfigureServices(services => { services.AddTransient(); - services.AddAuthentication(o => - { - o.DefaultScheme = TestExtensions.CookieAuthenticationScheme; - o.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme; - }); - services.AddAuthentication() + services.AddAuthentication("Auth") + .AddVirtualScheme("Auth", "Auth", o => + { + o.Default = TestExtensions.CookieAuthenticationScheme; + o.Challenge = GoogleDefaults.AuthenticationScheme; + }) .AddCookie(TestExtensions.CookieAuthenticationScheme) .AddGoogle(configureOptions) .AddFacebook(o => - { - o.AppId = "Test AppId"; - o.AppSecret = "Test AppSecrent"; - }); + { + o.AppId = "Test AppId"; + o.AppSecret = "Test AppSecrent"; + }); }); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs new file mode 100644 index 0000000000..a43478c949 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs @@ -0,0 +1,525 @@ +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication +{ + public class VirtualHandlerTests + { + [Fact] + public async Task CanDispatch() + { + var server = CreateServer(services => + { + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + o.AddScheme("auth3", "auth3"); + }) + .AddVirtualScheme("policy1", "policy1", p => + { + p.Default = "auth1"; + }) + .AddVirtualScheme("policy2", "policy2", p => + { + p.Authenticate = "auth2"; + }); + }); + + var transaction = await server.SendAsync("http://example.com/auth/policy1"); + Assert.Equal("auth1", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth1")); + + transaction = await server.SendAsync("http://example.com/auth/auth1"); + Assert.Equal("auth1", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth1")); + + transaction = await server.SendAsync("http://example.com/auth/auth2"); + Assert.Equal("auth2", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth2")); + + transaction = await server.SendAsync("http://example.com/auth/auth3"); + Assert.Equal("auth3", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth3")); + + transaction = await server.SendAsync("http://example.com/auth/policy2"); + Assert.Equal("auth2", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth2")); + } + + [Fact] + public async Task DefaultTargetSelectorWinsOverDefaultTarget() + { + var services = new ServiceCollection().AddOptions(); + + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + }) + .AddVirtualScheme("forward", "forward", p => { + p.Default = "auth2"; + p.DefaultSelector = ctx => "auth1"; + }); + + var handler1 = new TestHandler(); + services.AddSingleton(handler1); + var handler2 = new TestHandler2(); + services.AddSingleton(handler2); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, handler1.AuthenticateCount); + Assert.Equal(0, handler1.ForbidCount); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(0, handler1.SignOutCount); + Assert.Equal(0, handler2.AuthenticateCount); + Assert.Equal(0, handler2.ForbidCount); + Assert.Equal(0, handler2.ChallengeCount); + Assert.Equal(0, handler2.SignInCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.AuthenticateAsync("forward"); + Assert.Equal(1, handler1.AuthenticateCount); + Assert.Equal(0, handler2.AuthenticateCount); + + await context.ForbidAsync("forward"); + Assert.Equal(1, handler1.ForbidCount); + Assert.Equal(0, handler2.ForbidCount); + + await context.ChallengeAsync("forward"); + Assert.Equal(1, handler1.ChallengeCount); + Assert.Equal(0, handler2.ChallengeCount); + + await context.SignOutAsync("forward"); + Assert.Equal(1, handler1.SignOutCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.SignInAsync("forward", new ClaimsPrincipal()); + Assert.Equal(1, handler1.SignInCount); + Assert.Equal(0, handler2.SignInCount); + } + + [Fact] + public async Task NullDefaultTargetSelectorFallsBacktoDefaultTarget() + { + var services = new ServiceCollection().AddOptions(); + + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + }) + .AddVirtualScheme("forward", "forward", p => { + p.Default = "auth1"; + p.DefaultSelector = ctx => null; + }); + + var handler1 = new TestHandler(); + services.AddSingleton(handler1); + var handler2 = new TestHandler2(); + services.AddSingleton(handler2); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, handler1.AuthenticateCount); + Assert.Equal(0, handler1.ForbidCount); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(0, handler1.SignOutCount); + Assert.Equal(0, handler2.AuthenticateCount); + Assert.Equal(0, handler2.ForbidCount); + Assert.Equal(0, handler2.ChallengeCount); + Assert.Equal(0, handler2.SignInCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.AuthenticateAsync("forward"); + Assert.Equal(1, handler1.AuthenticateCount); + Assert.Equal(0, handler2.AuthenticateCount); + + await context.ForbidAsync("forward"); + Assert.Equal(1, handler1.ForbidCount); + Assert.Equal(0, handler2.ForbidCount); + + await context.ChallengeAsync("forward"); + Assert.Equal(1, handler1.ChallengeCount); + Assert.Equal(0, handler2.ChallengeCount); + + await context.SignOutAsync("forward"); + Assert.Equal(1, handler1.SignOutCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.SignInAsync("forward", new ClaimsPrincipal()); + Assert.Equal(1, handler1.SignInCount); + Assert.Equal(0, handler2.SignInCount); + } + + [Fact] + public async Task SpecificTargetAlwaysWinsOverDefaultTarget() + { + var services = new ServiceCollection().AddOptions(); + + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + }) + .AddVirtualScheme("forward", "forward", p => { + p.Default = "auth2"; + p.DefaultSelector = ctx => "auth2"; + p.Authenticate = "auth1"; + p.SignIn = "auth1"; + p.SignOut = "auth1"; + p.Forbid = "auth1"; + p.Challenge = "auth1"; + }); + + var handler1 = new TestHandler(); + services.AddSingleton(handler1); + var handler2 = new TestHandler2(); + services.AddSingleton(handler2); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, handler1.AuthenticateCount); + Assert.Equal(0, handler1.ForbidCount); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(0, handler1.SignOutCount); + Assert.Equal(0, handler2.AuthenticateCount); + Assert.Equal(0, handler2.ForbidCount); + Assert.Equal(0, handler2.ChallengeCount); + Assert.Equal(0, handler2.SignInCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.AuthenticateAsync("forward"); + Assert.Equal(1, handler1.AuthenticateCount); + Assert.Equal(0, handler2.AuthenticateCount); + + await context.ForbidAsync("forward"); + Assert.Equal(1, handler1.ForbidCount); + Assert.Equal(0, handler2.ForbidCount); + + await context.ChallengeAsync("forward"); + Assert.Equal(1, handler1.ChallengeCount); + Assert.Equal(0, handler2.ChallengeCount); + + await context.SignOutAsync("forward"); + Assert.Equal(1, handler1.SignOutCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.SignInAsync("forward", new ClaimsPrincipal()); + Assert.Equal(1, handler1.SignInCount); + Assert.Equal(0, handler2.SignInCount); + } + + [Fact] + public async Task VirtualSchemeTargetsForwardWithDefaultTarget() + { + var services = new ServiceCollection().AddOptions(); + + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + }) + .AddVirtualScheme("forward", "forward", p => p.Default = "auth1"); + + var handler1 = new TestHandler(); + services.AddSingleton(handler1); + var handler2 = new TestHandler2(); + services.AddSingleton(handler2); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, handler1.AuthenticateCount); + Assert.Equal(0, handler1.ForbidCount); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(0, handler1.SignOutCount); + Assert.Equal(0, handler2.AuthenticateCount); + Assert.Equal(0, handler2.ForbidCount); + Assert.Equal(0, handler2.ChallengeCount); + Assert.Equal(0, handler2.SignInCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.AuthenticateAsync("forward"); + Assert.Equal(1, handler1.AuthenticateCount); + Assert.Equal(0, handler2.AuthenticateCount); + + await context.ForbidAsync("forward"); + Assert.Equal(1, handler1.ForbidCount); + Assert.Equal(0, handler2.ForbidCount); + + await context.ChallengeAsync("forward"); + Assert.Equal(1, handler1.ChallengeCount); + Assert.Equal(0, handler2.ChallengeCount); + + await context.SignOutAsync("forward"); + Assert.Equal(1, handler1.SignOutCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.SignInAsync("forward", new ClaimsPrincipal()); + Assert.Equal(1, handler1.SignInCount); + Assert.Equal(0, handler2.SignInCount); + } + + [Fact] + public async Task VirtualSchemeTargetsOverrideDefaultTarget() + { + var services = new ServiceCollection().AddOptions(); + + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + }) + .AddVirtualScheme("forward", "forward", p => + { + p.Default = "auth1"; + p.Challenge = "auth2"; + p.SignIn = "auth2"; + }); + + var handler1 = new TestHandler(); + services.AddSingleton(handler1); + var handler2 = new TestHandler2(); + services.AddSingleton(handler2); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, handler1.AuthenticateCount); + Assert.Equal(0, handler1.ForbidCount); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(0, handler1.SignOutCount); + Assert.Equal(0, handler2.AuthenticateCount); + Assert.Equal(0, handler2.ForbidCount); + Assert.Equal(0, handler2.ChallengeCount); + Assert.Equal(0, handler2.SignInCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.AuthenticateAsync("forward"); + Assert.Equal(1, handler1.AuthenticateCount); + Assert.Equal(0, handler2.AuthenticateCount); + + await context.ForbidAsync("forward"); + Assert.Equal(1, handler1.ForbidCount); + Assert.Equal(0, handler2.ForbidCount); + + await context.ChallengeAsync("forward"); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(1, handler2.ChallengeCount); + + await context.SignOutAsync("forward"); + Assert.Equal(1, handler1.SignOutCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.SignInAsync("forward", new ClaimsPrincipal()); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(1, handler2.SignInCount); + } + + [Fact] + public async Task CanDynamicTargetBasedOnQueryString() + { + var server = CreateServer(services => + { + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + o.AddScheme("auth3", "auth3"); + }) + .AddVirtualScheme("dynamic", "dynamic", p => + { + p.DefaultSelector = c => c.Request.QueryString.Value.Substring(1); + }); + }); + + var transaction = await server.SendAsync("http://example.com/auth/dynamic?auth1"); + Assert.Equal("auth1", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth1")); + transaction = await server.SendAsync("http://example.com/auth/dynamic?auth2"); + Assert.Equal("auth2", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth2")); + transaction = await server.SendAsync("http://example.com/auth/dynamic?auth3"); + Assert.Equal("auth3", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth3")); + } + + [Fact] + public async Task TargetsDefaultSchemeByDefault() + { + var server = CreateServer(services => + { + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("default", "default"); + }) + .AddVirtualScheme("virtual", "virtual", p => { }); + }); + + var transaction = await server.SendAsync("http://example.com/auth/virtual"); + Assert.Equal("default", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "default")); + } + + [Fact] + public async Task TargetsDefaultSchemeThrowsWithNoDefault() + { + var server = CreateServer(services => + { + services.AddAuthentication(o => + { + o.AddScheme("default", "default"); + }) + .AddVirtualScheme("virtual", "virtual", p => { }); + }); + + var error = await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/virtual")); + Assert.Contains("No authenticationScheme was specified", error.Message); + } + + private class TestHandler : IAuthenticationSignInHandler + { + public AuthenticationScheme Scheme { get; set; } + public int SignInCount { get; set; } + public int SignOutCount { get; set; } + public int ForbidCount { get; set; } + public int ChallengeCount { get; set; } + public int AuthenticateCount { get; set; } + + public Task AuthenticateAsync() + { + AuthenticateCount++; + var principal = new ClaimsPrincipal(); + var id = new ClaimsIdentity(); + id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + principal.AddIdentity(id); + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); + } + + public Task ChallengeAsync(AuthenticationProperties properties) + { + ChallengeCount++; + return Task.CompletedTask; + } + + public Task ForbidAsync(AuthenticationProperties properties) + { + ForbidCount++; + return Task.CompletedTask; + } + + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + Scheme = scheme; + return Task.CompletedTask; + } + + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + { + SignInCount++; + return Task.CompletedTask; + } + + public Task SignOutAsync(AuthenticationProperties properties) + { + SignOutCount++; + return Task.CompletedTask; + } + } + + private class TestHandler2 : IAuthenticationSignInHandler + { + public AuthenticationScheme Scheme { get; set; } + public int SignInCount { get; set; } + public int SignOutCount { get; set; } + public int ForbidCount { get; set; } + public int ChallengeCount { get; set; } + public int AuthenticateCount { get; set; } + + public Task AuthenticateAsync() + { + AuthenticateCount++; + var principal = new ClaimsPrincipal(); + var id = new ClaimsIdentity(); + id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + principal.AddIdentity(id); + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); + } + + public Task ChallengeAsync(AuthenticationProperties properties) + { + ChallengeCount++; + return Task.CompletedTask; + } + + public Task ForbidAsync(AuthenticationProperties properties) + { + ForbidCount++; + return Task.CompletedTask; + } + + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + Scheme = scheme; + return Task.CompletedTask; + } + + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + { + SignInCount++; + return Task.CompletedTask; + } + + public Task SignOutAsync(AuthenticationProperties properties) + { + SignOutCount++; + return Task.CompletedTask; + } + } + + private static TestServer CreateServer(Action configure = null, string defaultScheme = null) + { + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Use(async (context, next) => + { + var req = context.Request; + var res = context.Response; + if (req.Path.StartsWithSegments(new PathString("/auth"), out var remainder)) + { + var name = (remainder.Value.Length > 0) ? remainder.Value.Substring(1) : null; + var result = await context.AuthenticateAsync(name); + res.Describe(result?.Ticket?.Principal); + } + else + { + await next(); + } + }); + }) + .ConfigureServices(services => + { + configure?.Invoke(services); + }); + return new TestServer(builder); + } + } +} From 148aef110e647d02224a2b2a180917539a8beaa0 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 7 Nov 2017 17:30:50 -0800 Subject: [PATCH 826/900] Remove redundant ProjectReference's in Auth.Test.csproj cref dotnet/sdk#1716 --- .../Microsoft.AspNetCore.Authentication.Test.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 2a43b216d0..b49206567a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -12,8 +12,6 @@ - - From 5e51cb5c691eda23e965a57ac5d83c8497ff40d6 Mon Sep 17 00:00:00 2001 From: Mikael Frosthage Date: Fri, 10 Nov 2017 17:46:12 +0100 Subject: [PATCH 827/900] Fixed summary tag on comment (#1535) --- .../OpenIdConnect/OpenIdConnectTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 32be26d33e..da52e0e4cb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect /// /// Tests RedirectForSignOutContext replaces the OpenIdConnectMesssage correctly. - /// summary> + /// /// Task [Fact] public async Task SignOutSettingMessage() From f8711a2da3fdf6b250d528136c6e9d8ecf78062b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 13 Nov 2017 17:24:59 -0800 Subject: [PATCH 828/900] Update samples and tests to target netcoreapp2.1 --- Directory.Build.props | 4 ++++ korebuild-lock.txt | 4 ++-- samples/CookieSample/CookieSample.csproj | 2 +- samples/CookieSessionSample/CookieSessionSample.csproj | 2 +- samples/JwtBearerSample/JwtBearerSample.csproj | 2 +- .../OpenIdConnect.AzureAdSample.csproj | 2 +- samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 2 +- samples/SocialSample/SocialSample.csproj | 2 +- test/Directory.Build.props | 7 +++++++ .../Microsoft.AspNetCore.Authentication.Test.csproj | 3 +-- .../OpenIdConnect/TestSettings.cs | 2 +- .../Microsoft.AspNetCore.Authorization.Test.csproj | 3 +-- ...ft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj | 3 +-- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 3 +-- 14 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index d277ef8629..e6771f7a88 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,8 @@  + + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 36d8056037..95f4613014 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15550 -commithash:0dd080d0d87b4d1966ec0af9961dc8bacc04f84f +version:2.1.0-preview1-15567 +commithash:903e3104807b1bb8cddd28bdef205b1e2dc021d1 diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index d8ebc437e1..193137b861 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index d480381765..6241edd667 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 2880ac9637..84b436581a 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 aspnet5-JwtBearerSample-20151210102827 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 1e0a0f5e3f..b14b9590f5 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 84fb99c7be..23e87d4f2a 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 7a8de5763d..a423ae21a3 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 aspnet5-SocialSample-20151210111056 diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 19544e342c..b842a48317 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,6 +1,13 @@  + + netcoreapp2.1 + $(DeveloperBuildTestTfms) + $(StandardTestTfms);netcoreapp2.0 + $(StandardTestTfms);net461 + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index b49206567a..57fed96c02 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -1,8 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index f174342aed..509b85e64e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -252,7 +252,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => -#if NETCOREAPP2_0 +#if NETCOREAPP2_0 || NETCOREAPP2_1 ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NETSTANDARD1_4", actualParams, errors, htmlEncoded); #elif NET461 ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET451", actualParams, errors, htmlEncoded); diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 2b2cc69ba7..d4379c3aab 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -1,8 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index e6f0b22934..20cd400ce7 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -1,8 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index 951dac0c51..d7a42f3efb 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -1,8 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) From 34083584a6593b636ed507c1b8e50570197ec2ad Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 17 Nov 2017 13:00:26 -0800 Subject: [PATCH 829/900] Use MicrosoftNETCoreApp21PackageVersion to determine the runtime framework in netcoreapp2.1 --- Directory.Build.targets | 1 + build/dependencies.props | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index e83ff95e39..894b1d0cf8 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,5 +1,6 @@  $(MicrosoftNETCoreApp20PackageVersion) + $(MicrosoftNETCoreApp21PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index 13ed63da13..7ef0a7cf7f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -33,6 +33,7 @@ 3.14.1 5.2.0-preview1-408290725 2.0.0 + 2.1.0-preview1-25907-02 15.3.0 3.0.1 3.0.1 From 28aae41993ee31b66cff28c6b8590941560c57b3 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 20 Nov 2017 12:18:35 -0800 Subject: [PATCH 830/900] Use MSBuild to set NuGet feeds instead of NuGet.config --- Directory.Build.props | 1 + NuGet.config | 4 +--- build/sources.props | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 build/sources.props diff --git a/Directory.Build.props b/Directory.Build.props index e6771f7a88..adbda10ef8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,6 +5,7 @@ + Microsoft ASP.NET Core diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de1..e32bddfd51 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,8 +2,6 @@ - - - + diff --git a/build/sources.props b/build/sources.props new file mode 100644 index 0000000000..c03f3ddb60 --- /dev/null +++ b/build/sources.props @@ -0,0 +1,16 @@ + + + + + $(DotNetRestoreSources) + + $(RestoreSources); + https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; + + + $(RestoreSources); + https://api.nuget.org/v3/index.json; + + + From a9482d1d03fc22f62e42cf31b8adb32c5550835e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Nov 2017 15:48:55 -0800 Subject: [PATCH 831/900] Replace aspnetcore-ci-dev feed with aspnetcore-dev --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- build/repo.props | 2 +- build/sources.props | 2 +- korebuild-lock.txt | 4 +-- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7ef0a7cf7f..e02aaa262c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,37 +1,37 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15550 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 + 2.1.0-preview1-15576 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 3.14.1 - 5.2.0-preview1-408290725 + 5.2.0-preview2-41113220915 2.0.0 2.1.0-preview1-25907-02 15.3.0 diff --git a/build/repo.props b/build/repo.props index 598c7f5a31..62f47b7a54 100644 --- a/build/repo.props +++ b/build/repo.props @@ -6,6 +6,6 @@ Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index c03f3ddb60..9feff29d09 100644 --- a/build/sources.props +++ b/build/sources.props @@ -5,7 +5,7 @@ $(DotNetRestoreSources) $(RestoreSources); - https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 95f4613014..1a99066b7c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15567 -commithash:903e3104807b1bb8cddd28bdef205b1e2dc021d1 +version:2.1.0-preview1-15576 +commithash:2f3856d2ba4f659fcb9253215b83946a06794a27 From e2f6ad6169e229c60cd8d3b6221bb43f66bcabea Mon Sep 17 00:00:00 2001 From: Muqeet Khan Date: Wed, 22 Nov 2017 13:04:54 -0600 Subject: [PATCH 832/900] Updated logging extension to remove the period on ValidationFailed _tokenValidationFailed format string includes the JWT token followed by a period, which if a dev troubleshooting copies incorrectly to the EOL will make the JWT invalid. Current: Failed to validate the token eyJhbGc.......HCwFmw. Proposed: Failed to validate the token eyJhbGc.......HCwFmw --- .../LoggingExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs index 008190f516..38a75fecaf 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs @@ -16,7 +16,7 @@ namespace Microsoft.Extensions.Logging _tokenValidationFailed = LoggerMessage.Define( eventId: 1, logLevel: LogLevel.Information, - formatString: "Failed to validate the token {Token}."); + formatString: "Failed to validate the token {Token}"); _tokenValidationSucceeded = LoggerMessage.Define( eventId: 2, logLevel: LogLevel.Information, From e69d9e20635abcc8ae46970f819397b717b2527a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 29 Nov 2017 14:09:30 -0800 Subject: [PATCH 833/900] Specify runtime versions to install --- build/repo.props | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build/repo.props b/build/repo.props index 62f47b7a54..541470c9f4 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,11 +1,17 @@  + + - Internal.AspNetCore.Universe.Lineup https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + + + + + From c5307f9a7a809b2c640785ac7f271287f807524e Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 1 Dec 2017 10:27:12 -0800 Subject: [PATCH 834/900] Update bootstrappers --- run.ps1 | 17 +++++++++++------ run.sh | 30 +++++++++++++++++++----------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/run.ps1 b/run.ps1 index 49c2899856..27dcf848f8 100644 --- a/run.ps1 +++ b/run.ps1 @@ -29,6 +29,9 @@ Updates KoreBuild to the latest version even if a lock file is present. .PARAMETER ConfigFile The path to the configuration file that stores values. Defaults to korebuild.json. +.PARAMETER ToolsSourceSuffix +The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. + .PARAMETER Arguments Arguments to be passed to the command @@ -51,7 +54,7 @@ Example config file: #> [CmdletBinding(PositionalBinding = $false)] param( - [Parameter(Mandatory=$true, Position = 0)] + [Parameter(Mandatory = $true, Position = 0)] [string]$Command, [string]$Path = $PSScriptRoot, [Alias('c')] @@ -63,6 +66,7 @@ param( [Alias('u')] [switch]$Update, [string]$ConfigFile, + [string]$ToolsSourceSuffix, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) @@ -79,7 +83,7 @@ function Get-KoreBuild { $lockFile = Join-Path $Path 'korebuild-lock.txt' if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix } $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 @@ -96,7 +100,7 @@ function Get-KoreBuild { try { $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile + Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { # Use built-in commands where possible as they are cross-plat compatible Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath @@ -124,7 +128,7 @@ function Join-Paths([string]$path, [string[]]$childPaths) { return $path } -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { if ($RemotePath -notlike 'http*') { Copy-Item $RemotePath $LocalPath return @@ -134,7 +138,7 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { while ($retries -gt 0) { $retries -= 1 try { - Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath + Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath return } catch { @@ -161,7 +165,8 @@ if (Test-Path $ConfigFile) { if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} } - } catch { + } + catch { Write-Warning "$ConfigFile could not be read. Its settings will be ignored." Write-Warning $Error[0] } diff --git a/run.sh b/run.sh index c278423acc..834961fc3a 100755 --- a/run.sh +++ b/run.sh @@ -17,6 +17,7 @@ update=false repo_path="$DIR" channel='' tools_source='' +tools_source_suffix='' # # Functions @@ -29,13 +30,14 @@ __usage() { echo " ... Arguments passed to the command. Variable number of arguments allowed." echo "" echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." + echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." echo "" echo "Description:" echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." @@ -50,7 +52,7 @@ get_korebuild() { local version local lock_file="$repo_path/korebuild-lock.txt" if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" fi version="$(grep 'version:*' -m 1 "$lock_file")" if [[ "$version" == '' ]]; then @@ -66,7 +68,7 @@ get_korebuild() { local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" tmpfile="$(mktemp)" echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile"; then + if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then unzip -q -d "$korebuild_path" "$tmpfile" fi rm "$tmpfile" || true @@ -98,6 +100,7 @@ __machine_has() { __get_remote_file() { local remote_path=$1 local local_path=$2 + local remote_path_suffix=$3 if [[ "$remote_path" != 'http'* ]]; then cp "$remote_path" "$local_path" @@ -106,14 +109,14 @@ __get_remote_file() { local failed=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true else failed=true fi if [ "$failed" = true ] && __machine_has curl; then failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true fi if [ "$failed" = true ]; then @@ -164,6 +167,11 @@ while [[ $# -gt 0 ]]; do tools_source="${1:-}" [ -z "$tools_source" ] && __usage ;; + --tools-source-suffix|-ToolsSourceSuffix) + shift + tools_source_suffix="${1:-}" + [ -z "$tools_source_suffix" ] && __usage + ;; -u|--update|-Update) update=true ;; From 4edc900dd89a0ad0a2244634764ac23696909f94 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 10 Dec 2017 13:47:31 -0800 Subject: [PATCH 835/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 62 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index e02aaa262c..450a5804b7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,45 +3,45 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15576 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 + 2.1.0-preview1-15618 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 3.14.1 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-25907-02 + 2.1.0-preview1-25915-01 15.3.0 3.0.1 3.0.1 3.0.1 10.0.1 - 0.7.0 - 2.3.0 - 2.3.0 + 0.8.0 + 2.3.1 + 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1a99066b7c..e7cce93009 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15576 -commithash:2f3856d2ba4f659fcb9253215b83946a06794a27 +version:2.1.0-preview1-15618 +commithash:00ce1383114015fe89b221146036e59e6bc11219 From bd3c202fcd707fdb7ac583d466463007bd9137df Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 13 Dec 2017 21:42:05 +0000 Subject: [PATCH 836/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 450a5804b7..d98007d0ca 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,37 +3,37 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15618 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 + 2.1.0-preview1-15626 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 3.14.1 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-25915-01 + 2.1.0-preview1-26008-01 15.3.0 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e7cce93009..8d52a6128c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15618 -commithash:00ce1383114015fe89b221146036e59e6bc11219 +version:2.1.0-preview1-15626 +commithash:fd6410e9c90c428bc01238372303ad09cb9ec889 From 45ab9485d3116432d1235ba0f466ff5d69e21620 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 18 Dec 2017 17:56:00 -0800 Subject: [PATCH 837/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d98007d0ca..9eca47a759 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,36 +4,36 @@ 2.1.0-preview1-15626 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 3.14.1 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-26008-01 + 2.1.0-preview1-26016-05 15.3.0 3.0.1 3.0.1 From f8b4f4c620e2faaeec262d302df143068c8d0b33 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 17 Nov 2017 15:08:30 -0800 Subject: [PATCH 838/900] Add consent to CookiePolicy #1561 --- Security.sln | 21 +- .../CookiePolicySample.csproj | 18 + samples/CookiePolicySample/Program.cs | 26 + .../Properties/launchSettings.json | 27 + samples/CookiePolicySample/Startup.cs | 118 ++++ .../ChunkingCookieManager.cs | 2 + .../CookieAuthenticationOptions.cs | 1 + .../OpenIdConnectOptions.cs | 1 + .../TwitterOptions.cs | 1 + .../RemoteAuthenticationOptions.cs | 1 + .../AppendCookieContext.cs | 3 + .../CookiePolicyMiddleware.cs | 151 +---- .../CookiePolicyOptions.cs | 12 + .../DeleteCookieContext.cs | 3 + .../ResponseCookiesWrapper.cs | 220 +++++++ .../CookieConsentTests.cs | 561 ++++++++++++++++++ 16 files changed, 1021 insertions(+), 145 deletions(-) create mode 100644 samples/CookiePolicySample/CookiePolicySample.csproj create mode 100644 samples/CookiePolicySample/Program.cs create mode 100644 samples/CookiePolicySample/Properties/launchSettings.json create mode 100644 samples/CookiePolicySample/Startup.cs create mode 100644 src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs create mode 100644 test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs diff --git a/Security.sln b/Security.sln index f88d8576b3..543b3be264 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.10 +VisualStudioVersion = 15.0.27004.2002 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" ProjectSection(SolutionItems) = preProject @@ -72,6 +72,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authorization.Policy", "src\Microsoft.AspNetCore.Authorization.Policy\Microsoft.AspNetCore.Authorization.Policy.csproj", "{58194599-F07D-47A3-9DF2-E21A22C5EF9E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookiePolicySample", "samples\CookiePolicySample\CookiePolicySample.csproj", "{24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -462,6 +464,22 @@ Global {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x64.Build.0 = Release|Any CPU {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.ActiveCfg = Release|Any CPU {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.Build.0 = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|x64.ActiveCfg = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|x64.Build.0 = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|x86.ActiveCfg = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|x86.Build.0 = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|Any CPU.Build.0 = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x64.ActiveCfg = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x64.Build.0 = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x86.ActiveCfg = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -491,6 +509,7 @@ Global {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {58194599-F07D-47A3-9DF2-E21A22C5EF9E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {ABF8089E-43D0-4010-84A7-7A9DCFE49357} diff --git a/samples/CookiePolicySample/CookiePolicySample.csproj b/samples/CookiePolicySample/CookiePolicySample.csproj new file mode 100644 index 0000000000..fb2e7d9172 --- /dev/null +++ b/samples/CookiePolicySample/CookiePolicySample.csproj @@ -0,0 +1,18 @@ + + + + net461;netcoreapp2.1 + + + + + + + + + + + + + + diff --git a/samples/CookiePolicySample/Program.cs b/samples/CookiePolicySample/Program.cs new file mode 100644 index 0000000000..12fc8ff287 --- /dev/null +++ b/samples/CookiePolicySample/Program.cs @@ -0,0 +1,26 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; + +namespace CookiePolicySample +{ + public static class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/samples/CookiePolicySample/Properties/launchSettings.json b/samples/CookiePolicySample/Properties/launchSettings.json new file mode 100644 index 0000000000..38ca6fc37f --- /dev/null +++ b/samples/CookiePolicySample/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:1788/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "CookieSample": { + "commandName": "Project", + "launchBrowser": true, + "applicationUrl": "http://localhost:12345", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/samples/CookiePolicySample/Startup.cs b/samples/CookiePolicySample/Startup.cs new file mode 100644 index 0000000000..7ce9c2d2d2 --- /dev/null +++ b/samples/CookiePolicySample/Startup.cs @@ -0,0 +1,118 @@ +using System; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; + +namespace CookiePolicySample +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) + .AddCookie(); + services.Configure(options => + { + options.CheckConsentNeeded = context => context.Request.PathBase.Equals("/NeedsConsent"); + + options.OnAppendCookie = context => { }; + }); + } + + public void Configure(IApplicationBuilder app) + { + app.UseCookiePolicy(); + app.UseAuthentication(); + + app.Map("/NeedsConsent", NestedApp); + app.Map("/NeedsNoConsent", NestedApp); + NestedApp(app); + } + + private void NestedApp(IApplicationBuilder app) + { + app.Run(async context => + { + var path = context.Request.Path; + switch (path) + { + case "/Login": + var user = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "bob") }, + CookieAuthenticationDefaults.AuthenticationScheme)); + await context.SignInAsync(user); + break; + case "/Logout": + await context.SignOutAsync(); + break; + case "/CreateTempCookie": + context.Response.Cookies.Append("Temp", "1"); + break; + case "/RemoveTempCookie": + context.Response.Cookies.Delete("Temp"); + break; + case "/GrantConsent": + context.Features.Get().GrantConsent(); + break; + case "/WithdrawConsent": + context.Features.Get().WithdrawConsent(); + break; + } + + // TODO: Debug log when cookie is suppressed + + await HomePage(context); + }); + } + + private async Task HomePage(HttpContext context) + { + var response = context.Response; + var cookies = context.Request.Cookies; + response.ContentType = "text/html"; + await response.WriteAsync("\r\n"); + + await response.WriteAsync($"Home
\r\n"); + await response.WriteAsync($"Login
\r\n"); + await response.WriteAsync($"Logout
\r\n"); + await response.WriteAsync($"Create Temp Cookie
\r\n"); + await response.WriteAsync($"Remove Temp Cookie
\r\n"); + await response.WriteAsync($"Grant Consent
\r\n"); + await response.WriteAsync($"Withdraw Consent
\r\n"); + await response.WriteAsync("
\r\n"); + await response.WriteAsync($"Needs Consent
\r\n"); + await response.WriteAsync($"Needs No Consent
\r\n"); + await response.WriteAsync("
\r\n"); + + var feature = context.Features.Get(); + await response.WriteAsync($"Consent:
\r\n"); + await response.WriteAsync($" - IsNeeded: {feature.IsConsentNeeded}
\r\n"); + await response.WriteAsync($" - Has: {feature.HasConsent}
\r\n"); + await response.WriteAsync($" - Can Track: {feature.CanTrack}
\r\n"); + await response.WriteAsync("
\r\n"); + + await response.WriteAsync($"{cookies.Count} Request Cookies:
\r\n"); + foreach (var cookie in cookies) + { + await response.WriteAsync($" - {cookie.Key} = {cookie.Value}
\r\n"); + } + await response.WriteAsync("
\r\n"); + + var responseCookies = response.Headers[HeaderNames.SetCookie]; + await response.WriteAsync($"{responseCookies.Count} Response Cookies:
\r\n"); + foreach (var cookie in responseCookies) + { + await response.WriteAsync($" - {cookie}
\r\n"); + } + + await response.WriteAsync(""); + } + } +} diff --git a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs index 7217e70d4f..42cc4e2f0f 100644 --- a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs +++ b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -285,6 +285,7 @@ namespace Microsoft.AspNetCore.Internal Path = options.Path, Domain = options.Domain, SameSite = options.SameSite, + IsEssential = options.IsEssential, Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), }); @@ -299,6 +300,7 @@ namespace Microsoft.AspNetCore.Internal Path = options.Path, Domain = options.Domain, SameSite = options.SameSite, + IsEssential = options.IsEssential, Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), }); } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 04c71ed1ef..35017f9c4d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -21,6 +21,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies SameSite = SameSiteMode.Lax, HttpOnly = true, SecurePolicy = CookieSecurePolicy.SameAsRequest, + IsEssential = true, }; /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index a40d374356..cbf6e8eab6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -74,6 +74,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect HttpOnly = true, SameSite = SameSiteMode.None, SecurePolicy = CookieSecurePolicy.SameAsRequest, + IsEssential = true, }; } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 86919d0925..03396807ee 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -35,6 +35,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter SecurePolicy = CookieSecurePolicy.SameAsRequest, HttpOnly = true, SameSite = SameSiteMode.Lax, + IsEssential = true, }; } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index daba1890fb..1bd3b210e5 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -29,6 +29,7 @@ namespace Microsoft.AspNetCore.Authentication HttpOnly = true, SameSite = SameSiteMode.None, SecurePolicy = CookieSecurePolicy.SameAsRequest, + IsEssential = true, }; } diff --git a/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs b/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs index 1b13251f73..bbb4899c04 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs @@ -19,5 +19,8 @@ namespace Microsoft.AspNetCore.CookiePolicy public CookieOptions CookieOptions { get; } public string CookieName { get; set; } public string CookieValue { get; set; } + public bool IsConsentNeeded { get; internal set; } + public bool HasConsent { get; internal set; } + public bool IssueCookie { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs index 92adac9677..b99fed2c3d 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -1,7 +1,6 @@ // 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.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; @@ -27,157 +26,21 @@ namespace Microsoft.AspNetCore.CookiePolicy public Task Invoke(HttpContext context) { var feature = context.Features.Get() ?? new ResponseCookiesFeature(context.Features); - context.Features.Set(new CookiesWrapperFeature(context, Options, feature)); + var wrapper = new ResponseCookiesWrapper(context, Options, feature); + context.Features.Set(new CookiesWrapperFeature(wrapper)); + context.Features.Set(wrapper); + return _next(context); } private class CookiesWrapperFeature : IResponseCookiesFeature { - public CookiesWrapperFeature(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature) + public CookiesWrapperFeature(ResponseCookiesWrapper wrapper) { - Wrapper = new CookiesWrapper(context, options, feature); + Cookies = wrapper; } - public IResponseCookies Wrapper { get; } - - public IResponseCookies Cookies - { - get - { - return Wrapper; - } - } - } - - private class CookiesWrapper : IResponseCookies - { - public CookiesWrapper(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature) - { - Context = context; - Feature = feature; - Policy = options; - } - - public HttpContext Context { get; } - - public IResponseCookiesFeature Feature { get; } - - public IResponseCookies Cookies - { - get - { - return Feature.Cookies; - } - } - - public CookiePolicyOptions Policy { get; } - - private bool PolicyRequiresCookieOptions() - { - return Policy.MinimumSameSitePolicy != SameSiteMode.None || Policy.HttpOnly != HttpOnlyPolicy.None || Policy.Secure != CookieSecurePolicy.None; - } - - public void Append(string key, string value) - { - if (PolicyRequiresCookieOptions() || Policy.OnAppendCookie != null) - { - Append(key, value, new CookieOptions()); - } - else - { - Cookies.Append(key, value); - } - } - - public void Append(string key, string value, CookieOptions options) - { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - ApplyPolicy(options); - if (Policy.OnAppendCookie != null) - { - var context = new AppendCookieContext(Context, options, key, value); - Policy.OnAppendCookie(context); - key = context.CookieName; - value = context.CookieValue; - } - Cookies.Append(key, value, options); - } - - public void Delete(string key) - { - if (PolicyRequiresCookieOptions() || Policy.OnDeleteCookie != null) - { - Delete(key, new CookieOptions()); - } - else - { - Cookies.Delete(key); - } - } - - public void Delete(string key, CookieOptions options) - { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - ApplyPolicy(options); - if (Policy.OnDeleteCookie != null) - { - var context = new DeleteCookieContext(Context, options, key); - Policy.OnDeleteCookie(context); - key = context.CookieName; - } - Cookies.Delete(key, options); - } - - private void ApplyPolicy(CookieOptions options) - { - switch (Policy.Secure) - { - case CookieSecurePolicy.Always: - options.Secure = true; - break; - case CookieSecurePolicy.SameAsRequest: - options.Secure = Context.Request.IsHttps; - break; - case CookieSecurePolicy.None: - break; - default: - throw new InvalidOperationException(); - } - switch (Policy.MinimumSameSitePolicy) - { - case SameSiteMode.None: - break; - case SameSiteMode.Lax: - if (options.SameSite == SameSiteMode.None) - { - options.SameSite = SameSiteMode.Lax; - } - break; - case SameSiteMode.Strict: - options.SameSite = SameSiteMode.Strict; - break; - default: - throw new InvalidOperationException($"Unrecognized {nameof(SameSiteMode)} value {Policy.MinimumSameSitePolicy.ToString()}"); - } - switch (Policy.HttpOnly) - { - case HttpOnlyPolicy.Always: - options.HttpOnly = true; - break; - case HttpOnlyPolicy.None: - break; - default: - throw new InvalidOperationException($"Unrecognized {nameof(HttpOnlyPolicy)} value {Policy.HttpOnly.ToString()}"); - } - } + public IResponseCookies Cookies { get; } } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index 1e474bfe22..cc2deaa3aa 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -27,6 +27,18 @@ namespace Microsoft.AspNetCore.Builder /// public CookieSecurePolicy Secure { get; set; } = CookieSecurePolicy.None; + public CookieBuilder ConsentCookie { get; set; } = new CookieBuilder() + { + Name = ".AspNet.Consent", + Expiration = TimeSpan.FromDays(90), + IsEssential = true, + }; + + /// + /// Checks if consent policies should be evaluated on this request. The default is false. + /// + public Func CheckConsentNeeded { get; set; } + /// /// Called when a cookie is appended. /// diff --git a/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs b/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs index f0693bf71f..fd79ea8d4b 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs @@ -17,5 +17,8 @@ namespace Microsoft.AspNetCore.CookiePolicy public HttpContext Context { get; } public CookieOptions CookieOptions { get; } public string CookieName { get; set; } + public bool IsConsentNeeded { get; internal set; } + public bool HasConsent { get; internal set; } + public bool IssueCookie { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs new file mode 100644 index 0000000000..fa68a3cbea --- /dev/null +++ b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs @@ -0,0 +1,220 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; + +namespace Microsoft.AspNetCore.CookiePolicy +{ + internal class ResponseCookiesWrapper : IResponseCookies, ITrackingConsentFeature + { + private const string ConsentValue = "yes"; + + private bool? _isConsentNeeded; + private bool? _hasConsent; + + public ResponseCookiesWrapper(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature) + { + Context = context; + Feature = feature; + Options = options; + } + + private HttpContext Context { get; } + + private IResponseCookiesFeature Feature { get; } + + private IResponseCookies Cookies => Feature.Cookies; + + private CookiePolicyOptions Options { get; } + + public bool IsConsentNeeded + { + get + { + if (!_isConsentNeeded.HasValue) + { + _isConsentNeeded = Options.CheckConsentNeeded == null ? false + : Options.CheckConsentNeeded(Context); + } + + return _isConsentNeeded.Value; + } + } + + public bool HasConsent + { + get + { + if (!_hasConsent.HasValue) + { + var cookie = Context.Request.Cookies[Options.ConsentCookie.Name]; + _hasConsent = string.Equals(cookie, ConsentValue, StringComparison.Ordinal); + } + + return _hasConsent.Value; + } + } + + public bool CanTrack => !IsConsentNeeded || HasConsent; + + public void GrantConsent() + { + if (!HasConsent && !Context.Response.HasStarted) + { + var cookieOptions = Options.ConsentCookie.Build(Context); + // Note policy will be applied. We don't want to bypass policy because we want HttpOnly, Secure, etc. to apply. + Append(Options.ConsentCookie.Name, ConsentValue, cookieOptions); + } + _hasConsent = true; + } + + public void WithdrawConsent() + { + if (HasConsent && !Context.Response.HasStarted) + { + var cookieOptions = Options.ConsentCookie.Build(Context); + // Note policy will be applied. We don't want to bypass policy because we want HttpOnly, Secure, etc. to apply. + Delete(Options.ConsentCookie.Name, cookieOptions); + } + _hasConsent = false; + } + + private bool CheckPolicyRequired() + { + return !CanTrack + || Options.MinimumSameSitePolicy != SameSiteMode.None + || Options.HttpOnly != HttpOnlyPolicy.None + || Options.Secure != CookieSecurePolicy.None; + } + + public void Append(string key, string value) + { + if (CheckPolicyRequired() || Options.OnAppendCookie != null) + { + Append(key, value, new CookieOptions()); + } + else + { + Cookies.Append(key, value); + } + } + + public void Append(string key, string value, CookieOptions options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var issueCookie = CanTrack || options.IsEssential; + ApplyPolicy(options); + if (Options.OnAppendCookie != null) + { + var context = new AppendCookieContext(Context, options, key, value) + { + IsConsentNeeded = IsConsentNeeded, + HasConsent = HasConsent, + IssueCookie = issueCookie, + }; + Options.OnAppendCookie(context); + + key = context.CookieName; + value = context.CookieValue; + issueCookie = context.IssueCookie; + } + + if (issueCookie) + { + Cookies.Append(key, value, options); + } + } + + public void Delete(string key) + { + if (CheckPolicyRequired() || Options.OnDeleteCookie != null) + { + Delete(key, new CookieOptions()); + } + else + { + Cookies.Delete(key); + } + } + + public void Delete(string key, CookieOptions options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + // Assume you can always delete cookies unless directly overridden in the user event. + var issueCookie = true; + ApplyPolicy(options); + if (Options.OnDeleteCookie != null) + { + var context = new DeleteCookieContext(Context, options, key) + { + IsConsentNeeded = IsConsentNeeded, + HasConsent = HasConsent, + IssueCookie = issueCookie, + }; + Options.OnDeleteCookie(context); + + key = context.CookieName; + issueCookie = context.IssueCookie; + } + + if (issueCookie) + { + Cookies.Delete(key, options); + } + } + + private void ApplyPolicy(CookieOptions options) + { + switch (Options.Secure) + { + case CookieSecurePolicy.Always: + options.Secure = true; + break; + case CookieSecurePolicy.SameAsRequest: + options.Secure = Context.Request.IsHttps; + break; + case CookieSecurePolicy.None: + break; + default: + throw new InvalidOperationException(); + } + switch (Options.MinimumSameSitePolicy) + { + case SameSiteMode.None: + break; + case SameSiteMode.Lax: + if (options.SameSite == SameSiteMode.None) + { + options.SameSite = SameSiteMode.Lax; + } + break; + case SameSiteMode.Strict: + options.SameSite = SameSiteMode.Strict; + break; + default: + throw new InvalidOperationException($"Unrecognized {nameof(SameSiteMode)} value {Options.MinimumSameSitePolicy.ToString()}"); + } + switch (Options.HttpOnly) + { + case HttpOnlyPolicy.Always: + options.HttpOnly = true; + break; + case HttpOnlyPolicy.None: + break; + default: + throw new InvalidOperationException($"Unrecognized {nameof(HttpOnlyPolicy)} value {Options.HttpOnly.ToString()}"); + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs new file mode 100644 index 0000000000..4e62d54a26 --- /dev/null +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -0,0 +1,561 @@ +// 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.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; +using Xunit; + +namespace Microsoft.AspNetCore.CookiePolicy.Test +{ + public class CookieConsentTests + { + [Fact] + public async Task ConsentChecksOffByDefault() + { + var httpContext = await RunTestAsync(options => { }, requestContext => { }, context => + { + var feature = context.Features.Get(); + Assert.False(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.True(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + Assert.Equal("Test=Value; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task ConsentEnabledForTemplateScenario() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task NonEssentialCookiesWithOptionsExcluded() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value", new CookieOptions() { IsEssential = false }); + return Task.CompletedTask; + }); + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task NonEssentialCookiesCanBeAllowedViaOnAppendCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.OnAppendCookie = context => + { + Assert.True(context.IsConsentNeeded); + Assert.False(context.HasConsent); + Assert.False(context.IssueCookie); + context.IssueCookie = true; + }; + }, + requestContext => { }, context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value", new CookieOptions() { IsEssential = false }); + return Task.CompletedTask; + }); + Assert.Equal("Test=Value; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task NeedsConsentDoesNotPreventEssentialCookies() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value", new CookieOptions() { IsEssential = true }); + return Task.CompletedTask; + }); + Assert.Equal("Test=Value; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task EssentialCookiesCanBeExcludedByOnAppendCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.OnAppendCookie = context => + { + Assert.True(context.IsConsentNeeded); + Assert.True(context.HasConsent); + Assert.True(context.IssueCookie); + context.IssueCookie = false; + }; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value", new CookieOptions() { IsEssential = true }); + return Task.CompletedTask; + }); + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task HasConsentReadsRequestCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + Assert.Equal("Test=Value; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task HasConsentIgnoresInvalidRequestCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=IAmATeapot"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task GrantConsentSetsCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(2, cookies.Count); + var consentCookie = cookies[0]; + Assert.Equal(".AspNet.Consent", consentCookie.Name); + Assert.Equal("yes", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + var testCookie = cookies[1]; + Assert.Equal("Test", testCookie.Name); + Assert.Equal("Value", testCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, testCookie.SameSite); + Assert.Null(testCookie.Expires); + } + + [Fact] + public async Task GrantConsentAppliesPolicyToConsentCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.MinimumSameSitePolicy = Http.SameSiteMode.Strict; + options.OnAppendCookie = context => + { + Assert.Equal(".AspNet.Consent", context.CookieName); + Assert.Equal("yes", context.CookieValue); + Assert.Equal(Http.SameSiteMode.Strict, context.CookieOptions.SameSite); + context.CookieName += "1"; + context.CookieValue += "1"; + }; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(1, cookies.Count); + var consentCookie = cookies[0]; + Assert.Equal(".AspNet.Consent1", consentCookie.Name); + Assert.Equal("yes1", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Strict, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + } + + [Fact] + public async Task GrantConsentWhenAlreadyHasItDoesNotSetCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + + Assert.Equal("Test=Value; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task GrantConsentAfterResponseStartsSetsHasConsentButDoesNotSetCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, + async context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + await context.Response.WriteAsync("Started."); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + Assert.Throws(() => context.Response.Cookies.Append("Test", "Value")); + + await context.Response.WriteAsync("Granted."); + }); + + var reader = new StreamReader(httpContext.Response.Body); + Assert.Equal("Started.Granted.", await reader.ReadToEndAsync()); + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task WithdrawConsentWhenNotHasConsentNoOps() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + feature.WithdrawConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task WithdrawConsentDeletesCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value1"); + + feature.WithdrawConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + context.Response.Cookies.Append("Test", "Value2"); + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(2, cookies.Count); + var testCookie = cookies[0]; + Assert.Equal("Test", testCookie.Name); + Assert.Equal("Value1", testCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, testCookie.SameSite); + Assert.Null(testCookie.Expires); + var consentCookie = cookies[1]; + Assert.Equal(".AspNet.Consent", consentCookie.Name); + Assert.Equal("", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + } + + [Fact] + public async Task WithdrawConsentAppliesPolicyToDeleteCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.MinimumSameSitePolicy = Http.SameSiteMode.Strict; + options.OnDeleteCookie = context => + { + Assert.Equal(".AspNet.Consent", context.CookieName); + context.CookieName += "1"; + }; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + feature.WithdrawConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(1, cookies.Count); + var consentCookie = cookies[0]; + Assert.Equal(".AspNet.Consent1", consentCookie.Name); + Assert.Equal("", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Strict, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + } + + [Fact] + public async Task WithdrawConsentAfterResponseHasStartedDoesNotDeleteCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + async context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value1"); + + await context.Response.WriteAsync("Started."); + + feature.WithdrawConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + // Doesn't throw the normal InvalidOperationException because the cookie is never written + context.Response.Cookies.Append("Test", "Value2"); + + await context.Response.WriteAsync("Withdrawn."); + }); + + var reader = new StreamReader(httpContext.Response.Body); + Assert.Equal("Started.Withdrawn.", await reader.ReadToEndAsync()); + Assert.Equal("Test=Value1; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task DeleteCookieDoesNotRequireConsent() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Delete("Test"); + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(1, cookies.Count); + var testCookie = cookies[0]; + Assert.Equal("Test", testCookie.Name); + Assert.Equal("", testCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, testCookie.SameSite); + Assert.NotNull(testCookie.Expires); + } + + [Fact] + public async Task OnDeleteCookieCanSuppressCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.OnDeleteCookie = context => + { + Assert.True(context.IsConsentNeeded); + Assert.False(context.HasConsent); + Assert.True(context.IssueCookie); + context.IssueCookie = false; + }; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Delete("Test"); + return Task.CompletedTask; + }); + + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + private Task RunTestAsync(Action configureOptions, Action configureRequest, RequestDelegate handleRequest) + { + var builder = new WebHostBuilder() + .ConfigureServices(services => + { + services.Configure(configureOptions); + }) + .Configure(app => + { + app.UseCookiePolicy(); + app.Run(handleRequest); + }); + var server = new TestServer(builder); + return server.SendAsync(configureRequest); + } + } +} \ No newline at end of file From 13e2a16b319b94918e626659ead4322737f58a8d Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 28 Dec 2017 11:52:47 -0800 Subject: [PATCH 839/900] Update dependencies for CookiePolicy --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 9eca47a759..f145edd9ca 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,33 +4,33 @@
2.1.0-preview1-15626 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 3.14.1 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 3.14.2 5.2.0-preview2-41113220915 2.0.0 2.1.0-preview1-26016-05 From c67cc03b778afa28a3dafbfa7695650c4d9a70ff Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 31 Dec 2017 21:58:42 +0000 Subject: [PATCH 840/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index f145edd9ca..3540fc2315 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15626 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 + 2.1.0-preview1-15651 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 3.14.2 5.2.0-preview2-41113220915 2.0.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 8d52a6128c..7c2e97aa79 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15626 -commithash:fd6410e9c90c428bc01238372303ad09cb9ec889 +version:2.1.0-preview1-15651 +commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 From e13ceb690bfe2a534fa11720d75fd87b4e07d6b0 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 29 Dec 2017 15:59:34 -0800 Subject: [PATCH 841/900] Detect remote denails for Twitter accounts --- .../TwitterHandler.cs | 6 ++++++ .../TwitterTests.cs | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index acfd765d9c..670e76f7e3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -60,6 +60,12 @@ namespace Microsoft.AspNetCore.Authentication.Twitter // REVIEW: see which of these are really errors + var denied = query["denied"]; + if (!StringValues.IsNullOrEmpty(denied)) + { + return HandleRequestResult.Fail("The user denied permissions.", properties); + } + var returnedToken = query["oauth_token"]; if (StringValues.IsNullOrEmpty(returnedToken)) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 735cb33146..2a63757b9a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -195,6 +195,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter OnRemoteFailure = context => { Assert.NotNull(context.Failure); + Assert.Equal("The user denied permissions.", context.Failure.Message); Assert.NotNull(context.Properties); Assert.Equal("testvalue", context.Properties.Items["testkey"]); context.Response.StatusCode = StatusCodes.Status406NotAcceptable; @@ -220,7 +221,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter var setCookieValue = setCookieValues.Single(); var cookie = new CookieHeaderValue(setCookieValue.Name, setCookieValue.Value); - var request = new HttpRequestMessage(HttpMethod.Get, "/signin-twitter"); + var request = new HttpRequestMessage(HttpMethod.Get, "/signin-twitter?denied=ABCDEFG"); request.Headers.Add(HeaderNames.Cookie, cookie.ToString()); var client = server.CreateClient(); var response = await client.SendAsync(request); From da066d50e062b850b92606e4ee8673586ad0df07 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 4 Jan 2018 02:05:41 +0000 Subject: [PATCH 842/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3540fc2315..cdb400f90f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 2.1.0-preview1-15651 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 3.14.2 5.2.0-preview2-41113220915 2.0.0 From 1f855f7b062a6870607a233b32a23cb65c2bee1c Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 5 Jan 2018 12:34:39 -0800 Subject: [PATCH 843/900] Implement ITrackingConsentFeature.CreateConsentCookie() #1590 --- Security.sln | 1 + .../ResponseCookiesWrapper.cs | 37 +++++++- .../CookieConsentTests.cs | 85 +++++++++++++++++++ 3 files changed, 119 insertions(+), 4 deletions(-) diff --git a/Security.sln b/Security.sln index 543b3be264..f598f34eb1 100644 --- a/Security.sln +++ b/Security.sln @@ -68,6 +68,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution build\Key.snk = build\Key.snk NuGet.config = NuGet.config build\repo.props = build\repo.props + build\sources.props = build\sources.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authorization.Policy", "src\Microsoft.AspNetCore.Authorization.Policy\Microsoft.AspNetCore.Authorization.Policy.csproj", "{58194599-F07D-47A3-9DF2-E21A22C5EF9E}" diff --git a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs index fa68a3cbea..e05cc9466f 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs @@ -82,6 +82,30 @@ namespace Microsoft.AspNetCore.CookiePolicy _hasConsent = false; } + // Note policy will be applied. We don't want to bypass policy because we want HttpOnly, Secure, etc. to apply. + public string CreateConsentCookie() + { + var key = Options.ConsentCookie.Name; + var value = ConsentValue; + var options = Options.ConsentCookie.Build(Context); + ApplyAppendPolicy(ref key, ref value, options); + + var setCookieHeaderValue = new Net.Http.Headers.SetCookieHeaderValue( + Uri.EscapeDataString(key), + Uri.EscapeDataString(value)) + { + Domain = options.Domain, + Path = options.Path, + Expires = options.Expires, + MaxAge = options.MaxAge, + Secure = options.Secure, + SameSite = (Net.Http.Headers.SameSiteMode)options.SameSite, + HttpOnly = options.HttpOnly + }; + + return setCookieHeaderValue.ToString(); + } + private bool CheckPolicyRequired() { return !CanTrack @@ -109,6 +133,14 @@ namespace Microsoft.AspNetCore.CookiePolicy throw new ArgumentNullException(nameof(options)); } + if (ApplyAppendPolicy(ref key, ref value, options)) + { + Cookies.Append(key, value, options); + } + } + + private bool ApplyAppendPolicy(ref string key, ref string value, CookieOptions options) + { var issueCookie = CanTrack || options.IsEssential; ApplyPolicy(options); if (Options.OnAppendCookie != null) @@ -126,10 +158,7 @@ namespace Microsoft.AspNetCore.CookiePolicy issueCookie = context.IssueCookie; } - if (issueCookie) - { - Cookies.Append(key, value, options); - } + return issueCookie; } public void Delete(string key) diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs index 4e62d54a26..3cd018e570 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -542,6 +542,91 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); } + [Fact] + public async Task CreateConsentCookieMatchesGrantConsentCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + var cookie = feature.CreateConsentCookie(); + context.Response.Headers["ManualCookie"] = cookie; + + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(1, cookies.Count); + var consentCookie = cookies[0]; + Assert.Equal(".AspNet.Consent", consentCookie.Name); + Assert.Equal("yes", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + + Assert.Equal(httpContext.Response.Headers[HeaderNames.SetCookie], httpContext.Response.Headers["ManualCookie"]); + } + + [Fact] + public async Task CreateConsentCookieAppliesPolicy() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.MinimumSameSitePolicy = Http.SameSiteMode.Strict; + options.OnAppendCookie = context => + { + Assert.Equal(".AspNet.Consent", context.CookieName); + Assert.Equal("yes", context.CookieValue); + Assert.Equal(Http.SameSiteMode.Strict, context.CookieOptions.SameSite); + context.CookieName += "1"; + context.CookieValue += "1"; + }; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + var cookie = feature.CreateConsentCookie(); + context.Response.Headers["ManualCookie"] = cookie; + + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(1, cookies.Count); + var consentCookie = cookies[0]; + Assert.Equal(".AspNet.Consent1", consentCookie.Name); + Assert.Equal("yes1", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Strict, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + + Assert.Equal(httpContext.Response.Headers[HeaderNames.SetCookie], httpContext.Response.Headers["ManualCookie"]); + } + private Task RunTestAsync(Action configureOptions, Action configureRequest, RequestDelegate handleRequest) { var builder = new WebHostBuilder() From 226b24060f72a7d63e6a6f8f3eaeb4dc5a909fe5 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 8 Jan 2018 09:11:13 -0800 Subject: [PATCH 844/900] Update deps --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index cdb400f90f..bf30832e18 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,36 +4,36 @@ 2.1.0-preview1-15651 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 3.14.2 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-26016-05 + 2.1.0-preview1-26102-01 15.3.0 3.0.1 3.0.1 From dde7671c06da64e4a7a290c37ed86e9a9bdd0dd7 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 8 Jan 2018 09:23:06 -0800 Subject: [PATCH 845/900] OIDC: Use IdentityModel redirect form generator #1448 --- .../OpenIdConnectHandler.cs | 44 +------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 7981cafd18..4f722323dc 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -16,7 +16,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Primitives; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; @@ -30,23 +29,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect public class OpenIdConnectHandler : RemoteAuthenticationHandler, IAuthenticationSignOutHandler { private const string NonceProperty = "N"; - private const string UriSchemeDelimiter = "://"; private const string HeaderValueEpocDate = "Thu, 01 Jan 1970 00:00:00 GMT"; - private const string InputTagFormat = @""; - private const string HtmlFormFormat = @" - - - Please wait while you're being redirected to the identity provider - - -
- {1} - -
- - -"; private static readonly RandomNumberGenerator CryptoRandom = RandomNumberGenerator.Create(); @@ -241,19 +225,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } else if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.FormPost) { - var inputs = new StringBuilder(); - foreach (var parameter in message.Parameters) - { - var name = HtmlEncoder.Encode(parameter.Key); - var value = HtmlEncoder.Encode(parameter.Value); - - var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value); - inputs.AppendLine(input); - } - - var issuer = HtmlEncoder.Encode(message.IssuerAddress); - - var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, issuer, inputs); + var content = message.BuildFormPost(); var buffer = Encoding.UTF8.GetBytes(content); Response.ContentLength = buffer.Length; @@ -422,19 +394,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect } else if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.FormPost) { - var inputs = new StringBuilder(); - foreach (var parameter in message.Parameters) - { - var name = HtmlEncoder.Encode(parameter.Key); - var value = HtmlEncoder.Encode(parameter.Value); - - var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value); - inputs.AppendLine(input); - } - - var issuer = HtmlEncoder.Encode(message.IssuerAddress); - - var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, issuer, inputs); + var content = message.BuildFormPost(); var buffer = Encoding.UTF8.GetBytes(content); Response.ContentLength = buffer.Length; From ba1eb281d135400436c52c17edc71307bc038ec0 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 16 Jan 2018 11:40:05 -0800 Subject: [PATCH 846/900] Stop logging username/token Fixes https://github.com/aspnet/Security/issues/1259 --- .../JwtBearerHandler.cs | 2 +- .../LoggingExtensions.cs | 20 +++++--------- .../DefaultAuthorizationService.cs | 26 ++----------------- .../LoggingExtensions.cs | 24 +++++++---------- 4 files changed, 20 insertions(+), 52 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index f894a97d0c..6d5c7f5f5e 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer } catch (Exception ex) { - Logger.TokenValidationFailed(token, ex); + Logger.TokenValidationFailed(ex); // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the event. if (Options.RefreshOnIssuerKeyNotFound && Options.ConfigurationManager != null diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs index 38a75fecaf..5c6ca088a8 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs @@ -7,16 +7,16 @@ namespace Microsoft.Extensions.Logging { internal static class LoggingExtensions { - private static Action _tokenValidationFailed; + private static Action _tokenValidationFailed; private static Action _tokenValidationSucceeded; private static Action _errorProcessingMessage; static LoggingExtensions() { - _tokenValidationFailed = LoggerMessage.Define( + _tokenValidationFailed = LoggerMessage.Define( eventId: 1, logLevel: LogLevel.Information, - formatString: "Failed to validate the token {Token}"); + formatString: "Failed to validate the token."); _tokenValidationSucceeded = LoggerMessage.Define( eventId: 2, logLevel: LogLevel.Information, @@ -27,19 +27,13 @@ namespace Microsoft.Extensions.Logging formatString: "Exception occurred while processing message."); } - public static void TokenValidationFailed(this ILogger logger, string token, Exception ex) - { - _tokenValidationFailed(logger, token, ex); - } + public static void TokenValidationFailed(this ILogger logger, Exception ex) + => _tokenValidationFailed(logger, ex); public static void TokenValidationSucceeded(this ILogger logger) - { - _tokenValidationSucceeded(logger, null); - } + => _tokenValidationSucceeded(logger, null); public static void ErrorProcessingMessage(this ILogger logger, Exception ex) - { - _errorProcessingMessage(logger, ex); - } + => _errorProcessingMessage(logger, ex); } } diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 9773ebbcc2..bc5d571c47 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -98,37 +98,15 @@ namespace Microsoft.AspNetCore.Authorization var result = _evaluator.Evaluate(authContext); if (result.Succeeded) { - _logger.UserAuthorizationSucceeded(GetUserNameForLogging(user)); + _logger.UserAuthorizationSucceeded(); } else { - _logger.UserAuthorizationFailed(GetUserNameForLogging(user)); + _logger.UserAuthorizationFailed(); } return result; } - private string GetUserNameForLogging(ClaimsPrincipal user) - { - var identity = user?.Identity; - if (identity != null) - { - var name = identity.Name; - if (name != null) - { - return name; - } - return GetClaimValue(identity, "sub") - ?? GetClaimValue(identity, ClaimTypes.Name) - ?? GetClaimValue(identity, ClaimTypes.NameIdentifier); - } - return null; - } - - private static string GetClaimValue(IIdentity identity, string claimsType) - { - return (identity as ClaimsIdentity)?.FindFirst(claimsType)?.Value; - } - /// /// Checks if a user meets a specific authorization policy. /// diff --git a/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs index 1d524dd74e..386df85e09 100644 --- a/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs @@ -7,29 +7,25 @@ namespace Microsoft.Extensions.Logging { internal static class LoggingExtensions { - private static Action _userAuthorizationFailed; - private static Action _userAuthorizationSucceeded; + private static Action _userAuthorizationFailed; + private static Action _userAuthorizationSucceeded; static LoggingExtensions() { - _userAuthorizationSucceeded = LoggerMessage.Define( + _userAuthorizationSucceeded = LoggerMessage.Define( eventId: 1, logLevel: LogLevel.Information, - formatString: "Authorization was successful for user: {UserName}."); - _userAuthorizationFailed = LoggerMessage.Define( + formatString: "Authorization was successful."); + _userAuthorizationFailed = LoggerMessage.Define( eventId: 2, logLevel: LogLevel.Information, - formatString: "Authorization failed for user: {UserName}."); + formatString: "Authorization failed."); } - public static void UserAuthorizationSucceeded(this ILogger logger, string userName) - { - _userAuthorizationSucceeded(logger, userName, null); - } + public static void UserAuthorizationSucceeded(this ILogger logger) + => _userAuthorizationSucceeded(logger, null); - public static void UserAuthorizationFailed(this ILogger logger, string userName) - { - _userAuthorizationFailed(logger, userName, null); - } + public static void UserAuthorizationFailed(this ILogger logger) + => _userAuthorizationFailed(logger, null); } } From c534335cb0b10b45708e2be2f94a94a86d6148a2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 23 Jan 2018 15:32:49 -0800 Subject: [PATCH 847/900] Branching for 2.1.0-preview1 --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- build/repo.props | 4 +-- build/sources.props | 4 +-- korebuild-lock.txt | 4 +-- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index bf30832e18..1aaf7a18a2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,37 +3,37 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
- 2.1.0-preview1-15651 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 + 2.1.0-preview1-15679 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 3.14.2 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-26102-01 + 2.1.0-preview1-26115-03 15.3.0 3.0.1 3.0.1 diff --git a/build/repo.props b/build/repo.props index 541470c9f4..2ab5a2ae35 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -7,7 +7,7 @@ Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index 9feff29d09..5d66393335 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,11 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7c2e97aa79..a474bc0e35 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15651 -commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 +version:2.1.0-preview1-15679 +commithash:5347461137cb45a77ddcc0b55b2478092de43338 From a940b6e3564c911dfdf96c850d78e9c785ade88e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 24 Jan 2018 15:00:29 -0800 Subject: [PATCH 848/900] Updating version to preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 5c4a7c32d1..370d5ababd 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview1 + preview2 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From ab8328abcaceb4569bd8c3c1b3177a88f19a3489 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 25 Jan 2018 15:55:46 -0800 Subject: [PATCH 849/900] Raise the CookiePolicy consent cookie lifetime to one year #1589 --- src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs | 2 +- .../CookieConsentTests.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index cc2deaa3aa..32d047297a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Builder public CookieBuilder ConsentCookie { get; set; } = new CookieBuilder() { Name = ".AspNet.Consent", - Expiration = TimeSpan.FromDays(90), + Expiration = TimeSpan.FromDays(365), IsEssential = true, }; diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs index 3cd018e570..4e35c165f4 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -221,6 +221,8 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test var consentCookie = cookies[0]; Assert.Equal(".AspNet.Consent", consentCookie.Name); Assert.Equal("yes", consentCookie.Value); + Assert.True(consentCookie.Expires.HasValue); + Assert.True(consentCookie.Expires.Value > DateTimeOffset.Now + TimeSpan.FromDays(364)); Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, consentCookie.SameSite); Assert.NotNull(consentCookie.Expires); var testCookie = cookies[1]; From 272aa16322f25f6c054598bdc06e7518ed0212fa Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 26 Jan 2018 11:46:35 -0800 Subject: [PATCH 850/900] Update JwtBearer sample error handling #1613 --- samples/JwtBearerSample/Startup.cs | 44 ++++++++++-------------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 6f2c5e2ecd..8c4a63cad6 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Runtime.ExceptionServices; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; @@ -43,33 +44,13 @@ namespace JwtBearerSample // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { - // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 - services.AddAuthentication(options => - { - options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - }).AddJwtBearer(o => - { - // You also need to update /wwwroot/app/scripts/app.js - o.Authority = Configuration["jwt:authority"]; - o.Audience = Configuration["jwt:audience"]; - o.Events = new JwtBearerEvents() + services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(o => { - OnAuthenticationFailed = c => - { - c.NoResult(); - - c.Response.StatusCode = 500; - c.Response.ContentType = "text/plain"; - if (Environment.IsDevelopment()) - { - // Debug only, in production do not share exceptions with the remote host. - return c.Response.WriteAsync(c.Exception.ToString()); - } - return c.Response.WriteAsync("An error occurred processing your authentication."); - } - }; - }); + // You also need to update /wwwroot/app/scripts/app.js + o.Authority = Configuration["oidc:authority"]; + o.Audience = Configuration["oidc:clientid"]; + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -86,13 +67,16 @@ namespace JwtBearerSample app.Use(async (context, next) => { // Use this if there are multiple authentication schemes - // var user = await context.Authentication.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme); - - var user = context.User; // We can do this because of there's only a single authentication scheme - if (user?.Identity?.IsAuthenticated ?? false) + var authResult = await context.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme); + if (authResult.Succeeded && authResult.Principal.Identity.IsAuthenticated) { await next(); } + else if (authResult.Failure != null) + { + // Rethrow, let the exception page handle it. + ExceptionDispatchInfo.Capture(authResult.Failure).Throw(); + } else { await context.ChallengeAsync(); From c729063c31d60753bc3bf08a91768a5de32e1f3d Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Tue, 30 Jan 2018 15:27:52 -0800 Subject: [PATCH 851/900] Fix flaky cookie policy tests #1629 --- .../CookieConsentTests.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs index 4e35c165f4..fffb8cc883 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -579,7 +579,13 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, consentCookie.SameSite); Assert.NotNull(consentCookie.Expires); - Assert.Equal(httpContext.Response.Headers[HeaderNames.SetCookie], httpContext.Response.Headers["ManualCookie"]); + cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers["ManualCookie"]); + Assert.Equal(1, cookies.Count); + var manualCookie = cookies[0]; + Assert.Equal(consentCookie.Name, manualCookie.Name); + Assert.Equal(consentCookie.Value, manualCookie.Value); + Assert.Equal(consentCookie.SameSite, manualCookie.SameSite); + Assert.NotNull(manualCookie.Expires); // Expires may not exactly match to the second. } [Fact] @@ -626,7 +632,13 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test Assert.Equal(Net.Http.Headers.SameSiteMode.Strict, consentCookie.SameSite); Assert.NotNull(consentCookie.Expires); - Assert.Equal(httpContext.Response.Headers[HeaderNames.SetCookie], httpContext.Response.Headers["ManualCookie"]); + cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers["ManualCookie"]); + Assert.Equal(1, cookies.Count); + var manualCookie = cookies[0]; + Assert.Equal(consentCookie.Name, manualCookie.Name); + Assert.Equal(consentCookie.Value, manualCookie.Value); + Assert.Equal(consentCookie.SameSite, manualCookie.SameSite); + Assert.NotNull(manualCookie.Expires); // Expires may not exactly match to the second. } private Task RunTestAsync(Action configureOptions, Action configureRequest, RequestDelegate handleRequest) From 088dc56f3daad861abbdd1ad665a85b99d65e848 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 31 Jan 2018 15:01:13 -0800 Subject: [PATCH 852/900] Update dependencies.props to 2.1.0-preview-28193, build tools to 2.1.0-preview1-1010 [ci skip] Scripted changes: - updated travis and appveyor.yml files to only build dev, ci, and release branches - updated dependencies.props - updated korebuild-lock.txt - updated korebuild.json to release/2.1 channel --- .appveyor.yml | 16 +++++------- .travis.yml | 24 ++++++++--------- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- korebuild.json | 4 +-- 5 files changed, 51 insertions(+), 53 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index c7b6e34316..4eea96ab69 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,19 +1,17 @@ init: - - git config --global core.autocrlf true +- git config --global core.autocrlf true branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ - - /^rel\/.*/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ build_script: - - ps: .\run.ps1 default-build +- ps: .\run.ps1 default-build clone_depth: 1 environment: global: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: off -deploy: off +test: 'off' +deploy: 'off' os: Visual Studio 2017 diff --git a/.travis.yml b/.travis.yml index 6c59666f3a..64bdbb4441 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,25 +3,25 @@ sudo: false dist: trusty env: global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 mono: none os: - - linux - - osx +- linux +- osx osx_image: xcode8.2 addons: apt: packages: - - libunwind8 + - libunwind8 branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ - - /^rel\/.*/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi +- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s + /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib + /usr/local/lib/; fi script: - - ./build.sh +- ./build.sh diff --git a/build/dependencies.props b/build/dependencies.props index 1aaf7a18a2..bd1daf187e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,37 +3,37 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15679 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 + 2.1.0-preview1-1010 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 3.14.2 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-26115-03 + 2.1.0-preview1-26122-01 15.3.0 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a474bc0e35..851bfbf203 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15679 -commithash:5347461137cb45a77ddcc0b55b2478092de43338 +version:2.1.0-preview1-1010 +commithash:75ca924dfbd673c38841025b04c4dcd93b84f56d diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } From c1171cd3ff0de71e6ce3e100059fa0115ebb8ee1 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 1 Feb 2018 04:30:48 +0000 Subject: [PATCH 853/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index bf30832e18..c5a4ece3ce 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,37 +3,37 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15651 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 + 2.1.0-preview2-15692 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 3.14.2 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-26102-01 + 2.1.0-preview2-26130-04 15.3.0 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7c2e97aa79..232cb858c2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15651 -commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 +version:2.1.0-preview2-15692 +commithash:5d9f445ce3f8492451a6f461df7e739bbed6a7f8 From c0b8be58ba0ccdb3a4cd38825c30536f60ab99ce Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 1 Feb 2018 14:40:56 -0800 Subject: [PATCH 854/900] Add scheme forwarding (authN policies) (#1625) --- .../CookieAuthenticationHandler.cs | 14 + .../OpenIdConnectHandler.cs | 7 + .../AuthenticationHandler.cs | 30 ++ .../AuthenticationSchemeOptions.cs | 53 +++ .../CookieTests.cs | 412 ++++++++++++++++- .../FacebookTests.cs | 397 ++++++++++++++++ .../GoogleTests.cs | 409 ++++++++++++++++- .../JwtBearerTests.cs | 399 ++++++++++++++++- .../MicrosoftAccountTests.cs | 395 ++++++++++++++++ .../OAuthTests.cs | 422 +++++++++++++++++- .../OpenIdConnectConfigurationTests.cs | 418 +++++++++++++++++ .../TestHandlers.cs | 115 +++++ .../TwitterTests.cs | 396 ++++++++++++++++ 13 files changed, 3441 insertions(+), 26 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 5d0afba46b..9a2fbfbc74 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -240,6 +240,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies throw new ArgumentNullException(nameof(user)); } + var target = ResolveTarget(Options.ForwardSignIn); + if (target != null) + { + await Context.SignInAsync(target, user, properties); + return; + } + properties = properties ?? new AuthenticationProperties(); _signInCalled = true; @@ -322,6 +329,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies public async virtual Task SignOutAsync(AuthenticationProperties properties) { + var target = ResolveTarget(Options.ForwardSignOut); + if (target != null) + { + await Context.SignOutAsync(target, properties); + return; + } + properties = properties ?? new AuthenticationProperties(); _signOutCalled = true; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 4f722323dc..ce7494fb4a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -155,6 +155,13 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// A task executing the sign out procedure public async virtual Task SignOutAsync(AuthenticationProperties properties) { + var target = ResolveTarget(Options.ForwardSignOut); + if (target != null) + { + await Context.SignOutAsync(target, properties); + return; + } + properties = properties ?? new AuthenticationProperties(); Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index ef4292100a..4399ce5f74 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -118,8 +118,24 @@ namespace Microsoft.AspNetCore.Authentication protected string BuildRedirectUri(string targetPath) => Request.Scheme + "://" + Request.Host + OriginalPathBase + targetPath; + protected virtual string ResolveTarget(string scheme) + { + var target = scheme ?? Options.ForwardDefaultSelector?.Invoke(Context) ?? Options.ForwardDefault; + + // Prevent self targetting + return string.Equals(target, Scheme.Name, StringComparison.Ordinal) + ? null + : target; + } + public async Task AuthenticateAsync() { + var target = ResolveTarget(Options.ForwardAuthenticate); + if (target != null) + { + return await Context.AuthenticateAsync(target); + } + // Calling Authenticate more than once should always return the original value. var result = await HandleAuthenticateOnceAsync(); if (result?.Failure == null) @@ -200,6 +216,13 @@ namespace Microsoft.AspNetCore.Authentication public async Task ChallengeAsync(AuthenticationProperties properties) { + var target = ResolveTarget(Options.ForwardChallenge); + if (target != null) + { + await Context.ChallengeAsync(target, properties); + return; + } + properties = properties ?? new AuthenticationProperties(); await HandleChallengeAsync(properties); Logger.AuthenticationSchemeChallenged(Scheme.Name); @@ -207,6 +230,13 @@ namespace Microsoft.AspNetCore.Authentication public async Task ForbidAsync(AuthenticationProperties properties) { + var target = ResolveTarget(Options.ForwardForbid); + if (target != null) + { + await Context.ForbidAsync(target, properties); + return; + } + properties = properties ?? new AuthenticationProperties(); await HandleForbiddenAsync(properties); Logger.AuthenticationSchemeForbidden(Scheme.Name); diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs index 18d4c97881..a547d203b4 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication { @@ -36,5 +37,57 @@ namespace Microsoft.AspNetCore.Authentication /// If set, will be used as the service type to get the Events instance instead of the property. ///
public Type EventsType { get; set; } + + /// + /// If set, this specifies a default scheme that authentication handlers should forward all authentication operations to + /// by default. The default forwarding logic will check the most specific ForwardAuthenticate/Challenge/Forbid/SignIn/SignOut + /// setting first, followed by checking the ForwardDefaultSelector, followed by ForwardDefault. The first non null result + /// will be used as the target scheme to forward to. + /// + public string ForwardDefault { get; set; } + + /// + /// If set, this specifies the target scheme that this scheme should forward AuthenticateAsync calls to. + /// For example Context.AuthenticateAsync("ThisScheme") => Context.AuthenticateAsync("ForwardAuthenticateValue"); + /// Set the target to the current scheme to disable forwarding and allow normal processing. + /// + public string ForwardAuthenticate { get; set; } + + /// + /// If set, this specifies the target scheme that this scheme should forward ChallengeAsync calls to. + /// For example Context.ChallengeAsync("ThisScheme") => Context.ChallengeAsync("ForwardChallengeValue"); + /// Set the target to the current scheme to disable forwarding and allow normal processing. + /// + public string ForwardChallenge { get; set; } + + /// + /// If set, this specifies the target scheme that this scheme should forward ForbidAsync calls to. + /// For example Context.ForbidAsync("ThisScheme") => Context.ForbidAsync("ForwardForbidValue"); + /// Set the target to the current scheme to disable forwarding and allow normal processing. + /// + public string ForwardForbid { get; set; } + + /// + /// If set, this specifies the target scheme that this scheme should forward SignInAsync calls to. + /// For example Context.SignInAsync("ThisScheme") => Context.SignInAsync("ForwardSignInValue"); + /// Set the target to the current scheme to disable forwarding and allow normal processing. + /// + public string ForwardSignIn { get; set; } + + /// + /// If set, this specifies the target scheme that this scheme should forward SignOutAsync calls to. + /// For example Context.SignOutAsync("ThisScheme") => Context.SignInAsync("ForwardSignOutValue"); + /// Set the target to the current scheme to disable forwarding and allow normal processing. + /// + public string ForwardSignOut { get; set; } + + /// + /// Used to select a default scheme for the current request that authentication handlers should forward all authentication operations to + /// by default. The default forwarding logic will check the most specific ForwardAuthenticate/Challenge/Forbid/SignIn/SignOut + /// setting first, followed by checking the ForwardDefaultSelector, followed by ForwardDefault. The first non null result + /// will be used as the target scheme to forward to. + /// + public Func ForwardDefaultSelector { get; set; } + } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 789f5ede9c..b2726bac8c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Diagnostics; using System.Linq; using System.Net; using System.Net.Http; @@ -11,6 +10,7 @@ using System.Security.Principal; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; @@ -26,6 +26,416 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { private TestClock _clock = new TestClock(); + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddCookie(o => o.ForwardDefault = "auth1"); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, forwardDefault.SignInCount); + } + + [Fact] + public async Task ForwardSignInWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardSignIn = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, specific.SignInCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignOutCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSignOutWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, selector.SignOutCount); + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, selector.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, forwardDefault.SignInCount); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 2314b6b3c9..684482ed5b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -5,11 +5,13 @@ using System; using System.Linq; using System.Net; using System.Net.Http; +using System.Security.Claims; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; @@ -24,6 +26,401 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { public class FacebookTests { + private void ConfigureDefaults(FacebookOptions o) + { + o.AppId = "whatever"; + o.AppSecret = "whatever"; + o.SignInScheme = "auth1"; + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySignInSchemeCannotBeSetToSelf() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 944a4827c3..8bfbaacde8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -10,6 +10,7 @@ using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; @@ -24,6 +25,401 @@ namespace Microsoft.AspNetCore.Authentication.Google { public class GoogleTests { + private void ConfigureDefaults(GoogleOptions o) + { + o.ClientId = "whatever"; + o.ClientSecret = "whatever"; + o.SignInScheme = "auth1"; + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySignInSchemeCannotBeSetToSelf() { @@ -1061,18 +1457,13 @@ namespace Microsoft.AspNetCore.Authentication.Google .ConfigureServices(services => { services.AddTransient(); - services.AddAuthentication("Auth") - .AddVirtualScheme("Auth", "Auth", o => - { - o.Default = TestExtensions.CookieAuthenticationScheme; - o.Challenge = GoogleDefaults.AuthenticationScheme; - }) - .AddCookie(TestExtensions.CookieAuthenticationScheme) + services.AddAuthentication(TestExtensions.CookieAuthenticationScheme) + .AddCookie(TestExtensions.CookieAuthenticationScheme, o => o.ForwardChallenge = GoogleDefaults.AuthenticationScheme) .AddGoogle(configureOptions) .AddFacebook(o => { - o.AppId = "Test AppId"; - o.AppSecret = "Test AppSecrent"; + o.ClientId = "Test ClientId"; + o.ClientSecret = "Test AppSecrent"; }); }); return new TestServer(builder); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 97adb21054..b472a4162d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; @@ -11,14 +10,13 @@ using System.Security.Claims; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; using Xunit; @@ -26,6 +24,401 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class JwtBearerTests { + private void ConfigureDefaults(JwtBearerOptions o) + { + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index b2854e344e..480241d35b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -27,6 +27,401 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { public class MicrosoftAccountTests { + private void ConfigureDefaults(MicrosoftAccountOptions o) + { + o.ClientId = "whatever"; + o.ClientSecret = "whatever"; + o.SignInScheme = "auth1"; + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySignInSchemeCannotBeSetToSelf() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 65d865b941..9279f145b9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -4,20 +4,416 @@ using System; using System.Collections.Generic; using System.Net; +using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.OAuth { public class OAuthTests { + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.SignInScheme = "auth1"; + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.SignInScheme = "auth1"; + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.SignInScheme = "auth1"; + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + + [Fact] public async Task VerifySignInSchemeCannotBeSetToSelf() { @@ -131,12 +527,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth "Weblie", opt => { - opt.ClientId = "Test Id"; - opt.ClientSecret = "secret"; - opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; - opt.AuthorizationEndpoint = "https://example.com/provider/login"; - opt.TokenEndpoint = "https://example.com/provider/token"; - opt.CallbackPath = "/oauth-callback"; + ConfigureDefaults(opt); }), async ctx => { @@ -162,12 +553,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth "Weblie", opt => { - opt.ClientId = "Test Id"; - opt.ClientSecret = "secret"; - opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; - opt.AuthorizationEndpoint = "https://example.com/provider/login"; - opt.TokenEndpoint = "https://example.com/provider/token"; - opt.CallbackPath = "/oauth-callback"; + ConfigureDefaults(opt); opt.CorrelationCookie.Path = "/"; }), async ctx => @@ -186,6 +572,16 @@ namespace Microsoft.AspNetCore.Authentication.OAuth Assert.Contains("path=/", correlation); } + private void ConfigureDefaults(OAuthOptions o) + { + o.ClientId = "Test Id"; + o.ClientSecret = "secret"; + o.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AuthorizationEndpoint = "https://example.com/provider/login"; + o.TokenEndpoint = "https://example.com/provider/token"; + o.CallbackPath = "/oauth-callback"; + } + [Fact] public async Task RemoteAuthenticationFailed_OAuthError_IncludesProperties() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 69ba758292..ed368c1ef7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -3,10 +3,13 @@ using System; using System.Net; +using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -15,6 +18,421 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { public class OpenIdConnectConfigurationTests { + private void ConfigureDefaults(OpenIdConnectOptions o) + { + o.Authority = TestServerBuilder.DefaultAuthority; + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.SignInScheme = "auth1"; + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, selector.SignOutCount); + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task MetadataAddressIsGeneratedFromAuthorityWhenMissing() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs b/test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs new file mode 100644 index 0000000000..cd9fe9fb1a --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs @@ -0,0 +1,115 @@ +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. + +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.Tests +{ + public class TestAuthHandler : AuthenticationHandler, IAuthenticationSignInHandler + { + public TestAuthHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { } + + public int SignInCount { get; set; } + public int SignOutCount { get; set; } + public int ForbidCount { get; set; } + public int ChallengeCount { get; set; } + public int AuthenticateCount { get; set; } + + protected override Task HandleChallengeAsync(AuthenticationProperties properties) + { + ChallengeCount++; + return Task.CompletedTask; + } + + protected override Task HandleForbiddenAsync(AuthenticationProperties properties) + { + ForbidCount++; + return Task.CompletedTask; + } + + protected override Task HandleAuthenticateAsync() + { + AuthenticateCount++; + var principal = new ClaimsPrincipal(); + var id = new ClaimsIdentity(); + id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + principal.AddIdentity(id); + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); + } + + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + { + SignInCount++; + return Task.CompletedTask; + } + + public Task SignOutAsync(AuthenticationProperties properties) + { + SignOutCount++; + return Task.CompletedTask; + } + } + + public class TestHandler : IAuthenticationSignInHandler + { + public AuthenticationScheme Scheme { get; set; } + public int SignInCount { get; set; } + public int SignOutCount { get; set; } + public int ForbidCount { get; set; } + public int ChallengeCount { get; set; } + public int AuthenticateCount { get; set; } + + public Task AuthenticateAsync() + { + AuthenticateCount++; + var principal = new ClaimsPrincipal(); + var id = new ClaimsIdentity(); + id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + principal.AddIdentity(id); + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); + } + + public Task ChallengeAsync(AuthenticationProperties properties) + { + ChallengeCount++; + return Task.CompletedTask; + } + + public Task ForbidAsync(AuthenticationProperties properties) + { + ForbidCount++; + return Task.CompletedTask; + } + + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + Scheme = scheme; + return Task.CompletedTask; + } + + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + { + SignInCount++; + return Task.CompletedTask; + } + + public Task SignOutAsync(AuthenticationProperties properties) + { + SignOutCount++; + return Task.CompletedTask; + } + } + + public class TestHandler2 : TestHandler + { + } + + public class TestHandler3 : TestHandler + { + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 2a63757b9a..c1937d136c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -7,6 +7,7 @@ using System.Net.Http; using System.Security.Claims; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -19,6 +20,401 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { public class TwitterTests { + private void ConfigureDefaults(TwitterOptions o) + { + o.ConsumerKey = "whatever"; + o.ConsumerSecret = "whatever"; + o.SignInScheme = "auth1"; + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySignInSchemeCannotBeSetToSelf() { From 29ed4ce9f64b6df26706f7e431ff815573004a49 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sat, 3 Feb 2018 03:03:01 +0000 Subject: [PATCH 855/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c5a4ece3ce..b3ced86881 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15692 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 + 2.1.0-preview2-15694 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 3.14.2 5.2.0-preview2-41113220915 2.0.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 232cb858c2..6f294ef0e6 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15692 -commithash:5d9f445ce3f8492451a6f461df7e739bbed6a7f8 +version:2.1.0-preview2-15694 +commithash:f61af02b48e89592c9aadb7ebaebe84228666c3b From 59c7cd0efe33687dcdc4f7701933b85dd89a340c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 9 Feb 2018 12:00:17 -0800 Subject: [PATCH 856/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index b3ced86881..140d9ddbc2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,35 +3,35 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15694 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 + 2.1.0-preview2-15698 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 3.14.2 - 5.2.0-preview2-41113220915 + 5.2.0 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 6f294ef0e6..3e2b56b91b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15694 -commithash:f61af02b48e89592c9aadb7ebaebe84228666c3b +version:2.1.0-preview2-15698 +commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 From 5de25bb11cfb2bf60d05ea2be36e80d86b38d18b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 11 Feb 2018 12:40:54 -0800 Subject: [PATCH 857/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 140d9ddbc2..7fcf154c23 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 2.1.0-preview2-15698 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 3.14.2 5.2.0 2.0.0 @@ -41,7 +41,7 @@ 10.0.1 0.8.0 2.3.1 - 2.3.1 + 2.4.0-beta.1.build3945 From f201a2b1708eda884f0b7309b89f18a07bc5fe89 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 18 Feb 2018 12:31:34 -0800 Subject: [PATCH 858/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7fcf154c23..4edb3917cf 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15698 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 + 2.1.0-preview2-15707 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 3.14.2 5.2.0 2.0.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3e2b56b91b..89d0ad3d15 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15698 -commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 +version:2.1.0-preview2-15707 +commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 From dda0921c0a2e3e341bbab2bcc083a2604aa6cc8e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 21 Feb 2018 18:27:13 -0800 Subject: [PATCH 859/900] Use FeatureBranchVersionSuffix when generating VersionSuffix --- version.props | 1 + 1 file changed, 1 insertion(+) diff --git a/version.props b/version.props index 370d5ababd..65c8a07e37 100644 --- a/version.props +++ b/version.props @@ -5,6 +5,7 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 + $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) From 2b1dab2efed9d3ba74fa082d9f01ccbd1d05bd43 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 26 Feb 2018 11:15:31 -0800 Subject: [PATCH 860/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4edb3917cf..ca0ede407e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15707 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 + 2.1.0-preview2-15721 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 3.14.2 5.2.0 2.0.0 2.1.0-preview2-26130-04 - 15.3.0 + 15.6.0 3.0.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 89d0ad3d15..e6c7fddffa 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15707 -commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 +version:2.1.0-preview2-15721 +commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 From d95109c96d6b92d04178dea004583796824072da Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Tue, 12 Sep 2017 16:28:07 -0700 Subject: [PATCH 861/900] #43 Add Microsoft.AspNetCore.Authentication.WsFederation, samples, and tests. #1443 Block unsolicited wsfed logins by default. #1520 Update WsFed to use the 2.0 event structure #1425 Implement WsFed remote signout cleanup Rework WsFed RemoteSignOutPath logic to work with ADFS #1581 Update versions, dependencies. --- Security.sln | 40 +- build/dependencies.props | 2 + samples/WsFedSample/Program.cs | 64 +++ .../Properties/launchSettings.json | 28 ++ samples/WsFedSample/Startup.cs | 168 +++++++ samples/WsFedSample/WsFedSample.csproj | 27 ++ .../WsFedSample/compiler/resources/cert.pfx | Bin 0 -> 2483 bytes .../Events/AuthenticationFailedContext.cs | 35 ++ .../Events/MessageReceivedContext.cs | 33 ++ .../Events/RedirectContext.cs | 44 ++ .../Events/RemoteSignoutContext.cs | 30 ++ .../Events/SecurityTokenReceivedContext.cs | 28 ++ .../Events/SecurityTokenValidatedContext.cs | 34 ++ .../Events/WsFederationEvents.cs | 74 +++ .../LoggingExtensions.cs | 85 ++++ ...NetCore.Authentication.WsFederation.csproj | 17 + .../Properties/Resources.Designer.cs | 114 +++++ .../Resources.resx | 138 ++++++ .../WsFederationDefaults.cs | 26 + .../WsFederationExtensions.cs | 58 +++ .../WsFederationHandler.cs | 425 +++++++++++++++++ .../WsFederationOptions.cs | 180 +++++++ .../WsFederationPostConfigureOptions.cs | 89 ++++ ...soft.AspNetCore.Authentication.Test.csproj | 19 + .../WsFederation/CustomStateDataFormat.cs | 58 +++ .../WsFederation/InvalidToken.xml | 83 ++++ .../WsFederation/TestSecurityToken.cs | 27 ++ .../TestSecurityTokenValidator.cs | 31 ++ .../WsFederation/ValidToken.xml | 83 ++++ .../WsFederation/WsFederationTest.cs | 443 ++++++++++++++++++ .../WsFederation/federationmetadata.xml | 132 ++++++ 31 files changed, 2614 insertions(+), 1 deletion(-) create mode 100644 samples/WsFedSample/Program.cs create mode 100644 samples/WsFedSample/Properties/launchSettings.json create mode 100644 samples/WsFedSample/Startup.cs create mode 100644 samples/WsFedSample/WsFedSample.csproj create mode 100644 samples/WsFedSample/compiler/resources/cert.pfx create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml diff --git a/Security.sln b/Security.sln index f598f34eb1..3df759651b 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27004.2002 +VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" ProjectSection(SolutionItems) = preProject @@ -75,6 +75,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Author EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookiePolicySample", "samples\CookiePolicySample\CookiePolicySample.csproj", "{24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.WsFederation", "src\Microsoft.AspNetCore.Authentication.WsFederation\Microsoft.AspNetCore.Authentication.WsFederation.csproj", "{B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WsFedSample", "samples\WsFedSample\WsFedSample.csproj", "{5EC2E398-E46A-430D-8E4B-E91C8FC3E800}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -481,6 +485,38 @@ Global {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x64.Build.0 = Release|Any CPU {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x86.ActiveCfg = Release|Any CPU {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x86.Build.0 = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|x64.ActiveCfg = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|x64.Build.0 = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|x86.ActiveCfg = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|x86.Build.0 = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|Any CPU.Build.0 = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|x64.ActiveCfg = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|x64.Build.0 = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|x86.ActiveCfg = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|x86.Build.0 = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|x64.ActiveCfg = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|x64.Build.0 = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|x86.ActiveCfg = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|x86.Build.0 = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|Any CPU.Build.0 = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x64.ActiveCfg = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x64.Build.0 = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x86.ActiveCfg = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -511,6 +547,8 @@ Global {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {58194599-F07D-47A3-9DF2-E21A22C5EF9E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {ABF8089E-43D0-4010-84A7-7A9DCFE49357} diff --git a/build/dependencies.props b/build/dependencies.props index ca0ede407e..4ccaf4fcbc 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -32,6 +32,7 @@ 2.1.0-preview2-30187 3.14.2 5.2.0 + 5.2.0 2.0.0 2.1.0-preview2-26130-04 15.6.0 @@ -39,6 +40,7 @@ 3.0.1 3.0.1 10.0.1 + 5.2.0 0.8.0 2.3.1 2.4.0-beta.1.build3945 diff --git a/samples/WsFedSample/Program.cs b/samples/WsFedSample/Program.cs new file mode 100644 index 0000000000..40e1945c69 --- /dev/null +++ b/samples/WsFedSample/Program.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Reflection; +using System.Security.Cryptography.X509Certificates; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Logging; + +namespace WsFedSample +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddDebug(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + factory.AddFilter("Debug", level => level >= LogLevel.Information); + }) + .UseKestrel(options => + { + options.Listen(IPAddress.Loopback, 44307, listenOptions => + { + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); + }) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + + private static X509Certificate2 LoadCertificate() + { + var assembly = typeof(Startup).GetTypeInfo().Assembly; + var embeddedFileProvider = new EmbeddedFileProvider(assembly, "WsFedSample"); + var certificateFileInfo = embeddedFileProvider.GetFileInfo("compiler/resources/cert.pfx"); + using (var certificateStream = certificateFileInfo.CreateReadStream()) + { + byte[] certificatePayload; + using (var memoryStream = new MemoryStream()) + { + certificateStream.CopyTo(memoryStream); + certificatePayload = memoryStream.ToArray(); + } + + return new X509Certificate2(certificatePayload, "testPassword"); + } + } + } +} diff --git a/samples/WsFedSample/Properties/launchSettings.json b/samples/WsFedSample/Properties/launchSettings.json new file mode 100644 index 0000000000..bdf80e2481 --- /dev/null +++ b/samples/WsFedSample/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "https://localhost:44307/", + "sslPort": 44318 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "https://localhost:44307/", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "WsFedSample": { + "commandName": "Project", + "launchBrowser": true, + "applicationUrl": "https://localhost:44307/", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/samples/WsFedSample/Startup.cs b/samples/WsFedSample/Startup.cs new file mode 100644 index 0000000000..0fc32769e9 --- /dev/null +++ b/samples/WsFedSample/Startup.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.WsFederation; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace WsFedSample +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddAuthentication(sharedOptions => + { + sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme; + }) + .AddWsFederation(options => + { + options.Wtrealm = "https://Tratcheroutlook.onmicrosoft.com/WsFedSample"; + options.MetadataAddress = "https://login.windows.net/cdc690f9-b6b8-4023-813a-bae7143d1f87/FederationMetadata/2007-06/FederationMetadata.xml"; + // options.CallbackPath = "/"; + // options.SkipUnrecognizedRequests = true; + }) + .AddCookie(); + } + + public void Configure(IApplicationBuilder app) + { + app.UseDeveloperExceptionPage(); + app.UseAuthentication(); + + app.Run(async context => + { + if (context.Request.Path.Equals("/signedout")) + { + await WriteHtmlAsync(context.Response, async res => + { + await res.WriteAsync($"

You have been signed out.

"); + await res.WriteAsync("Sign In"); + }); + return; + } + + if (context.Request.Path.Equals("/signout")) + { + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await WriteHtmlAsync(context.Response, async res => + { + await context.Response.WriteAsync($"

Signed out {HtmlEncode(context.User.Identity.Name)}

"); + await context.Response.WriteAsync("Sign In"); + }); + return; + } + + if (context.Request.Path.Equals("/signout-remote")) + { + // Redirects + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.SignOutAsync(WsFederationDefaults.AuthenticationScheme, new AuthenticationProperties() + { + RedirectUri = "/signedout" + }); + return; + } + + if (context.Request.Path.Equals("/Account/AccessDenied")) + { + await WriteHtmlAsync(context.Response, async res => + { + await context.Response.WriteAsync($"

Access Denied for user {HtmlEncode(context.User.Identity.Name)} to resource '{HtmlEncode(context.Request.Query["ReturnUrl"])}'

"); + await context.Response.WriteAsync("Sign Out"); + }); + return; + } + + // DefaultAuthenticateScheme causes User to be set + var user = context.User; + + // This is what [Authorize] calls + // var user = await context.AuthenticateAsync(); + + // This is what [Authorize(ActiveAuthenticationSchemes = WsFederationDefaults.AuthenticationScheme)] calls + // var user = await context.AuthenticateAsync(WsFederationDefaults.AuthenticationScheme); + + // Not authenticated + if (user == null || !user.Identities.Any(identity => identity.IsAuthenticated)) + { + // This is what [Authorize] calls + await context.ChallengeAsync(); + + // This is what [Authorize(ActiveAuthenticationSchemes = WsFederationDefaults.AuthenticationScheme)] calls + // await context.ChallengeAsync(WsFederationDefaults.AuthenticationScheme); + + return; + } + + // Authenticated, but not authorized + if (context.Request.Path.Equals("/restricted") && !user.Identities.Any(identity => identity.HasClaim("special", "true"))) + { + await context.ForbidAsync(); + return; + } + + await WriteHtmlAsync(context.Response, async response => + { + await response.WriteAsync($"

Hello Authenticated User {HtmlEncode(user.Identity.Name)}

"); + await response.WriteAsync("Restricted"); + await response.WriteAsync("Sign Out"); + await response.WriteAsync("Sign Out Remote"); + + await response.WriteAsync("

Claims:

"); + await WriteTableHeader(response, new string[] { "Claim Type", "Value" }, context.User.Claims.Select(c => new string[] { c.Type, c.Value })); + }); + }); + } + + private static async Task WriteHtmlAsync(HttpResponse response, Func writeContent) + { + var bootstrap = ""; + + response.ContentType = "text/html"; + await response.WriteAsync($"{bootstrap}
"); + await writeContent(response); + await response.WriteAsync("
"); + } + + private static async Task WriteTableHeader(HttpResponse response, IEnumerable columns, IEnumerable> data) + { + await response.WriteAsync(""); + await response.WriteAsync(""); + foreach (var column in columns) + { + await response.WriteAsync($""); + } + await response.WriteAsync(""); + foreach (var row in data) + { + await response.WriteAsync(""); + foreach (var column in row) + { + await response.WriteAsync($""); + } + await response.WriteAsync(""); + } + await response.WriteAsync("
{HtmlEncode(column)}
{HtmlEncode(column)}
"); + } + + private static string HtmlEncode(string content) => + string.IsNullOrEmpty(content) ? string.Empty : HtmlEncoder.Default.Encode(content); + } +} diff --git a/samples/WsFedSample/WsFedSample.csproj b/samples/WsFedSample/WsFedSample.csproj new file mode 100644 index 0000000000..bc3a59f10e --- /dev/null +++ b/samples/WsFedSample/WsFedSample.csproj @@ -0,0 +1,27 @@ + + + + net461;netcoreapp2.0 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/WsFedSample/compiler/resources/cert.pfx b/samples/WsFedSample/compiler/resources/cert.pfx new file mode 100644 index 0000000000000000000000000000000000000000..7118908c2d730670c16e9f8b2c532a262c951989 GIT binary patch literal 2483 zcmaKuc|27A8pqF>IWr86E&Q@(n=B)p$ug!;QVB6xij*z;uPLG!yCz#DQB)+9G$9m9 zQU)=DWXU?*EZIwG!+0d++P@yZ4Xhoagg?p6B~|Ue7tN=Ny=UD?x#1n1MTq z#c9MHh+D#gd|(a(cN}8i91v^=GcdgW3SmA$49p~gM-dys3jVWdg8+!iVL)pz1LDE5 zSb=|GAn(@R=(Ux!MfS9@}sFu-xDd zIt2+mqSq$glwy_6UNs<2?(qERU!gJ;5j}Pp&6trxG=wi)=@k(w2+fJVnc+qvXVzy(>Om4;L|^)R`t*3nTpAmEmTl(#i!RV#a0t#u6>Q9mY`-Nmcs7$XjXT7 zUmCD`O~_j7!%R#I?cG-7C^hcH)@l?WC1vyw$FFu_(r)jhOq6p}W8sG7NO{YTy8tG4 zrb$tTkag*G?(7lfoGx$4YWui>{{@}-FB2ub=}RX{1zx?j)s-##J9|G7E1@-;7Nuln z9MQoX7FJ76+D#XXT@ZZmLZCufIdf3@OigG6m8I7!GT=7VD|>?6e!z9=eT}*E_tSn6 zl+clHCZ-kcIR#gen#LjMJW8>0QtViaQB#FhqsCb0YPYr3;jRITl@V9Aph24D?r2d` zetCyyCg<*O-u+M& zW^ptmT|}p$VAOZpmbQ1{5fK-6ytEvre#Po}6c2URn`viQAF2+e?Z~PK2&pd>7=7)I zTCYm)@3PFRu_6a6Kb)IpCzQ%e3l%O#SDA+$Pq{Dk{HCqi7z>qd{nVpebffL7h{c4( zmhXn~G+C27S3(IfC)q2KON=YwqHXEo%zc40DgWLzF{%RIdr@RcLu90qMSHf!Y}JaqP<={8_Rfe;ddR5= zKEo;^Yip&^m((#{czE{kUga3-@`*;&EwO}Jt>QdURP2P>ob^j-A!qld-0S_pm)kjs zkNo48oZnMt){W~o8g^f;4#?lRLr-T@f}wH1o~-Iq=NEVtTVEZ`vrW~!>2yh%;Bc~H zHl&OK>n@d`*e19*9#v>zZpU?I);f7}IPIfSSk#N|ujE492Itg)l!)TJ19@FE^x|p= zH16NC7OfK&|6_!AnWfTIf^YPOa&`|nbk3VR0vql6&s@y1V3QOU%(`Re+kJgrz?r9!{^wOQ4W-eng23gc}f(LxIs zH_Ls~5izbjcRQH#WH6s6hR;zn>j_R8aJ$A)6xNneu8UI-vWV8Z@HZu&WwvG5q{1ZS zdZeVf{Pv5-u281~y;aJe*x%Uv0@biMZ$vPbKj}O`(SOWQc~kJX` zXR&d4DtAe@2RH$^ z0os5*;0eIUeJi3Uh`A%44x(XzjClG8BO~-r_A}odiRuHo2-86#`mhrgN5p~<$RLY? zq(kynfFA5{v#p+EA1 z5aoe1763EQHorRm`C&ktKn(OQ1n)$Q{GZz&jRb`eDEMpl<0O#+)DMV(T7nsIzCG{QuM->B9g7Lrl2SE&gW`M!~(un|y0fIn=b^6_$ z9{zEzgYI~39xn0ZP*9qBL%fg7rg$ttt&TOmvfNNO<6FT0ZavM$Y4CYLQGIcIYv9Y& zBGPUh&QTfW;V2!)oIra@s&d968y-y}Y|ww(R$GzWS*V&)k@W0>Slem{|HdTCjm;_5 zwY*A8W3nUbemE^_f0ng$tbd<`sr?TO-_&VCw+F#7P@LkIl$1PzTBoPY1b88EIO>UO zP-NK7+g2yD3U6g3i|iA6+su>54sf_Sk0F=)1|9odnCM4u2Rs z=&Y?-V&VquSN%3FJ2~ZGweP~iLs|w=l@9yu$tj@}Dp?e-2JUsqOoswdXb=E%&0te_ zA2M+{5Hf-dqD7=yw*r@A*xkn(1IS~nfP}k}e?4Bt|9g(eph4hFX_|S6nj1&Sz9z^= zRw~<&-9d@FzTn6S*RVE{Wj5lgLJr9HLB8S9CgOm*>XA8*y4`JE;^s$=bqD#U4;e5C&x&ggKIAVL zrQ)Yd8|{>7Z(6*B&7&4&9(*vDOfHMuR-Dk1IZia*XM^EZUD^{?cWG>J>KrtElc*{K zaVl(7SN2cH4I6Q$bZOpJ8e5LKaG7p;?tJ~#+9QrTYU@f#5`Vo7cEX!szCT}iX-K^2 w#3o+=C+lQz2J+SOEzVX(eJ)e7=eicC{rr9U2VGDcdH?_b literal 0 HcmV?d00001 diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs new file mode 100644 index 0000000000..f643fad97f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs @@ -0,0 +1,35 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// The context object used in for . + /// + public class AuthenticationFailedContext : RemoteAuthenticationContext + { + /// + /// Creates a new context object + /// + /// + /// + /// + public AuthenticationFailedContext(HttpContext context, AuthenticationScheme scheme, WsFederationOptions options) + : base(context, scheme, options, new AuthenticationProperties()) + { } + + /// + /// The from the request, if any. + /// + public WsFederationMessage ProtocolMessage { get; set; } + + /// + /// The that triggered this event. + /// + public Exception Exception { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs new file mode 100644 index 0000000000..4028fa5e3c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs @@ -0,0 +1,33 @@ +// 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.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// The context object used for . + /// + public class MessageReceivedContext : RemoteAuthenticationContext + { + /// + /// Creates a new context object. + /// + /// + /// + /// + /// + public MessageReceivedContext( + HttpContext context, + AuthenticationScheme scheme, + WsFederationOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } + + /// + /// The received on this request. + /// + public WsFederationMessage ProtocolMessage { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs new file mode 100644 index 0000000000..654037d0a8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs @@ -0,0 +1,44 @@ +// 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.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// When a user configures the to be notified prior to redirecting to an IdentityProvider + /// an instance of is passed to the 'RedirectToAuthenticationEndpoint' or 'RedirectToEndSessionEndpoint' events. + /// + public class RedirectContext : PropertiesContext + { + /// + /// Creates a new context object. + /// + /// + /// + /// + /// + public RedirectContext( + HttpContext context, + AuthenticationScheme scheme, + WsFederationOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } + + /// + /// The used to compose the redirect. + /// + public WsFederationMessage ProtocolMessage { get; set; } + + /// + /// If true, will skip any default logic for this redirect. + /// + public bool Handled { get; private set; } + + /// + /// Skips any default logic for this redirect. + /// + public void HandleResponse() => Handled = true; + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs new file mode 100644 index 0000000000..8aec24a64e --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs @@ -0,0 +1,30 @@ +// 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.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// An event context for RemoteSignOut. + /// + public class RemoteSignOutContext : RemoteAuthenticationContext + { + /// + /// + /// + /// + /// + /// + /// + public RemoteSignOutContext(HttpContext context, AuthenticationScheme scheme, WsFederationOptions options, WsFederationMessage message) + : base(context, scheme, options, new AuthenticationProperties()) + => ProtocolMessage = message; + + /// + /// The signout message. + /// + public WsFederationMessage ProtocolMessage { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs new file mode 100644 index 0000000000..311f41515f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs @@ -0,0 +1,28 @@ +// 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.Security.Claims; +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// This Context can be used to be informed when an 'AuthorizationCode' is redeemed for tokens at the token endpoint. + /// + public class SecurityTokenReceivedContext : RemoteAuthenticationContext + { + /// + /// Creates a + /// + public SecurityTokenReceivedContext(HttpContext context, AuthenticationScheme scheme, WsFederationOptions options, AuthenticationProperties properties) + : base(context, scheme, options, properties) + { + } + + /// + /// The received on this request. + /// + public WsFederationMessage ProtocolMessage { get; set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs new file mode 100644 index 0000000000..1f32014b6c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs @@ -0,0 +1,34 @@ +// 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.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; +using Microsoft.IdentityModel.Tokens; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// The context object used for . + /// + public class SecurityTokenValidatedContext : RemoteAuthenticationContext + { + /// + /// Creates a + /// + public SecurityTokenValidatedContext(HttpContext context, AuthenticationScheme scheme, WsFederationOptions options, ClaimsPrincipal principal, AuthenticationProperties properties) + : base(context, scheme, options, properties) + => Principal = principal; + + /// + /// The received on this request. + /// + public WsFederationMessage ProtocolMessage { get; set; } + + /// + /// The that was validated. + /// + public SecurityToken SecurityToken { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs new file mode 100644 index 0000000000..55c3936f9e --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs @@ -0,0 +1,74 @@ +// 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.Threading.Tasks; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// Specifies events which the invokes to enable developer control over the authentication process. /> + /// + public class WsFederationEvents : RemoteAuthenticationEvents + { + /// + /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. + /// + public Func OnAuthenticationFailed { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked when a protocol message is first received. + /// + public Func OnMessageReceived { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked to manipulate redirects to the identity provider for SignIn, SignOut, or Challenge. + /// + public Func OnRedirectToIdentityProvider { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked when a wsignoutcleanup request is received at the RemoteSignOutPath endpoint. + /// + public Func OnRemoteSignOut { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked with the security token that has been extracted from the protocol message. + /// + public Func OnSecurityTokenReceived { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. + /// + public Func OnSecurityTokenValidated { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. + /// + public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); + + /// + /// Invoked when a protocol message is first received. + /// + public virtual Task MessageReceived(MessageReceivedContext context) => OnMessageReceived(context); + + /// + /// Invoked to manipulate redirects to the identity provider for SignIn, SignOut, or Challenge. + /// + public virtual Task RedirectToIdentityProvider(RedirectContext context) => OnRedirectToIdentityProvider(context); + + /// + /// Invoked when a wsignoutcleanup request is received at the RemoteSignOutPath endpoint. + /// + public virtual Task RemoteSignOut(RemoteSignOutContext context) => OnRemoteSignOut(context); + + /// + /// Invoked with the security token that has been extracted from the protocol message. + /// + public virtual Task SecurityTokenReceived(SecurityTokenReceivedContext context) => OnSecurityTokenReceived(context); + + /// + /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. + /// + public virtual Task SecurityTokenValidated(SecurityTokenValidatedContext context) => OnSecurityTokenValidated(context); + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs new file mode 100644 index 0000000000..e28b7e15b0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs @@ -0,0 +1,85 @@ +// 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.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _signInWithoutWresult; + private static Action _signInWithoutToken; + private static Action _exceptionProcessingMessage; + private static Action _malformedRedirectUri; + private static Action _remoteSignOutHandledResponse; + private static Action _remoteSignOutSkipped; + private static Action _remoteSignOut; + + static LoggingExtensions() + { + _signInWithoutWresult = LoggerMessage.Define( + eventId: 1, + logLevel: LogLevel.Debug, + formatString: "Received a sign-in message without a WResult."); + _signInWithoutToken = LoggerMessage.Define( + eventId: 2, + logLevel: LogLevel.Debug, + formatString: "Received a sign-in message without a token."); + _exceptionProcessingMessage = LoggerMessage.Define( + eventId: 3, + logLevel: LogLevel.Error, + formatString: "Exception occurred while processing message."); + _malformedRedirectUri = LoggerMessage.Define( + eventId: 4, + logLevel: LogLevel.Warning, + formatString: "The sign-out redirect URI '{0}' is malformed."); + _remoteSignOutHandledResponse = LoggerMessage.Define( + eventId: 5, + logLevel: LogLevel.Debug, + formatString: "RemoteSignOutContext.HandledResponse"); + _remoteSignOutSkipped = LoggerMessage.Define( + eventId: 6, + logLevel: LogLevel.Debug, + formatString: "RemoteSignOutContext.Skipped"); + _remoteSignOut = LoggerMessage.Define( + eventId: 7, + logLevel: LogLevel.Information, + formatString: "Remote signout request processed."); + } + + public static void SignInWithoutWresult(this ILogger logger) + { + _signInWithoutWresult(logger, null); + } + + public static void SignInWithoutToken(this ILogger logger) + { + _signInWithoutToken(logger, null); + } + + public static void ExceptionProcessingMessage(this ILogger logger, Exception ex) + { + _exceptionProcessingMessage(logger, ex); + } + + public static void MalformedRedirectUri(this ILogger logger, string uri) + { + _malformedRedirectUri(logger, uri, null); + } + + public static void RemoteSignOutHandledResponse(this ILogger logger) + { + _remoteSignOutHandledResponse(logger, null); + } + + public static void RemoteSignOutSkipped(this ILogger logger) + { + _remoteSignOutSkipped(logger, null); + } + + public static void RemoteSignOut(this ILogger logger) + { + _remoteSignOut(logger, null); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj b/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj new file mode 100644 index 0000000000..4edb55cb35 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj @@ -0,0 +1,17 @@ + + + + ASP.NET Core middleware that enables an application to support the WsFederation authentication workflow. + netstandard2.0 + true + aspnetcore;authentication;security + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..564e826a78 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs @@ -0,0 +1,114 @@ +// +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + using System.Globalization; + using System.Reflection; + using System.Resources; + + internal static class Resources + { + private static readonly ResourceManager _resourceManager + = new ResourceManager("Microsoft.AspNetCore.Authentication.WsFederation.Resources", typeof(Resources).GetTypeInfo().Assembly); + + /// + /// The service descriptor is missing. + /// + internal static string Exception_MissingDescriptor + { + get => GetString("Exception_MissingDescriptor"); + } + + /// + /// The service descriptor is missing. + /// + internal static string FormatException_MissingDescriptor() + => GetString("Exception_MissingDescriptor"); + + /// + /// No token validator was found for the given token. + /// + internal static string Exception_NoTokenValidatorFound + { + get => GetString("Exception_NoTokenValidatorFound"); + } + + /// + /// No token validator was found for the given token. + /// + internal static string FormatException_NoTokenValidatorFound() + => GetString("Exception_NoTokenValidatorFound"); + + /// + /// The '{0}' option must be provided. + /// + internal static string Exception_OptionMustBeProvided + { + get => GetString("Exception_OptionMustBeProvided"); + } + + /// + /// The '{0}' option must be provided. + /// + internal static string FormatException_OptionMustBeProvided(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); + + /// + /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. + /// + internal static string Exception_ValidatorHandlerMismatch + { + get => GetString("Exception_ValidatorHandlerMismatch"); + } + + /// + /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. + /// + internal static string FormatException_ValidatorHandlerMismatch() + => GetString("Exception_ValidatorHandlerMismatch"); + + /// + /// The sign in message does not contain a required token. + /// + internal static string SignInMessageTokenIsMissing + { + get => GetString("SignInMessageTokenIsMissing"); + } + + /// + /// The sign in message does not contain a required token. + /// + internal static string FormatSignInMessageTokenIsMissing() + => GetString("SignInMessageTokenIsMissing"); + + /// + /// The sign in message does not contain a required wresult. + /// + internal static string SignInMessageWresultIsMissing + { + get => GetString("SignInMessageWresultIsMissing"); + } + + /// + /// The sign in message does not contain a required wresult. + /// + internal static string FormatSignInMessageWresultIsMissing() + => GetString("SignInMessageWresultIsMissing"); + + private static string GetString(string name, params string[] formatterNames) + { + var value = _resourceManager.GetString(name); + + System.Diagnostics.Debug.Assert(value != null); + + if (formatterNames != null) + { + for (var i = 0; i < formatterNames.Length; i++) + { + value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); + } + } + + return value; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx b/src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx new file mode 100644 index 0000000000..e2edafb671 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + The service descriptor is missing. + + + No token validator was found for the given token. + + + The '{0}' option must be provided. + + + An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. + + + The sign in message does not contain a required token. + + + The sign in message does not contain a required wresult. + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs new file mode 100644 index 0000000000..3b97d995b5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs @@ -0,0 +1,26 @@ +// 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.AspNetCore.Authentication.WsFederation +{ + /// + /// Default values related to WsFederation authentication handler + /// + public static class WsFederationDefaults + { + /// + /// The default authentication type used when registering the WsFederationHandler. + /// + public const string AuthenticationScheme = "WsFederation"; + + /// + /// The default display name used when registering the WsFederationHandler. + /// + public const string DisplayName = "WsFederation"; + + /// + /// Constant used to identify userstate inside AuthenticationProperties that have been serialized in the 'wctx' parameter. + /// + public static readonly string UserstatePropertiesKey = "WsFederation.Userstate"; + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs new file mode 100644 index 0000000000..47091d58d5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs @@ -0,0 +1,58 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.WsFederation; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Options; + +namespace Microsoft.Extensions.DependencyInjection +{ + /// + /// Extensions for registering the . + /// + public static class WsFederationExtensions + { + /// + /// Registers the using the default authentication scheme, display name, and options. + /// + /// + /// + public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder) + => builder.AddWsFederation(WsFederationDefaults.AuthenticationScheme, _ => { }); + + /// + /// Registers the using the default authentication scheme, display name, and the given options configuration. + /// + /// + /// A delegate that configures the . + /// + public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddWsFederation(WsFederationDefaults.AuthenticationScheme, configureOptions); + + /// + /// Registers the using the given authentication scheme, default display name, and the given options configuration. + /// + /// + /// + /// A delegate that configures the . + /// + public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddWsFederation(authenticationScheme, WsFederationDefaults.DisplayName, configureOptions); + + /// + /// Registers the using the given authentication scheme, display name, and options configuration. + /// + /// + /// + /// + /// A delegate that configures the . + /// + public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, WsFederationPostConfigureOptions>()); + return builder.AddRemoteScheme(authenticationScheme, displayName, configureOptions); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs new file mode 100644 index 0000000000..e47f8431f9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs @@ -0,0 +1,425 @@ +// 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.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Protocols.WsFederation; +using Microsoft.IdentityModel.Tokens; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// A per-request authentication handler for the WsFederation. + /// + public class WsFederationHandler : RemoteAuthenticationHandler, IAuthenticationSignOutHandler + { + private const string CorrelationProperty = ".xsrf"; + private WsFederationConfiguration _configuration; + + /// + /// Creates a new WsFederationAuthenticationHandler + /// + /// + /// + /// + /// + public WsFederationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) + { + } + + /// + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// If it is not provided a default instance is supplied which does nothing when the methods are called. + /// + protected new WsFederationEvents Events + { + get { return (WsFederationEvents)base.Events; } + set { base.Events = value; } + } + + /// + /// Creates a new instance of the events instance. + /// + /// A new instance of the events instance. + protected override Task CreateEventsAsync() => Task.FromResult(new WsFederationEvents()); + + /// + /// Overridden to handle remote signout requests + /// + /// + public override Task HandleRequestAsync() + { + // RemoteSignOutPath and CallbackPath may be the same, fall through if the message doesn't match. + if (Options.RemoteSignOutPath.HasValue && Options.RemoteSignOutPath == Request.Path && HttpMethods.IsGet(Request.Method) + && string.Equals(Request.Query[WsFederationConstants.WsFederationParameterNames.Wa], + WsFederationConstants.WsFederationActions.SignOutCleanup, StringComparison.OrdinalIgnoreCase)) + { + // We've received a remote sign-out request + return HandleRemoteSignOutAsync(); + } + + return base.HandleRequestAsync(); + } + + /// + /// Handles Challenge + /// + /// + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) + { + if (_configuration == null) + { + _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); + } + + // Save the original challenge URI so we can redirect back to it when we're done. + if (string.IsNullOrEmpty(properties.RedirectUri)) + { + properties.RedirectUri = CurrentUri; + } + + var wsFederationMessage = new WsFederationMessage() + { + IssuerAddress = _configuration.TokenEndpoint ?? string.Empty, + Wtrealm = Options.Wtrealm, + Wa = WsFederationConstants.WsFederationActions.SignIn, + }; + + if (!string.IsNullOrEmpty(Options.Wreply)) + { + wsFederationMessage.Wreply = Options.Wreply; + } + else + { + wsFederationMessage.Wreply = BuildRedirectUri(Options.CallbackPath); + } + + GenerateCorrelationId(properties); + + var redirectContext = new RedirectContext(Context, Scheme, Options, properties) + { + ProtocolMessage = wsFederationMessage + }; + await Events.RedirectToIdentityProvider(redirectContext); + + if (redirectContext.Handled) + { + return; + } + + wsFederationMessage = redirectContext.ProtocolMessage; + + if (!string.IsNullOrEmpty(wsFederationMessage.Wctx)) + { + properties.Items[WsFederationDefaults.UserstatePropertiesKey] = wsFederationMessage.Wctx; + } + + wsFederationMessage.Wctx = Uri.EscapeDataString(Options.StateDataFormat.Protect(properties)); + + var redirectUri = wsFederationMessage.CreateSignInUrl(); + if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) + { + Logger.MalformedRedirectUri(redirectUri); + } + Response.Redirect(redirectUri); + } + + /// + /// Invoked to process incoming authentication messages. + /// + /// + protected override async Task HandleRemoteAuthenticateAsync() + { + WsFederationMessage wsFederationMessage = null; + AuthenticationProperties properties = null; + + // assumption: if the ContentType is "application/x-www-form-urlencoded" it should be safe to read as it is small. + if (HttpMethods.IsPost(Request.Method) + && !string.IsNullOrEmpty(Request.ContentType) + // May have media/type; charset=utf-8, allow partial match. + && Request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase) + && Request.Body.CanRead) + { + var form = await Request.ReadFormAsync(); + + wsFederationMessage = new WsFederationMessage(form.Select(pair => new KeyValuePair(pair.Key, pair.Value))); + } + + if (wsFederationMessage == null || !wsFederationMessage.IsSignInMessage) + { + if (Options.SkipUnrecognizedRequests) + { + // Not for us? + return HandleRequestResult.SkipHandler(); + } + + return HandleRequestResult.Fail("No message."); + } + + try + { + // Retrieve our cached redirect uri + var state = wsFederationMessage.Wctx; + // WsFed allows for uninitiated logins, state may be missing. See AllowUnsolicitedLogins. + properties = Options.StateDataFormat.Unprotect(state); + + if (properties == null) + { + if (!Options.AllowUnsolicitedLogins) + { + return HandleRequestResult.Fail("Unsolicited logins are not allowed."); + } + } + else + { + // Extract the user state from properties and reset. + properties.Items.TryGetValue(WsFederationDefaults.UserstatePropertiesKey, out var userState); + wsFederationMessage.Wctx = userState; + } + + var messageReceivedContext = new MessageReceivedContext(Context, Scheme, Options, properties) + { + ProtocolMessage = wsFederationMessage + }; + await Events.MessageReceived(messageReceivedContext); + if (messageReceivedContext.Result != null) + { + return messageReceivedContext.Result; + } + wsFederationMessage = messageReceivedContext.ProtocolMessage; + properties = messageReceivedContext.Properties; // Provides a new instance if not set. + + // If state did flow from the challenge then validate it. See AllowUnsolicitedLogins above. + if (properties.Items.TryGetValue(CorrelationProperty, out string correlationId) + && !ValidateCorrelationId(properties)) + { + return HandleRequestResult.Fail("Correlation failed.", properties); + } + + if (wsFederationMessage.Wresult == null) + { + Logger.SignInWithoutWresult(); + return HandleRequestResult.Fail(Resources.SignInMessageWresultIsMissing, properties); + } + + var token = wsFederationMessage.GetToken(); + if (string.IsNullOrEmpty(token)) + { + Logger.SignInWithoutToken(); + return HandleRequestResult.Fail(Resources.SignInMessageTokenIsMissing, properties); + } + + var securityTokenReceivedContext = new SecurityTokenReceivedContext(Context, Scheme, Options, properties) + { + ProtocolMessage = wsFederationMessage + }; + await Events.SecurityTokenReceived(securityTokenReceivedContext); + if (securityTokenReceivedContext.Result != null) + { + return securityTokenReceivedContext.Result; + } + wsFederationMessage = securityTokenReceivedContext.ProtocolMessage; + properties = messageReceivedContext.Properties; + + if (_configuration == null) + { + _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); + } + + // Copy and augment to avoid cross request race conditions for updated configurations. + var tvp = Options.TokenValidationParameters.Clone(); + var issuers = new[] { _configuration.Issuer }; + tvp.ValidIssuers = (tvp.ValidIssuers == null ? issuers : tvp.ValidIssuers.Concat(issuers)); + tvp.IssuerSigningKeys = (tvp.IssuerSigningKeys == null ? _configuration.SigningKeys : tvp.IssuerSigningKeys.Concat(_configuration.SigningKeys)); + + ClaimsPrincipal principal = null; + SecurityToken parsedToken = null; + foreach (var validator in Options.SecurityTokenHandlers) + { + if (validator.CanReadToken(token)) + { + principal = validator.ValidateToken(token, tvp, out parsedToken); + break; + } + } + + if (principal == null) + { + throw new SecurityTokenException(Resources.Exception_NoTokenValidatorFound); + } + + if (Options.UseTokenLifetime && parsedToken != null) + { + // Override any session persistence to match the token lifetime. + var issued = parsedToken.ValidFrom; + if (issued != DateTime.MinValue) + { + properties.IssuedUtc = issued.ToUniversalTime(); + } + var expires = parsedToken.ValidTo; + if (expires != DateTime.MinValue) + { + properties.ExpiresUtc = expires.ToUniversalTime(); + } + properties.AllowRefresh = false; + } + + var securityTokenValidatedContext = new SecurityTokenValidatedContext(Context, Scheme, Options, principal, properties) + { + ProtocolMessage = wsFederationMessage, + SecurityToken = parsedToken, + }; + + await Events.SecurityTokenValidated(securityTokenValidatedContext); + if (securityTokenValidatedContext.Result != null) + { + return securityTokenValidatedContext.Result; + } + + // Flow possible changes + principal = securityTokenValidatedContext.Principal; + properties = securityTokenValidatedContext.Properties; + + return HandleRequestResult.Success(new AuthenticationTicket(principal, properties, Scheme.Name)); + } + catch (Exception exception) + { + Logger.ExceptionProcessingMessage(exception); + + // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the notification. + if (Options.RefreshOnIssuerKeyNotFound && exception.GetType().Equals(typeof(SecurityTokenSignatureKeyNotFoundException))) + { + Options.ConfigurationManager.RequestRefresh(); + } + + var authenticationFailedContext = new AuthenticationFailedContext(Context, Scheme, Options) + { + ProtocolMessage = wsFederationMessage, + Exception = exception + }; + await Events.AuthenticationFailed(authenticationFailedContext); + if (authenticationFailedContext.Result != null) + { + return authenticationFailedContext.Result; + } + + return HandleRequestResult.Fail(exception, properties); + } + } + + /// + /// Handles Signout + /// + /// + public async virtual Task SignOutAsync(AuthenticationProperties properties) + { + var target = ResolveTarget(Options.ForwardSignOut); + if (target != null) + { + await Context.SignOutAsync(target, properties); + return; + } + + if (_configuration == null) + { + _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); + } + + var wsFederationMessage = new WsFederationMessage() + { + IssuerAddress = _configuration.TokenEndpoint ?? string.Empty, + Wtrealm = Options.Wtrealm, + Wa = WsFederationConstants.WsFederationActions.SignOut, + }; + + // Set Wreply in order: + // 1. properties.Redirect + // 2. Options.SignOutWreply + // 3. Options.Wreply + if (properties != null && !string.IsNullOrEmpty(properties.RedirectUri)) + { + wsFederationMessage.Wreply = BuildRedirectUriIfRelative(properties.RedirectUri); + } + else if (!string.IsNullOrEmpty(Options.SignOutWreply)) + { + wsFederationMessage.Wreply = BuildRedirectUriIfRelative(Options.SignOutWreply); + } + else if (!string.IsNullOrEmpty(Options.Wreply)) + { + wsFederationMessage.Wreply = BuildRedirectUriIfRelative(Options.Wreply); + } + + var redirectContext = new RedirectContext(Context, Scheme, Options, properties) + { + ProtocolMessage = wsFederationMessage + }; + await Events.RedirectToIdentityProvider(redirectContext); + + if (!redirectContext.Handled) + { + var redirectUri = redirectContext.ProtocolMessage.CreateSignOutUrl(); + if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) + { + Logger.MalformedRedirectUri(redirectUri); + } + Response.Redirect(redirectUri); + } + } + + /// + /// Handles wsignoutcleanup1.0 messages sent to the RemoteSignOutPath + /// + /// + protected virtual async Task HandleRemoteSignOutAsync() + { + var message = new WsFederationMessage(Request.Query.Select(pair => new KeyValuePair(pair.Key, pair.Value))); + var remoteSignOutContext = new RemoteSignOutContext(Context, Scheme, Options, message); + await Events.RemoteSignOut(remoteSignOutContext); + + if (remoteSignOutContext.Result != null) + { + if (remoteSignOutContext.Result.Handled) + { + Logger.RemoteSignOutHandledResponse(); + return true; + } + if (remoteSignOutContext.Result.Skipped) + { + Logger.RemoteSignOutSkipped(); + return false; + } + } + + Logger.RemoteSignOut(); + + await Context.SignOutAsync(Options.SignOutScheme); + return true; + } + + /// + /// Build a redirect path if the given path is a relative path. + /// + private string BuildRedirectUriIfRelative(string uri) + { + if (string.IsNullOrEmpty(uri)) + { + return uri; + } + + if (!uri.StartsWith("/", StringComparison.Ordinal)) + { + return uri; + } + + return BuildRedirectUri(uri); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs new file mode 100644 index 0000000000..4e06126773 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs @@ -0,0 +1,180 @@ +// 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.Collections.Generic; +using System.Collections.ObjectModel; +using System.IdentityModel.Tokens.Jwt; +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.WsFederation; +using Microsoft.IdentityModel.Tokens; +using Microsoft.IdentityModel.Tokens.Saml; +using Microsoft.IdentityModel.Tokens.Saml2; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// Configuration options for + /// + public class WsFederationOptions : RemoteAuthenticationOptions + { + private ICollection _securityTokenHandlers = new Collection() + { + new Saml2SecurityTokenHandler(), + new SamlSecurityTokenHandler(), + new JwtSecurityTokenHandler() + }; + private TokenValidationParameters _tokenValidationParameters = new TokenValidationParameters(); + + /// + /// Initializes a new + /// + public WsFederationOptions() + { + CallbackPath = "/signin-wsfed"; + // In ADFS the cleanup messages are sent to the same callback path as the initial login. + // In AAD it sends the cleanup message to a random Reply Url and there's no deterministic way to configure it. + // If you manage to get it configured, then you can set RemoteSignOutPath accordingly. + RemoteSignOutPath = "/signin-wsfed"; + Events = new WsFederationEvents(); + } + + /// + /// Check that the options are valid. Should throw an exception if things are not ok. + /// + public override void Validate() + { + base.Validate(); + + if (ConfigurationManager == null) + { + throw new InvalidOperationException($"Provide {nameof(MetadataAddress)}, " + + $"{nameof(Configuration)}, or {nameof(ConfigurationManager)} to {nameof(WsFederationOptions)}"); + } + } + + /// + /// Configuration provided directly by the developer. If provided, then MetadataAddress and the Backchannel properties + /// will not be used. This information should not be updated during request processing. + /// + public WsFederationConfiguration Configuration { get; set; } + + /// + /// Gets or sets the address to retrieve the wsFederation metadata + /// + public string MetadataAddress { get; set; } + + /// + /// Responsible for retrieving, caching, and refreshing the configuration from metadata. + /// If not provided, then one will be created using the MetadataAddress and Backchannel properties. + /// + public IConfigurationManager ConfigurationManager { get; set; } + + /// + /// Gets or sets if a metadata refresh should be attempted after a SecurityTokenSignatureKeyNotFoundException. This allows for automatic + /// recovery in the event of a signature key rollover. This is enabled by default. + /// + public bool RefreshOnIssuerKeyNotFound { get; set; } = true; + + /// + /// Indicates if requests to the CallbackPath may also be for other components. If enabled the handler will pass + /// requests through that do not contain WsFederation authentication responses. Disabling this and setting the + /// CallbackPath to a dedicated endpoint may provide better error handling. + /// This is disabled by default. + /// + public bool SkipUnrecognizedRequests { get; set; } + + /// + /// Gets or sets the to call when processing WsFederation messages. + /// + public new WsFederationEvents Events + { + get => (WsFederationEvents)base.Events; + set => base.Events = value; + } + + /// + /// Gets or sets the collection of used to read and validate the s. + /// + public ICollection SecurityTokenHandlers + { + get + { + return _securityTokenHandlers; + } + set + { + _securityTokenHandlers = value ?? throw new ArgumentNullException(nameof(SecurityTokenHandlers)); + } + } + + /// + /// Gets or sets the type used to secure data handled by the middleware. + /// + public ISecureDataFormat StateDataFormat { get; set; } + + /// + /// Gets or sets the + /// + /// if 'TokenValidationParameters' is null. + public TokenValidationParameters TokenValidationParameters + { + get + { + return _tokenValidationParameters; + } + set + { + _tokenValidationParameters = value ?? throw new ArgumentNullException(nameof(TokenValidationParameters)); + } + } + + /// + /// Gets or sets the 'wreply'. CallbackPath must be set to match or cleared so it can be generated dynamically. + /// This field is optional. If not set then it will be generated from the current request and the CallbackPath. + /// + public string Wreply { get; set; } + + /// + /// Gets or sets the 'wreply' value used during sign-out. + /// If none is specified then the value from the Wreply field is used. + /// + public string SignOutWreply { get; set; } + + /// + /// Gets or sets the 'wtrealm'. + /// + public string Wtrealm { get; set; } + + /// + /// Indicates that the authentication session lifetime (e.g. cookies) should match that of the authentication token. + /// If the token does not provide lifetime information then normal session lifetimes will be used. + /// This is enabled by default. + /// + public bool UseTokenLifetime { get; set; } = true; + + /// + /// Gets or sets if HTTPS is required for the metadata address or authority. + /// The default is true. This should be disabled only in development environments. + /// + public bool RequireHttpsMetadata { get; set; } = true; + + /// + /// The Ws-Federation protocol allows the user to initiate logins without contacting the application for a Challenge first. + /// However, that flow is susceptible to XSRF and other attacks so it is disabled here by default. + /// + public bool AllowUnsolicitedLogins { get; set; } + + /// + /// Requests received on this path will cause the handler to invoke SignOut using the SignOutScheme. + /// + public PathString RemoteSignOutPath { get; set; } + + /// + /// The Authentication Scheme to use with SignOutAsync from RemoteSignOutPath. SignInScheme will be used if this + /// is not set. + /// + public string SignOutScheme { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs new file mode 100644 index 0000000000..62647d4fcd --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs @@ -0,0 +1,89 @@ +// 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.Net.Http; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// Used to setup defaults for all . + /// + public class WsFederationPostConfigureOptions : IPostConfigureOptions + { + private readonly IDataProtectionProvider _dp; + + /// + /// + /// + /// + public WsFederationPostConfigureOptions(IDataProtectionProvider dataProtection) + { + _dp = dataProtection; + } + + /// + /// Invoked to post configure a TOptions instance. + /// + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, WsFederationOptions options) + { + options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; + + if (string.IsNullOrEmpty(options.SignOutScheme)) + { + options.SignOutScheme = options.SignInScheme; + } + + if (options.StateDataFormat == null) + { + var dataProtector = options.DataProtectionProvider.CreateProtector( + typeof(WsFederationHandler).FullName, name, "v1"); + options.StateDataFormat = new PropertiesDataFormat(dataProtector); + } + + if (!options.CallbackPath.HasValue && !string.IsNullOrEmpty(options.Wreply) && Uri.TryCreate(options.Wreply, UriKind.Absolute, out var wreply)) + { + // Wreply must be a very specific, case sensitive value, so we can't generate it. Instead we generate CallbackPath from it. + options.CallbackPath = PathString.FromUriComponent(wreply); + } + + if (string.IsNullOrEmpty(options.TokenValidationParameters.ValidAudience)) + { + options.TokenValidationParameters.ValidAudience = options.Wtrealm; + } + + if (options.Backchannel == null) + { + options.Backchannel = new HttpClient(options.BackchannelHttpHandler ?? new HttpClientHandler()); + options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core WsFederation handler"); + options.Backchannel.Timeout = options.BackchannelTimeout; + options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + } + + if (options.ConfigurationManager == null) + { + if (options.Configuration != null) + { + options.ConfigurationManager = new StaticConfigurationManager(options.Configuration); + } + else if (!string.IsNullOrEmpty(options.MetadataAddress)) + { + if (options.RequireHttpsMetadata && !options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException("The MetadataAddress must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); + } + + options.ConfigurationManager = new ConfigurationManager(options.MetadataAddress, new WsFederationConfigurationRetriever(), + new HttpDocumentRetriever(options.Backchannel) { RequireHttps = options.RequireHttpsMetadata }); + } + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 57fed96c02..469726690f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -4,6 +4,24 @@ $(StandardTestTfms) + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + @@ -12,6 +30,7 @@ + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs new file mode 100644 index 0000000000..0de867d286 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs @@ -0,0 +1,58 @@ +// 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.IO; +using System.Runtime.Serialization; +using System.Text; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + public class CustomStateDataFormat : ISecureDataFormat + { + public const string ValidStateData = "ValidStateData"; + + private string lastSavedAuthenticationProperties; + private DataContractSerializer serializer = new DataContractSerializer(typeof(AuthenticationProperties)); + + public string Protect(AuthenticationProperties data) + { + lastSavedAuthenticationProperties = Serialize(data); + return ValidStateData; + } + + public string Protect(AuthenticationProperties data, string purpose) + { + return Protect(data); + } + + public AuthenticationProperties Unprotect(string state) + { + return state == ValidStateData ? DeSerialize(lastSavedAuthenticationProperties) : null; + } + + public AuthenticationProperties Unprotect(string protectedText, string purpose) + { + return Unprotect(protectedText); + } + + private string Serialize(AuthenticationProperties data) + { + using (MemoryStream memoryStream = new MemoryStream()) + { + serializer.WriteObject(memoryStream, data); + memoryStream.Position = 0; + return new StreamReader(memoryStream).ReadToEnd(); + } + } + + private AuthenticationProperties DeSerialize(string state) + { + var stateDataAsBytes = Encoding.UTF8.GetBytes(state); + + using (var ms = new MemoryStream(stateDataAsBytes, false)) + { + return (AuthenticationProperties)serializer.ReadObject(ms); + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml new file mode 100644 index 0000000000..dfdb0d68d0 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml @@ -0,0 +1,83 @@ + + + 2014-04-18T20:21:17.341Z + 2014-04-19T08:21:17.341Z + + + +
http://automation1/
+
+
+ + + https://sts.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/ + + + + + + + + + + + Lkq0wTyTFxLUU2cyx0XybJqhka5RzRGj6kC4aIpFg+g= + + + bPwNswOB/B9xcdAljIkin9A2vjq+u94JdyvK03mf8vZFGUYNu9uN/Q6ims1DvW1FnP7SgFBwhIvW5OjZyW8fdYGhC2bq36izkxH6ulkWbciOcyELkyHDACLudvh8kP/Q+IwpicefKzAeI2Qu/5MFq16vFg5YgI+dovg8u1fYPPEPmmptW893RNTHWeh9mLRpLYnHyg7aLG6emNRkEu7w9rzeoICeMFybb9BvJl/q/8MFCW/Z5WemQhCi6YXFSEwCO6zJzCFi/3T6ChU/xYgXbFykDLqulsNOCQxdgutyqxJzugt+3PH5IKHHuoqe7UZNUIyELJ4BgwE1sXCGYIi24rg== + + + MIIDPjCCAiqgAwIBAgIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTIwNjA3MDcwMDAwWhcNMTQwNjA3MDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCz8Sn3GGXmikH2MdTeGY1D711EORX/lVXpr+ecGgqfUWF8MPB07XkYuJ54DAuYT318+2XrzMjOtqkT94VkXmxv6dFGhG8YZ8vNMPd4tdj9c0lpvWQdqXtL1TlFRpD/P6UMEigfN0c9oWDg9U7Ilymgei0UXtf1gtcQbc5sSQU0S4vr9YJp2gLFIGK11Iqg4XSGdcI0QWLLkkC6cBukhVnd6BCYbLjTYy3fNs4DzNdemJlxGl8sLexFytBF6YApvSdus3nFXaMCtBGx16HzkK9ne3lobAwL2o79bP4imEGqg+ibvyNmbrwFGnQrBc1jTF9LyQX9q+louxVfHs6ZiVwIDAQABo2IwYDBeBgNVHQEEVzBVgBCxDDsLd8xkfOLKm4Q/SzjtoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAA4IBAQAkJtxxm/ErgySlNk69+1odTMP8Oy6L0H17z7XGG3w4TqvTUSWaxD4hSFJ0e7mHLQLQD7oV/erACXwSZn2pMoZ89MBDjOMQA+e6QzGB7jmSzPTNmQgMLA8fWCfqPrz6zgH+1F1gNp8hJY57kfeVPBiyjuBmlTEBsBlzolY9dd/55qqfQk6cgSeCbHCy/RU/iep0+UsRMlSgPNNmqhj5gmN2AFVCN96zF694LwuPae5CeR2ZcVknexOWHYjFM0MgUSw0ubnGl0h9AJgGyhvNGcjQqu9vd1xkupFgaN+f7P3p3EVN5csBg5H94jEcQZT7EKeTiZ6bTrpDAnrr8tDCy8ng + + + + + t0ch1TsP0pi5VoW8q5CGWsCXVZoNtpsg0mbMZPOYb4I + + + + + http://Automation1 + + + + + Test + + + Test + + + user1@praburajgmail.onmicrosoft.com + + + 4afbc689-805b-48cf-a24c-d4aa3248a248 + + + c2f0cd49-5e53-4520-8ed9-4e178dc488c5 + + + https://sts.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/ + + + + + urn:oasis:names:tc:SAML:2.0:ac:classes:Password + + + + + + + _660ec874-f70a-4997-a9c4-bd591f1c7469 + + + + + _660ec874-f70a-4997-a9c4-bd591f1c7469 + + + http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0 + http://schemas.xmlsoap.org/ws/2005/02/trust/Issue + http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey +
\ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs new file mode 100644 index 0000000000..dfe8607242 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs @@ -0,0 +1,27 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.IdentityModel.Tokens; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + internal class TestSecurityToken : SecurityToken + { + public override string Id => "id"; + + public override string Issuer => "issuer"; + + public override SecurityKey SecurityKey => throw new NotImplementedException(); + + public override SecurityKey SigningKey + { + get => throw new NotImplementedException(); + set => throw new NotImplementedException(); + } + + public override DateTime ValidFrom => new DateTime(2008, 3, 22); + + public override DateTime ValidTo => new DateTime(2017, 3, 22); + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs new file mode 100644 index 0000000000..05882518f9 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs @@ -0,0 +1,31 @@ +// 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.Security.Claims; +using Microsoft.IdentityModel.Tokens; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + internal class TestSecurityTokenValidator : ISecurityTokenValidator + { + public bool CanValidateToken => true; + + public int MaximumTokenSizeInBytes { get; set; } = 1024 * 5; + + public bool CanReadToken(string securityToken) + { + return true; + } + + public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParameters validationParameters, out SecurityToken validatedToken) + { + if (!string.IsNullOrEmpty(securityToken) && securityToken.Contains("ThisIsAValidToken")) + { + validatedToken = new TestSecurityToken(); + return new ClaimsPrincipal(new ClaimsIdentity("Test")); + } + + throw new SecurityTokenException("The security token did not contain ThisIsAValidToken"); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml new file mode 100644 index 0000000000..2addae96c1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml @@ -0,0 +1,83 @@ + + + 2014-04-18T20:21:17.341Z + 2014-04-19T08:21:17.341Z + + + +
http://automation1/
+
+
+ + + https://sts.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/ + + + + + + + + + + + Lkq0wTyTFxLUU2cyx0XybJqhka5RzRGj6kC4aIpFg+g= + + + bPwNswOB/B9xcdAljIkin9A2vjq+u94JdyvK03mf8vZFGUYNu9uN/Q6ims1DvW1FnP7SgFBwhIvW5OjZyW8fdYGhC2bq36izkxH6ulkWbciOcyELkyHDACLudvh8kP/Q+IwpicefKzAeI2Qu/5MFq16vFg5YgI+dovg8u1fYPPEPmmptW893RNTHWeh9mLRpLYnHyg7aLG6emNRkEu7w9rzeoICeMFybb9BvJl/q/8MFCW/Z5WemQhCi6YXFSEwCO6zJzCFi/3T6ChU/xYgXbFykDLqulsNOCQxdgutyqxJzugt+3PH5IKHHuoqe7UZNUIyELJ4BgwE1sXCGYIi24rg== + + + ThisIsAValidToken + + + + + t0ch1TsP0pi5VoW8q5CGWsCXVZoNtpsg0mbMZPOYb4I + + + + + http://Automation1 + + + + + Test + + + Test + + + user1@praburajgmail.onmicrosoft.com + + + 4afbc689-805b-48cf-a24c-d4aa3248a248 + + + c2f0cd49-5e53-4520-8ed9-4e178dc488c5 + + + https://sts.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/ + + + + + urn:oasis:names:tc:SAML:2.0:ac:classes:Password + + + + + + + _660ec874-f70a-4997-a9c4-bd591f1c7469 + + + + + _660ec874-f70a-4997-a9c4-bd591f1c7469 + + + http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0 + http://schemas.xmlsoap.org/ws/2005/02/trust/Issue + http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey +
\ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs new file mode 100644 index 0000000000..bc1ef757f1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs @@ -0,0 +1,443 @@ +// 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.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Claims; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Extensions; +using Microsoft.AspNetCore.TestHost; +using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; +using Microsoft.Net.Http.Headers; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + public class WsFederationTest + { + [Fact] + public async Task VerifySchemeDefaults() + { + var services = new ServiceCollection(); + services.AddAuthentication().AddWsFederation(); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync(WsFederationDefaults.AuthenticationScheme); + Assert.NotNull(scheme); + Assert.Equal("WsFederationHandler", scheme.HandlerType.Name); + Assert.Equal(WsFederationDefaults.AuthenticationScheme, scheme.DisplayName); + } + + [Fact] + public async Task MissingConfigurationThrows() + { + var builder = new WebHostBuilder() + .Configure(ConfigureApp) + .ConfigureServices(services => + { + services.AddAuthentication(sharedOptions => + { + sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme; + }) + .AddCookie() + .AddWsFederation(); + }); + var server = new TestServer(builder); + var httpClient = server.CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var exception = await Assert.ThrowsAsync(() => httpClient.GetAsync("/")); + Assert.Equal("Provide MetadataAddress, Configuration, or ConfigurationManager to WsFederationOptions", exception.Message); + } + + [Fact] + public async Task ChallengeRedirects() + { + var httpClient = CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var response = await httpClient.GetAsync("/"); + Assert.Equal("https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed", response.Headers.Location.GetLeftPart(System.UriPartial.Path)); + var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query); + + Assert.Equal("http://Automation1", queryItems["wtrealm"]); + Assert.True(queryItems["wctx"].ToString().Equals(CustomStateDataFormat.ValidStateData), "wctx does not equal ValidStateData"); + Assert.Equal(httpClient.BaseAddress + "signin-wsfed", queryItems["wreply"]); + Assert.Equal("wsignin1.0", queryItems["wa"]); + } + + [Fact] + public async Task MapWillNotAffectRedirect() + { + var httpClient = CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var response = await httpClient.GetAsync("/mapped-challenge"); + Assert.Equal("https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed", response.Headers.Location.GetLeftPart(System.UriPartial.Path)); + var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query); + + Assert.Equal("http://Automation1", queryItems["wtrealm"]); + Assert.True(queryItems["wctx"].ToString().Equals(CustomStateDataFormat.ValidStateData), "wctx does not equal ValidStateData"); + Assert.Equal(httpClient.BaseAddress + "signin-wsfed", queryItems["wreply"]); + Assert.Equal("wsignin1.0", queryItems["wa"]); + } + + [Fact] + public async Task PreMappedWillAffectRedirect() + { + var httpClient = CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var response = await httpClient.GetAsync("/premapped-challenge"); + Assert.Equal("https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed", response.Headers.Location.GetLeftPart(System.UriPartial.Path)); + var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query); + + Assert.Equal("http://Automation1", queryItems["wtrealm"]); + Assert.True(queryItems["wctx"].ToString().Equals(CustomStateDataFormat.ValidStateData), "wctx does not equal ValidStateData"); + Assert.Equal(httpClient.BaseAddress + "premapped-challenge/signin-wsfed", queryItems["wreply"]); + Assert.Equal("wsignin1.0", queryItems["wa"]); + } + + [Fact] + public async Task ValidTokenIsAccepted() + { + var httpClient = CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var response = await httpClient.GetAsync("/"); + var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query); + + var request = new HttpRequestMessage(HttpMethod.Post, queryItems["wreply"]); + CopyCookies(response, request); + request.Content = CreateSignInContent("WsFederation/ValidToken.xml", queryItems["wctx"]); + response = await httpClient.SendAsync(request); + + Assert.Equal(HttpStatusCode.Found, response.StatusCode); + + request = new HttpRequestMessage(HttpMethod.Get, response.Headers.Location); + CopyCookies(response, request); + response = await httpClient.SendAsync(request); + + // Did the request end in the actual resource requested for + Assert.Equal(WsFederationDefaults.AuthenticationScheme, await response.Content.ReadAsStringAsync()); + } + + [Fact] + public async Task ValidUnsolicitedTokenIsRefused() + { + var httpClient = CreateClient(); + var form = CreateSignInContent("WsFederation/ValidToken.xml", suppressWctx: true); + var exception = await Assert.ThrowsAsync(() => httpClient.PostAsync(httpClient.BaseAddress + "signin-wsfed", form)); + Assert.Contains("Unsolicited logins are not allowed.", exception.InnerException.Message); + } + + [Fact] + public async Task ValidUnsolicitedTokenIsAcceptedWhenAllowed() + { + var httpClient = CreateClient(allowUnsolicited: true); + + var form = CreateSignInContent("WsFederation/ValidToken.xml", suppressWctx: true); + var response = await httpClient.PostAsync(httpClient.BaseAddress + "signin-wsfed", form); + + Assert.Equal(HttpStatusCode.Found, response.StatusCode); + + var request = new HttpRequestMessage(HttpMethod.Get, response.Headers.Location); + CopyCookies(response, request); + response = await httpClient.SendAsync(request); + + // Did the request end in the actual resource requested for + Assert.Equal(WsFederationDefaults.AuthenticationScheme, await response.Content.ReadAsStringAsync()); + } + + [Fact] + public async Task InvalidTokenIsRejected() + { + var httpClient = CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var response = await httpClient.GetAsync("/"); + var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query); + + var request = new HttpRequestMessage(HttpMethod.Post, queryItems["wreply"]); + CopyCookies(response, request); + request.Content = CreateSignInContent("WsFederation/InvalidToken.xml", queryItems["wctx"]); + response = await httpClient.SendAsync(request); + + // Did the request end in the actual resource requested for + Assert.Equal("AuthenticationFailed", await response.Content.ReadAsStringAsync()); + } + + [Fact] + public async Task RemoteSignoutRequestTriggersSignout() + { + var httpClient = CreateClient(); + + var response = await httpClient.GetAsync("/signin-wsfed?wa=wsignoutcleanup1.0"); + response.EnsureSuccessStatusCode(); + + var cookie = response.Headers.GetValues(HeaderNames.SetCookie).Single(); + Assert.Equal(".AspNetCore.Cookies=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax", cookie); + Assert.Equal("OnRemoteSignOut", response.Headers.GetValues("EventHeader").Single()); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + } + + [Fact] + public async Task EventsResolvedFromDI() + { + var builder = new WebHostBuilder() + .ConfigureServices(services => + { + services.AddSingleton(); + services.AddAuthentication(sharedOptions => + { + sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme; + }) + .AddCookie() + .AddWsFederation(options => + { + options.Wtrealm = "http://Automation1"; + options.MetadataAddress = "https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/federationmetadata/2007-06/federationmetadata.xml"; + options.BackchannelHttpHandler = new WaadMetadataDocumentHandler(); + options.EventsType = typeof(MyWsFedEvents); + }); + }) + .Configure(app => + { + app.Run(context => context.ChallengeAsync()); + }); + var server = new TestServer(builder); + + var result = await server.CreateClient().GetAsync(""); + Assert.Contains("CustomKey=CustomValue", result.Headers.Location.Query); + } + + private class MyWsFedEvents : WsFederationEvents + { + public override Task RedirectToIdentityProvider(RedirectContext context) + { + context.ProtocolMessage.SetParameter("CustomKey", "CustomValue"); + return base.RedirectToIdentityProvider(context); + } + } + + private FormUrlEncodedContent CreateSignInContent(string tokenFile, string wctx = null, bool suppressWctx = false) + { + var kvps = new List>(); + kvps.Add(new KeyValuePair("wa", "wsignin1.0")); + kvps.Add(new KeyValuePair("wresult", File.ReadAllText(tokenFile))); + if (!string.IsNullOrEmpty(wctx)) + { + kvps.Add(new KeyValuePair("wctx", wctx)); + } + if (suppressWctx) + { + kvps.Add(new KeyValuePair("suppressWctx", "true")); + } + return new FormUrlEncodedContent(kvps); + } + + private void CopyCookies(HttpResponseMessage response, HttpRequestMessage request) + { + var cookies = SetCookieHeaderValue.ParseList(response.Headers.GetValues(HeaderNames.SetCookie).ToList()); + foreach (var cookie in cookies) + { + if (cookie.Value.HasValue) + { + request.Headers.Add(HeaderNames.Cookie, new CookieHeaderValue(cookie.Name, cookie.Value).ToString()); + } + } + } + + private HttpClient CreateClient(bool allowUnsolicited = false) + { + var builder = new WebHostBuilder() + .Configure(ConfigureApp) + .ConfigureServices(services => + { + services.AddAuthentication(sharedOptions => + { + sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme; + }) + .AddCookie() + .AddWsFederation(options => + { + options.Wtrealm = "http://Automation1"; + options.MetadataAddress = "https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/federationmetadata/2007-06/federationmetadata.xml"; + options.BackchannelHttpHandler = new WaadMetadataDocumentHandler(); + options.StateDataFormat = new CustomStateDataFormat(); + options.SecurityTokenHandlers = new List() { new TestSecurityTokenValidator() }; + options.UseTokenLifetime = false; + options.AllowUnsolicitedLogins = allowUnsolicited; + options.Events = new WsFederationEvents() + { + OnMessageReceived = context => + { + if (!context.ProtocolMessage.Parameters.TryGetValue("suppressWctx", out var suppress)) + { + Assert.True(context.ProtocolMessage.Wctx.Equals("customValue"), "wctx is not my custom value"); + } + context.HttpContext.Items["MessageReceived"] = true; + return Task.FromResult(0); + }, + OnRedirectToIdentityProvider = context => + { + if (context.ProtocolMessage.IsSignInMessage) + { + // Sign in message + context.ProtocolMessage.Wctx = "customValue"; + } + + return Task.FromResult(0); + }, + OnSecurityTokenReceived = context => + { + context.HttpContext.Items["SecurityTokenReceived"] = true; + return Task.FromResult(0); + }, + OnSecurityTokenValidated = context => + { + Assert.True((bool)context.HttpContext.Items["MessageReceived"], "MessageReceived notification not invoked"); + Assert.True((bool)context.HttpContext.Items["SecurityTokenReceived"], "SecurityTokenReceived notification not invoked"); + + if (context.Principal != null) + { + var identity = context.Principal.Identities.Single(); + identity.AddClaim(new Claim("ReturnEndpoint", "true")); + identity.AddClaim(new Claim("Authenticated", "true")); + identity.AddClaim(new Claim(identity.RoleClaimType, "Guest", ClaimValueTypes.String)); + } + + return Task.FromResult(0); + }, + OnAuthenticationFailed = context => + { + context.HttpContext.Items["AuthenticationFailed"] = true; + //Change the request url to something different and skip Wsfed. This new url will handle the request and let us know if this notification was invoked. + context.HttpContext.Request.Path = new PathString("/AuthenticationFailed"); + context.SkipHandler(); + return Task.FromResult(0); + }, + OnRemoteSignOut = context => + { + context.Response.Headers["EventHeader"] = "OnRemoteSignOut"; + return Task.FromResult(0); + } + }; + }); + }); + var server = new TestServer(builder); + return server.CreateClient(); + } + + private void ConfigureApp(IApplicationBuilder app) + { + app.Map("/PreMapped-Challenge", mapped => + { + mapped.UseAuthentication(); + mapped.Run(async context => + { + await context.ChallengeAsync(WsFederationDefaults.AuthenticationScheme); + }); + }); + + app.UseAuthentication(); + + app.Map("/Logout", subApp => + { + subApp.Run(async context => + { + if (context.User.Identity.IsAuthenticated) + { + var authProperties = new AuthenticationProperties() { RedirectUri = context.Request.GetEncodedUrl() }; + await context.SignOutAsync(WsFederationDefaults.AuthenticationScheme, authProperties); + await context.Response.WriteAsync("Signing out..."); + } + else + { + await context.Response.WriteAsync("SignedOut"); + } + }); + }); + + app.Map("/AuthenticationFailed", subApp => + { + subApp.Run(async context => + { + await context.Response.WriteAsync("AuthenticationFailed"); + }); + }); + + app.Map("/signout-wsfed", subApp => + { + subApp.Run(async context => + { + await context.Response.WriteAsync("signout-wsfed"); + }); + }); + + app.Map("/mapped-challenge", subApp => + { + subApp.Run(async context => + { + await context.ChallengeAsync(WsFederationDefaults.AuthenticationScheme); + }); + }); + + app.Run(async context => + { + var result = context.AuthenticateAsync(); + if (context.User == null || !context.User.Identity.IsAuthenticated) + { + await context.ChallengeAsync(WsFederationDefaults.AuthenticationScheme); + await context.Response.WriteAsync("Unauthorized"); + } + else + { + var identity = context.User.Identities.Single(); + if (identity.NameClaimType == "Name_Failed" && identity.RoleClaimType == "Role_Failed") + { + context.Response.StatusCode = 500; + await context.Response.WriteAsync("SignIn_Failed"); + } + else if (!identity.HasClaim("Authenticated", "true") || !identity.HasClaim("ReturnEndpoint", "true") || !identity.HasClaim(identity.RoleClaimType, "Guest")) + { + await context.Response.WriteAsync("Provider not invoked"); + return; + } + else + { + await context.Response.WriteAsync(WsFederationDefaults.AuthenticationScheme); + } + } + }); + } + + private class WaadMetadataDocumentHandler : HttpMessageHandler + { + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + var metadata = File.ReadAllText(@"WsFederation/federationmetadata.xml"); + var newResponse = new HttpResponseMessage() { Content = new StringContent(metadata, Encoding.UTF8, "text/xml") }; + return Task.FromResult(newResponse); + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml new file mode 100644 index 0000000000..920ed66a4f --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + wFJy/A1QstqtLHauYGcqwwHvn3HUW25DcWI/XLOmXOM= + + + R6fPw+BiFS9XYdkhwNJRjGxVftA2j9TdkF5d5jgR8uG1QMyuEA/Eizeq1HnnUj2Yi+sqNG+HzaZQclECeiJfi88Ry+keorDCo9KgdnjlZZc+WFzrJZeHjaDIvFD6B4OAN0mTq5kbpwr7+idzSbvyRXAnpvJxOrViZKE4HpwltGAZGDTkjsVkd8Z/wfoN7ehN4Ei7u/mOAiEU4FkWYFU/BfSVRVIUDyyQ7DGfQFJvCwHWFvsq+M1wfOUzQO5K+M9EU2m4VEP1qqbexXaZMAbcjqyUn4eN7doWjWE59jkXGbn+GR8qgCJqLOaYwXnH5XD0pMjy71aKGyLNaUb3wCwjkA== + + + MIIDPjCCAiqgAwIBAgIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTIwNjA3MDcwMDAwWhcNMTQwNjA3MDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCz8Sn3GGXmikH2MdTeGY1D711EORX/lVXpr+ecGgqfUWF8MPB07XkYuJ54DAuYT318+2XrzMjOtqkT94VkXmxv6dFGhG8YZ8vNMPd4tdj9c0lpvWQdqXtL1TlFRpD/P6UMEigfN0c9oWDg9U7Ilymgei0UXtf1gtcQbc5sSQU0S4vr9YJp2gLFIGK11Iqg4XSGdcI0QWLLkkC6cBukhVnd6BCYbLjTYy3fNs4DzNdemJlxGl8sLexFytBF6YApvSdus3nFXaMCtBGx16HzkK9ne3lobAwL2o79bP4imEGqg+ibvyNmbrwFGnQrBc1jTF9LyQX9q+louxVfHs6ZiVwIDAQABo2IwYDBeBgNVHQEEVzBVgBCxDDsLd8xkfOLKm4Q/SzjtoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAA4IBAQAkJtxxm/ErgySlNk69+1odTMP8Oy6L0H17z7XGG3w4TqvTUSWaxD4hSFJ0e7mHLQLQD7oV/erACXwSZn2pMoZ89MBDjOMQA+e6QzGB7jmSzPTNmQgMLA8fWCfqPrz6zgH+1F1gNp8hJY57kfeVPBiyjuBmlTEBsBlzolY9dd/55qqfQk6cgSeCbHCy/RU/iep0+UsRMlSgPNNmqhj5gmN2AFVCN96zF694LwuPae5CeR2ZcVknexOWHYjFM0MgUSw0ubnGl0h9AJgGyhvNGcjQqu9vd1xkupFgaN+f7P3p3EVN5csBg5H94jEcQZT7EKeTiZ6bTrpDAnrr8tDCy8ng + + + + + + + + MIIDPjCCAiqgAwIBAgIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTQwMTAxMDcwMDAwWhcNMTYwMTAxMDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkSCWg6q9iYxvJE2NIhSyOiKvqoWCO2GFipgH0sTSAs5FalHQosk9ZNTztX0ywS/AHsBeQPqYygfYVJL6/EgzVuwRk5txr9e3n1uml94fLyq/AXbwo9yAduf4dCHTP8CWR1dnDR+Qnz/4PYlWVEuuHHONOw/blbfdMjhY+C/BYM2E3pRxbohBb3x//CfueV7ddz2LYiH3wjz0QS/7kjPiNCsXcNyKQEOTkbHFi3mu0u13SQwNddhcynd/GTgWN8A+6SN1r4hzpjFKFLbZnBt77ACSiYx+IHK4Mp+NaVEi5wQtSsjQtI++XsokxRDqYLwus1I1SihgbV/STTg5enufuwIDAQABo2IwYDBeBgNVHQEEVzBVgBDLebM6bK3BjWGqIBrBNFeNoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAA4IBAQCJ4JApryF77EKC4zF5bUaBLQHQ1PNtA1uMDbdNVGKCmSf8M65b8h0NwlIjGGGy/unK8P6jWFdm5IlZ0YPTOgzcRZguXDPj7ajyvlVEQ2K2ICvTYiRQqrOhEhZMSSZsTKXFVwNfW6ADDkN3bvVOVbtpty+nBY5UqnI7xbcoHLZ4wYD251uj5+lo13YLnsVrmQ16NCBYq2nQFNPuNJw6t3XUbwBHXpF46aLT1/eGf/7Xx6iy8yPJX4DyrpFTutDz882RWofGEO5t4Cw+zZg70dJ/hH/ODYRMorfXEW+8uKmXMKmX2wyxMKvfiPbTy5LmAU8Jvjs2tLg4rOBcXWLAIarZ + + + + + + + MIIDPjCCAiqgAwIBAgIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTIwNjA3MDcwMDAwWhcNMTQwNjA3MDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCz8Sn3GGXmikH2MdTeGY1D711EORX/lVXpr+ecGgqfUWF8MPB07XkYuJ54DAuYT318+2XrzMjOtqkT94VkXmxv6dFGhG8YZ8vNMPd4tdj9c0lpvWQdqXtL1TlFRpD/P6UMEigfN0c9oWDg9U7Ilymgei0UXtf1gtcQbc5sSQU0S4vr9YJp2gLFIGK11Iqg4XSGdcI0QWLLkkC6cBukhVnd6BCYbLjTYy3fNs4DzNdemJlxGl8sLexFytBF6YApvSdus3nFXaMCtBGx16HzkK9ne3lobAwL2o79bP4imEGqg+ibvyNmbrwFGnQrBc1jTF9LyQX9q+louxVfHs6ZiVwIDAQABo2IwYDBeBgNVHQEEVzBVgBCxDDsLd8xkfOLKm4Q/SzjtoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAA4IBAQAkJtxxm/ErgySlNk69+1odTMP8Oy6L0H17z7XGG3w4TqvTUSWaxD4hSFJ0e7mHLQLQD7oV/erACXwSZn2pMoZ89MBDjOMQA+e6QzGB7jmSzPTNmQgMLA8fWCfqPrz6zgH+1F1gNp8hJY57kfeVPBiyjuBmlTEBsBlzolY9dd/55qqfQk6cgSeCbHCy/RU/iep0+UsRMlSgPNNmqhj5gmN2AFVCN96zF694LwuPae5CeR2ZcVknexOWHYjFM0MgUSw0ubnGl0h9AJgGyhvNGcjQqu9vd1xkupFgaN+f7P3p3EVN5csBg5H94jEcQZT7EKeTiZ6bTrpDAnrr8tDCy8ng + + + + + + UPN + UPN of the user + + + Name + The display name for the user + + + Given Name + First name of the user + + + Surname + Last name of the user + + + Authentication Instant + The time (UTC) at which the user authenticated to the identity provider + + + Authentication Method + The method of authentication used by the identity provider + + + TenantId + Identifier for the user's tenant + + + IdentityProvider + Identity provider for the user. + + + + +
https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed
+
+
+ + +
https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed
+
+
+
+ + + + + MIIDPjCCAiqgAwIBAgIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTQwMTAxMDcwMDAwWhcNMTYwMTAxMDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkSCWg6q9iYxvJE2NIhSyOiKvqoWCO2GFipgH0sTSAs5FalHQosk9ZNTztX0ywS/AHsBeQPqYygfYVJL6/EgzVuwRk5txr9e3n1uml94fLyq/AXbwo9yAduf4dCHTP8CWR1dnDR+Qnz/4PYlWVEuuHHONOw/blbfdMjhY+C/BYM2E3pRxbohBb3x//CfueV7ddz2LYiH3wjz0QS/7kjPiNCsXcNyKQEOTkbHFi3mu0u13SQwNddhcynd/GTgWN8A+6SN1r4hzpjFKFLbZnBt77ACSiYx+IHK4Mp+NaVEi5wQtSsjQtI++XsokxRDqYLwus1I1SihgbV/STTg5enufuwIDAQABo2IwYDBeBgNVHQEEVzBVgBDLebM6bK3BjWGqIBrBNFeNoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAA4IBAQCJ4JApryF77EKC4zF5bUaBLQHQ1PNtA1uMDbdNVGKCmSf8M65b8h0NwlIjGGGy/unK8P6jWFdm5IlZ0YPTOgzcRZguXDPj7ajyvlVEQ2K2ICvTYiRQqrOhEhZMSSZsTKXFVwNfW6ADDkN3bvVOVbtpty+nBY5UqnI7xbcoHLZ4wYD251uj5+lo13YLnsVrmQ16NCBYq2nQFNPuNJw6t3XUbwBHXpF46aLT1/eGf/7Xx6iy8yPJX4DyrpFTutDz882RWofGEO5t4Cw+zZg70dJ/hH/ODYRMorfXEW+8uKmXMKmX2wyxMKvfiPbTy5LmAU8Jvjs2tLg4rOBcXWLAIarZ + + + + + + + MIIDPjCCAiqgAwIBAgIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTIwNjA3MDcwMDAwWhcNMTQwNjA3MDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCz8Sn3GGXmikH2MdTeGY1D711EORX/lVXpr+ecGgqfUWF8MPB07XkYuJ54DAuYT318+2XrzMjOtqkT94VkXmxv6dFGhG8YZ8vNMPd4tdj9c0lpvWQdqXtL1TlFRpD/P6UMEigfN0c9oWDg9U7Ilymgei0UXtf1gtcQbc5sSQU0S4vr9YJp2gLFIGK11Iqg4XSGdcI0QWLLkkC6cBukhVnd6BCYbLjTYy3fNs4DzNdemJlxGl8sLexFytBF6YApvSdus3nFXaMCtBGx16HzkK9ne3lobAwL2o79bP4imEGqg+ibvyNmbrwFGnQrBc1jTF9LyQX9q+louxVfHs6ZiVwIDAQABo2IwYDBeBgNVHQEEVzBVgBCxDDsLd8xkfOLKm4Q/SzjtoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAA4IBAQAkJtxxm/ErgySlNk69+1odTMP8Oy6L0H17z7XGG3w4TqvTUSWaxD4hSFJ0e7mHLQLQD7oV/erACXwSZn2pMoZ89MBDjOMQA+e6QzGB7jmSzPTNmQgMLA8fWCfqPrz6zgH+1F1gNp8hJY57kfeVPBiyjuBmlTEBsBlzolY9dd/55qqfQk6cgSeCbHCy/RU/iep0+UsRMlSgPNNmqhj5gmN2AFVCN96zF694LwuPae5CeR2ZcVknexOWHYjFM0MgUSw0ubnGl0h9AJgGyhvNGcjQqu9vd1xkupFgaN+f7P3p3EVN5csBg5H94jEcQZT7EKeTiZ6bTrpDAnrr8tDCy8ng + + + + + +
https://sts.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/
+
+
+ + +
https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed
+
+
+ + +
https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed
+
+
+
+ + + + + MIIDPjCCAiqgAwIBAgIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTQwMTAxMDcwMDAwWhcNMTYwMTAxMDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkSCWg6q9iYxvJE2NIhSyOiKvqoWCO2GFipgH0sTSAs5FalHQosk9ZNTztX0ywS/AHsBeQPqYygfYVJL6/EgzVuwRk5txr9e3n1uml94fLyq/AXbwo9yAduf4dCHTP8CWR1dnDR+Qnz/4PYlWVEuuHHONOw/blbfdMjhY+C/BYM2E3pRxbohBb3x//CfueV7ddz2LYiH3wjz0QS/7kjPiNCsXcNyKQEOTkbHFi3mu0u13SQwNddhcynd/GTgWN8A+6SN1r4hzpjFKFLbZnBt77ACSiYx+IHK4Mp+NaVEi5wQtSsjQtI++XsokxRDqYLwus1I1SihgbV/STTg5enufuwIDAQABo2IwYDBeBgNVHQEEVzBVgBDLebM6bK3BjWGqIBrBNFeNoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAA4IBAQCJ4JApryF77EKC4zF5bUaBLQHQ1PNtA1uMDbdNVGKCmSf8M65b8h0NwlIjGGGy/unK8P6jWFdm5IlZ0YPTOgzcRZguXDPj7ajyvlVEQ2K2ICvTYiRQqrOhEhZMSSZsTKXFVwNfW6ADDkN3bvVOVbtpty+nBY5UqnI7xbcoHLZ4wYD251uj5+lo13YLnsVrmQ16NCBYq2nQFNPuNJw6t3XUbwBHXpF46aLT1/eGf/7Xx6iy8yPJX4DyrpFTutDz882RWofGEO5t4Cw+zZg70dJ/hH/ODYRMorfXEW+8uKmXMKmX2wyxMKvfiPbTy5LmAU8Jvjs2tLg4rOBcXWLAIarZ + + + + + + + MIIDPjCCAiqgAwIBAgIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTIwNjA3MDcwMDAwWhcNMTQwNjA3MDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCz8Sn3GGXmikH2MdTeGY1D711EORX/lVXpr+ecGgqfUWF8MPB07XkYuJ54DAuYT318+2XrzMjOtqkT94VkXmxv6dFGhG8YZ8vNMPd4tdj9c0lpvWQdqXtL1TlFRpD/P6UMEigfN0c9oWDg9U7Ilymgei0UXtf1gtcQbc5sSQU0S4vr9YJp2gLFIGK11Iqg4XSGdcI0QWLLkkC6cBukhVnd6BCYbLjTYy3fNs4DzNdemJlxGl8sLexFytBF6YApvSdus3nFXaMCtBGx16HzkK9ne3lobAwL2o79bP4imEGqg+ibvyNmbrwFGnQrBc1jTF9LyQX9q+louxVfHs6ZiVwIDAQABo2IwYDBeBgNVHQEEVzBVgBCxDDsLd8xkfOLKm4Q/SzjtoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAA4IBAQAkJtxxm/ErgySlNk69+1odTMP8Oy6L0H17z7XGG3w4TqvTUSWaxD4hSFJ0e7mHLQLQD7oV/erACXwSZn2pMoZ89MBDjOMQA+e6QzGB7jmSzPTNmQgMLA8fWCfqPrz6zgH+1F1gNp8hJY57kfeVPBiyjuBmlTEBsBlzolY9dd/55qqfQk6cgSeCbHCy/RU/iep0+UsRMlSgPNNmqhj5gmN2AFVCN96zF694LwuPae5CeR2ZcVknexOWHYjFM0MgUSw0ubnGl0h9AJgGyhvNGcjQqu9vd1xkupFgaN+f7P3p3EVN5csBg5H94jEcQZT7EKeTiZ6bTrpDAnrr8tDCy8ng + + + + + + +
\ No newline at end of file From cc8acdff57a200966b6b695c7846dfde073cfe68 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 28 Feb 2018 09:48:07 -0800 Subject: [PATCH 862/900] Update facebook API version to 2.12 #1306 --- .../FacebookDefaults.cs | 6 +++--- .../FacebookTests.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs index 6143a4f235..92d1d003e6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -9,10 +9,10 @@ namespace Microsoft.AspNetCore.Authentication.Facebook public static readonly string DisplayName = "Facebook"; - public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.6/dialog/oauth"; + public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.12/dialog/oauth"; - public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.6/oauth/access_token"; + public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.12/oauth/access_token"; - public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v2.6/me"; + public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v2.12/me"; } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 684482ed5b..99177d66bb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -585,7 +585,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var transaction = await server.SendAsync("http://example.com/base/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.6/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=" + UrlEncoder.Default.Encode("http://example.com/base/signin-facebook"), location); @@ -617,7 +617,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var transaction = await server.SendAsync("http://example.com/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.6/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri="+ UrlEncoder.Default.Encode("http://example.com/signin-facebook"), location); @@ -652,7 +652,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var transaction = await server.SendAsync("http://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.6/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=", location); From 21acbf06e88a5f649e90b4a458b4341355791ac4 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 28 Feb 2018 10:01:09 -0800 Subject: [PATCH 863/900] Update google auth endpoint to v2 #1307 --- .../GoogleDefaults.cs | 2 +- test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs index e4bd666157..0428703180 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Authentication.Google public static readonly string DisplayName = "Google"; - public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/auth"; + public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth"; public static readonly string TokenEndpoint = "https://www.googleapis.com/oauth2/v4/token"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 8bfbaacde8..c3e80ef71a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -457,7 +457,7 @@ namespace Microsoft.AspNetCore.Authentication.Google var transaction = await server.SendAsync("https://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.ToString(); - Assert.Contains("https://accounts.google.com/o/oauth2/auth?response_type=code", location); + Assert.Contains("https://accounts.google.com/o/oauth2/v2/auth?response_type=code", location); Assert.Contains("&client_id=", location); Assert.Contains("&redirect_uri=", location); Assert.Contains("&scope=", location); From 9839799645a1110990a5fa5fb8ce060566a0e39e Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 2 Mar 2018 09:53:03 -0800 Subject: [PATCH 864/900] Add CookiePolicy logging #1588 --- samples/CookiePolicySample/Program.cs | 2 +- .../CookiePolicyMiddleware.cs | 18 ++- .../LoggingExtensions.cs | 105 ++++++++++++++++++ .../Microsoft.AspNetCore.CookiePolicy.csproj | 1 + .../ResponseCookiesWrapper.cs | 50 +++++++-- .../CookiePolicyTests.cs | 2 +- 6 files changed, 163 insertions(+), 15 deletions(-) create mode 100644 src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs diff --git a/samples/CookiePolicySample/Program.cs b/samples/CookiePolicySample/Program.cs index 12fc8ff287..3fc09a3db2 100644 --- a/samples/CookiePolicySample/Program.cs +++ b/samples/CookiePolicySample/Program.cs @@ -12,7 +12,7 @@ namespace CookiePolicySample .ConfigureLogging(factory => { factory.AddConsole(); - factory.AddFilter("Console", level => level >= LogLevel.Information); + factory.AddFilter("Microsoft", LogLevel.Trace); }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs index b99fed2c3d..1a810b7d55 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -1,10 +1,13 @@ // 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.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.CookiePolicy @@ -12,13 +15,20 @@ namespace Microsoft.AspNetCore.CookiePolicy public class CookiePolicyMiddleware { private readonly RequestDelegate _next; + private readonly ILogger _logger; - public CookiePolicyMiddleware( - RequestDelegate next, - IOptions options) + public CookiePolicyMiddleware(RequestDelegate next, IOptions options, ILoggerFactory factory) + { + Options = options.Value; + _next = next ?? throw new ArgumentNullException(nameof(next)); + _logger = factory.CreateLogger(); + } + + public CookiePolicyMiddleware(RequestDelegate next, IOptions options) { Options = options.Value; _next = next; + _logger = NullLogger.Instance; } public CookiePolicyOptions Options { get; set; } @@ -26,7 +36,7 @@ namespace Microsoft.AspNetCore.CookiePolicy public Task Invoke(HttpContext context) { var feature = context.Features.Get() ?? new ResponseCookiesFeature(context.Features); - var wrapper = new ResponseCookiesWrapper(context, Options, feature); + var wrapper = new ResponseCookiesWrapper(context, Options, feature, _logger); context.Features.Set(new CookiesWrapperFeature(wrapper)); context.Features.Set(wrapper); diff --git a/src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs b/src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs new file mode 100644 index 0000000000..21b04facc9 --- /dev/null +++ b/src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs @@ -0,0 +1,105 @@ +// 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.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _needsConsent; + private static Action _hasConsent; + private static Action _consentGranted; + private static Action _consentWithdrawn; + private static Action _cookieSuppressed; + private static Action _deleteCookieSuppressed; + private static Action _upgradedToSecure; + private static Action _upgradedSameSite; + private static Action _upgradedToHttpOnly; + + static LoggingExtensions() + { + _needsConsent = LoggerMessage.Define( + eventId: 1, + logLevel: LogLevel.Trace, + formatString: "Needs consent: {needsConsent}."); + _hasConsent = LoggerMessage.Define( + eventId: 2, + logLevel: LogLevel.Trace, + formatString: "Has consent: {hasConsent}."); + _consentGranted = LoggerMessage.Define( + eventId: 3, + logLevel: LogLevel.Debug, + formatString: "Consent granted."); + _consentWithdrawn = LoggerMessage.Define( + eventId: 4, + logLevel: LogLevel.Debug, + formatString: "Consent withdrawn."); + _cookieSuppressed = LoggerMessage.Define( + eventId: 5, + logLevel: LogLevel.Debug, + formatString: "Cookie '{key}' suppressed due to consent policy."); + _deleteCookieSuppressed = LoggerMessage.Define( + eventId: 6, + logLevel: LogLevel.Debug, + formatString: "Delete cookie '{key}' suppressed due to developer policy."); + _upgradedToSecure = LoggerMessage.Define( + eventId: 7, + logLevel: LogLevel.Debug, + formatString: "Cookie '{key}' upgraded to 'secure'."); + _upgradedSameSite = LoggerMessage.Define( + eventId: 8, + logLevel: LogLevel.Debug, + formatString: "Cookie '{key}' same site mode upgraded to '{mode}'."); + _upgradedToHttpOnly = LoggerMessage.Define( + eventId: 9, + logLevel: LogLevel.Debug, + formatString: "Cookie '{key}' upgraded to 'httponly'."); + } + + public static void NeedsConsent(this ILogger logger, bool needsConsent) + { + _needsConsent(logger, needsConsent, null); + } + + public static void HasConsent(this ILogger logger, bool hasConsent) + { + _hasConsent(logger, hasConsent, null); + } + + public static void ConsentGranted(this ILogger logger) + { + _consentGranted(logger, null); + } + + public static void ConsentWithdrawn(this ILogger logger) + { + _consentWithdrawn(logger, null); + } + + public static void CookieSuppressed(this ILogger logger, string key) + { + _cookieSuppressed(logger, key, null); + } + + public static void DeleteCookieSuppressed(this ILogger logger, string key) + { + _deleteCookieSuppressed(logger, key, null); + } + + public static void CookieUpgradedToSecure(this ILogger logger, string key) + { + _upgradedToSecure(logger, key, null); + } + + public static void CookieSameSiteUpgraded(this ILogger logger, string key, string mode) + { + _upgradedSameSite(logger, key, mode, null); + } + + public static void CookieUpgradedToHttpOnly(this ILogger logger, string key) + { + _upgradedToHttpOnly(logger, key, null); + } + } +} diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 1a42b04dde..40f97633ae 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs index e05cc9466f..126c4d7bd5 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs @@ -5,21 +5,23 @@ using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.CookiePolicy { internal class ResponseCookiesWrapper : IResponseCookies, ITrackingConsentFeature { private const string ConsentValue = "yes"; - + private readonly ILogger _logger; private bool? _isConsentNeeded; private bool? _hasConsent; - public ResponseCookiesWrapper(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature) + public ResponseCookiesWrapper(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature, ILogger logger) { Context = context; Feature = feature; Options = options; + _logger = logger; } private HttpContext Context { get; } @@ -38,6 +40,7 @@ namespace Microsoft.AspNetCore.CookiePolicy { _isConsentNeeded = Options.CheckConsentNeeded == null ? false : Options.CheckConsentNeeded(Context); + _logger.NeedsConsent(_isConsentNeeded.Value); } return _isConsentNeeded.Value; @@ -52,6 +55,7 @@ namespace Microsoft.AspNetCore.CookiePolicy { var cookie = Context.Request.Cookies[Options.ConsentCookie.Name]; _hasConsent = string.Equals(cookie, ConsentValue, StringComparison.Ordinal); + _logger.HasConsent(_hasConsent.Value); } return _hasConsent.Value; @@ -67,6 +71,7 @@ namespace Microsoft.AspNetCore.CookiePolicy var cookieOptions = Options.ConsentCookie.Build(Context); // Note policy will be applied. We don't want to bypass policy because we want HttpOnly, Secure, etc. to apply. Append(Options.ConsentCookie.Name, ConsentValue, cookieOptions); + _logger.ConsentGranted(); } _hasConsent = true; } @@ -78,6 +83,7 @@ namespace Microsoft.AspNetCore.CookiePolicy var cookieOptions = Options.ConsentCookie.Build(Context); // Note policy will be applied. We don't want to bypass policy because we want HttpOnly, Secure, etc. to apply. Delete(Options.ConsentCookie.Name, cookieOptions); + _logger.ConsentWithdrawn(); } _hasConsent = false; } @@ -137,12 +143,16 @@ namespace Microsoft.AspNetCore.CookiePolicy { Cookies.Append(key, value, options); } + else + { + _logger.CookieSuppressed(key); + } } private bool ApplyAppendPolicy(ref string key, ref string value, CookieOptions options) { var issueCookie = CanTrack || options.IsEssential; - ApplyPolicy(options); + ApplyPolicy(key, options); if (Options.OnAppendCookie != null) { var context = new AppendCookieContext(Context, options, key, value) @@ -182,7 +192,7 @@ namespace Microsoft.AspNetCore.CookiePolicy // Assume you can always delete cookies unless directly overridden in the user event. var issueCookie = true; - ApplyPolicy(options); + ApplyPolicy(key, options); if (Options.OnDeleteCookie != null) { var context = new DeleteCookieContext(Context, options, key) @@ -201,17 +211,30 @@ namespace Microsoft.AspNetCore.CookiePolicy { Cookies.Delete(key, options); } + else + { + _logger.DeleteCookieSuppressed(key); + } } - private void ApplyPolicy(CookieOptions options) + private void ApplyPolicy(string key, CookieOptions options) { switch (Options.Secure) { case CookieSecurePolicy.Always: - options.Secure = true; + if (!options.Secure) + { + options.Secure = true; + _logger.CookieUpgradedToSecure(key); + } break; case CookieSecurePolicy.SameAsRequest: - options.Secure = Context.Request.IsHttps; + // Never downgrade a cookie + if (Context.Request.IsHttps && !options.Secure) + { + options.Secure = true; + _logger.CookieUpgradedToSecure(key); + } break; case CookieSecurePolicy.None: break; @@ -226,10 +249,15 @@ namespace Microsoft.AspNetCore.CookiePolicy if (options.SameSite == SameSiteMode.None) { options.SameSite = SameSiteMode.Lax; + _logger.CookieSameSiteUpgraded(key, "lax"); } break; case SameSiteMode.Strict: - options.SameSite = SameSiteMode.Strict; + if (options.SameSite != SameSiteMode.Strict) + { + options.SameSite = SameSiteMode.Strict; + _logger.CookieSameSiteUpgraded(key, "strict"); + } break; default: throw new InvalidOperationException($"Unrecognized {nameof(SameSiteMode)} value {Options.MinimumSameSitePolicy.ToString()}"); @@ -237,7 +265,11 @@ namespace Microsoft.AspNetCore.CookiePolicy switch (Options.HttpOnly) { case HttpOnlyPolicy.Always: - options.HttpOnly = true; + if (!options.HttpOnly) + { + options.HttpOnly = true; + _logger.CookieUpgradedToHttpOnly(key); + } break; case HttpOnlyPolicy.None: break; diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index 7c34f950a5..a2592e5575 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.CookiePolicy.Test Assert.Equal("A=A; path=/; samesite=lax", transaction.SetCookie[0]); Assert.Equal("B=B; path=/; samesite=lax", transaction.SetCookie[1]); Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; samesite=lax", transaction.SetCookie[3]); + Assert.Equal("D=D; path=/; secure; samesite=lax", transaction.SetCookie[3]); }), new RequestTest("https://example.com/secureSame", transaction => From 1df139eb6d8ef1c1e74a14dd20c9dd13eb6e0e23 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 2 Mar 2018 12:37:19 -0800 Subject: [PATCH 865/900] Clone tickets for sliding refresh #1607 --- .../CookieAuthenticationHandler.cs | 21 +++- .../CookieTests.cs | 116 +++++++++++++++++- 2 files changed, 134 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 9a2fbfbc74..5993f75325 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -31,6 +31,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies private DateTimeOffset? _refreshExpiresUtc; private string _sessionKey; private Task _readCookieTask; + private AuthenticationTicket _refreshTicket; public CookieAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) @@ -99,9 +100,27 @@ namespace Microsoft.AspNetCore.Authentication.Cookies _refreshIssuedUtc = currentUtc; var timeSpan = expiresUtc.Value.Subtract(issuedUtc.Value); _refreshExpiresUtc = currentUtc.Add(timeSpan); + _refreshTicket = CloneTicket(ticket); } } + private AuthenticationTicket CloneTicket(AuthenticationTicket ticket) + { + var newPrincipal = new ClaimsPrincipal(); + foreach (var identity in ticket.Principal.Identities) + { + newPrincipal.AddIdentity(identity.Clone()); + } + + var newProperties = new AuthenticationProperties(); + foreach (var item in ticket.Properties.Items) + { + newProperties.Items[item.Key] = item.Value; + } + + return new AuthenticationTicket(newPrincipal, newProperties, ticket.AuthenticationScheme); + } + private async Task ReadCookieTicket() { var cookie = Options.CookieManager.GetRequestCookie(Context, Options.Cookie.Name); @@ -190,7 +209,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies return; } - var ticket = (await HandleAuthenticateOnceSafeAsync())?.Ticket; + var ticket = _refreshTicket; if (ticket != null) { var properties = ticket.Properties; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index b2726bac8c..945ec82ee6 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -515,8 +515,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies private Task SignInAsAlice(HttpContext context) { + var user = new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")); + user.AddClaim(new Claim("marker", "true")); return context.SignInAsync("Cookies", - new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), + new ClaimsPrincipal(user), new AuthenticationProperties()); } @@ -942,6 +944,61 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); } + [Fact] + public async Task CookieCanBeRenewedByValidatorWithModifiedProperties() + { + var server = CreateServer(o => + { + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = ctx => + { + ctx.ShouldRenew = true; + var id = ctx.Principal.Identities.First(); + var claim = id.FindFirst("counter"); + if (claim == null) + { + id.AddClaim(new Claim("counter", "1")); + } + else + { + id.RemoveClaim(claim); + id.AddClaim(new Claim("counter", claim.Value + "1")); + } + return Task.FromResult(0); + } + }; + }, + context => + context.SignInAsync("Cookies", + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction2.SetCookie); + Assert.Equal("1", FindClaimValue(transaction2, "counter")); + + _clock.Add(TimeSpan.FromMinutes(5)); + + var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); + Assert.NotNull(transaction3.SetCookie); + Assert.Equal("11", FindClaimValue(transaction3, "counter")); + + _clock.Add(TimeSpan.FromMinutes(6)); + + var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction3.CookieNameValue); + Assert.NotNull(transaction4.SetCookie); + Assert.Equal("111", FindClaimValue(transaction4, "counter")); + + _clock.Add(TimeSpan.FromMinutes(11)); + + var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction4.CookieNameValue); + Assert.Null(transaction5.SetCookie); + Assert.Null(FindClaimValue(transaction5, "counter")); + } + [Fact] public async Task CookieValidatorOnlyCalledOnce() { @@ -1114,6 +1171,51 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Equal("Alice", FindClaimValue(transaction5, ClaimTypes.Name)); } + [Fact] + public async Task CookieIsRenewedWithSlidingExpirationWithoutTransformations() + { + var server = CreateServer(o => + { + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = true; + o.Events.OnValidatePrincipal = c => + { + // https://github.com/aspnet/Security/issues/1607 + // On sliding refresh the transformed principal should not be serialized into the cookie, only the original principal. + Assert.Single(c.Principal.Identities); + Assert.True(c.Principal.Identities.First().HasClaim("marker", "true")); + return Task.CompletedTask; + }; + }, + SignInAsAlice, + claimsTransform: true); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.Null(transaction2.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + + _clock.Add(TimeSpan.FromMinutes(4)); + + var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.Null(transaction3.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); + + _clock.Add(TimeSpan.FromMinutes(4)); + + // transaction4 should arrive with a new SetCookie value + var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction4.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); + + _clock.Add(TimeSpan.FromMinutes(4)); + + var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction4.CookieNameValue); + Assert.Null(transaction5.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction5, ClaimTypes.Name)); + } + [Fact] public async Task CookieUsesPathBaseByDefault() { @@ -1643,6 +1745,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { public Task TransformAsync(ClaimsPrincipal p) { + var firstId = p.Identities.First(); + if (firstId.HasClaim("marker", "true")) + { + firstId.RemoveClaim(firstId.FindFirst("marker")); + } + // TransformAsync could be called twice on one request if you have a default scheme and also + // call AuthenticateAsync. if (!p.Identities.Any(i => i.AuthenticationType == "xform")) { var id = new ClaimsIdentity("xform"); @@ -1658,7 +1767,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { s.AddSingleton(_clock); s.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions); - s.AddSingleton(); + if (claimsTransform) + { + s.AddSingleton(); + } }, testpath, baseAddress); private static TestServer CreateServerWithServices(Action configureServices, Func testpath = null, Uri baseAddress = null) From f5ea6944f0d501915a26a6c343eb67357bc6270a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:06:01 -0800 Subject: [PATCH 866/900] Use dotnet-core feed in repos --- build/sources.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/sources.props b/build/sources.props index 9feff29d09..9215df9751 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,10 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); + https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; From 4e3e8bb109f3d1b3d95f7af4775a386d291c2b96 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:06:01 -0800 Subject: [PATCH 867/900] Prepend FeatureBranchVersionPrefix if FeatureBranchVersionSuffix is specified --- version.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.props b/version.props index 65c8a07e37..a11ea1ed52 100644 --- a/version.props +++ b/version.props @@ -5,7 +5,8 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 - $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) + a- + $(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) From 41bcbd5f0b3fa8bf361cb4a1eae03861cd3841bb Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 8 Mar 2018 13:14:09 -0800 Subject: [PATCH 868/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4ccaf4fcbc..d0cb88aa82 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15721 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 + 2.1.0-preview2-15728 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview2-26130-04 + 2.1.0-preview2-26225-03 15.6.0 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e6c7fddffa..138d848db1 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15721 -commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 +version:2.1.0-preview2-15728 +commithash:393377068ddcf51dfee0536536d455f57a828b06 From 4103d47f0919f9e5b5804d6bd4ee33ad5bb77d15 Mon Sep 17 00:00:00 2001 From: Alexander Klingenbeck Date: Tue, 13 Mar 2018 18:57:36 +0100 Subject: [PATCH 869/900] Rename ns Microsoft.AspNetCore.Authroization.Test to Microsoft.AspNetCore.Authorization.Test (#1693) --- .../AuthorizationPolicyFacts.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs index 3eefb7af7b..143be1b9be 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Authorization.Infrastructure; using Microsoft.Extensions.Options; using Xunit; -namespace Microsoft.AspNetCore.Authroization.Test +namespace Microsoft.AspNetCore.Authorization.Test { public class AuthorizationPolicyFacts { From bee77ebf911d477faed36a12bcc7369bf0005e1a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 13 Mar 2018 11:09:43 -0700 Subject: [PATCH 870/900] Rename VirtualScheme => PolicyScheme (#1665) * VirtualScheme => PolicyScheme * Use SignInHandler base for cookies * PolicySchemeHandlers throw NotImplemented by default * Remove redundant interface --- .../CookieAuthenticationHandler.cs | 23 +--- .../breakingchanges.netcore.json | 6 ++ .../AuthenticationBuilder.cs | 6 +- .../AuthenticationHandler.cs | 1 - .../PolicySchemeHandler.cs | 36 +++++++ .../PolicySchemeOptions.cs | 11 ++ .../SignInAuthenticationHandler.cs | 39 +++++++ .../SignOutAuthenticationHandler.cs | 36 +++++++ .../VirtualAuthenticationHandler.cs | 71 ------------ .../VirtualSchemeOptions.cs | 33 ------ ...{VirtualHandlerTests.cs => PolicyTests.cs} | 102 ++++++------------ 11 files changed, 166 insertions(+), 198 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs rename test/Microsoft.AspNetCore.Authentication.Test/{VirtualHandlerTests.cs => PolicyTests.cs} (85%) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 5993f75325..343cf1b3a7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -14,10 +14,7 @@ using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Authentication.Cookies { - public class CookieAuthenticationHandler : - AuthenticationHandler, - IAuthenticationSignInHandler, - IAuthenticationSignOutHandler + public class CookieAuthenticationHandler : SignInAuthenticationHandler { private const string HeaderValueNoCache = "no-cache"; private const string HeaderValueEpocDate = "Thu, 01 Jan 1970 00:00:00 GMT"; @@ -252,20 +249,13 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } } - public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + protected async override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { if (user == null) { throw new ArgumentNullException(nameof(user)); } - var target = ResolveTarget(Options.ForwardSignIn); - if (target != null) - { - await Context.SignInAsync(target, user, properties); - return; - } - properties = properties ?? new AuthenticationProperties(); _signInCalled = true; @@ -346,15 +336,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Logger.SignedIn(Scheme.Name); } - public async virtual Task SignOutAsync(AuthenticationProperties properties) + protected async override Task HandleSignOutAsync(AuthenticationProperties properties) { - var target = ResolveTarget(Options.ForwardSignOut); - if (target != null) - { - await Context.SignOutAsync(target, properties); - return; - } - properties = properties ?? new AuthenticationProperties(); _signOutCalled = true; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json new file mode 100644 index 0000000000..7673fc1a0e --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json @@ -0,0 +1,6 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler, Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs index 7bf8fe96ee..401b1f488c 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -91,15 +91,15 @@ namespace Microsoft.AspNetCore.Authentication } /// - /// Adds a based authentication handler which can be used to + /// Adds a based authentication handler which can be used to /// redirect to other authentication schemes. /// /// The name of this scheme. /// The display name of this scheme. /// Used to configure the scheme options. /// The builder. - public virtual AuthenticationBuilder AddVirtualScheme(string authenticationScheme, string displayName, Action configureOptions) - => AddSchemeHelper(authenticationScheme, displayName, configureOptions); + public virtual AuthenticationBuilder AddPolicyScheme(string authenticationScheme, string displayName, Action configureOptions) + => AddSchemeHelper(authenticationScheme, displayName, configureOptions); // Used to ensure that there's always a default sign in scheme that's not itself private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 4399ce5f74..5c9a6473f1 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; diff --git a/src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs b/src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs new file mode 100644 index 0000000000..4dbbb7de2d --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// PolicySchemes are used to redirect authentication methods to another scheme. + /// + public class PolicySchemeHandler : SignInAuthenticationHandler + { + public PolicySchemeHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { } + + protected override Task HandleChallengeAsync(AuthenticationProperties properties) + => throw new NotImplementedException(); + + protected override Task HandleForbiddenAsync(AuthenticationProperties properties) + => throw new NotImplementedException(); + + protected override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + => throw new NotImplementedException(); + + protected override Task HandleSignOutAsync(AuthenticationProperties properties) + => throw new NotImplementedException(); + + protected override Task HandleAuthenticateAsync() + => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs new file mode 100644 index 0000000000..1921c77ec8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs @@ -0,0 +1,11 @@ +// 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.AspNetCore.Authentication +{ + /// + /// Contains the options used by the . + /// + public class PolicySchemeOptions : AuthenticationSchemeOptions + { } +} diff --git a/src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs new file mode 100644 index 0000000000..dbd612dc10 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs @@ -0,0 +1,39 @@ +// 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.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Adds support for SignInAsync + /// + public abstract class SignInAuthenticationHandler : SignOutAuthenticationHandler, IAuthenticationSignInHandler + where TOptions : AuthenticationSchemeOptions, new() + { + public SignInAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { } + + public virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + { + var target = ResolveTarget(Options.ForwardSignIn); + return (target != null) + ? Context.SignInAsync(target, user, properties) + : HandleSignInAsync(user, properties ?? new AuthenticationProperties()); + } + + /// + /// Override this method to handle SignIn. + /// + /// + /// + /// A Task. + protected abstract Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties); + + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs new file mode 100644 index 0000000000..015cb39e05 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Adds support for SignOutAsync + /// + public abstract class SignOutAuthenticationHandler : AuthenticationHandler, IAuthenticationSignOutHandler + where TOptions : AuthenticationSchemeOptions, new() + { + public SignOutAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { } + + public virtual Task SignOutAsync(AuthenticationProperties properties) + { + var target = ResolveTarget(Options.ForwardSignOut); + return (target != null) + ? Context.SignOutAsync(target, properties) + : HandleSignOutAsync(properties ?? new AuthenticationProperties()); + } + + /// + /// Override this method to handle SignOut. + /// + /// + /// A Task. + protected abstract Task HandleSignOutAsync(AuthenticationProperties properties); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs deleted file mode 100644 index 4a023bec2c..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Security.Claims; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Forwards calls to another authentication scheme. - /// - public class VirtualAuthenticationHandler : IAuthenticationHandler, IAuthenticationSignInHandler - { - protected IOptionsMonitor OptionsMonitor { get; } - public AuthenticationScheme Scheme { get; private set; } - public VirtualSchemeOptions Options { get; private set; } - protected HttpContext Context { get; private set; } - - public VirtualAuthenticationHandler(IOptionsMonitor options) - { - OptionsMonitor = options; - } - - /// - /// Initialize the handler, resolve the options and validate them. - /// - /// - /// - /// A Task. - public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) - { - if (scheme == null) - { - throw new ArgumentNullException(nameof(scheme)); - } - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - Scheme = scheme; - Context = context; - - Options = OptionsMonitor.Get(Scheme.Name) ?? new VirtualSchemeOptions(); - Options.Validate(); - - return Task.CompletedTask; - } - - protected virtual string ResolveTarget(string scheme) - => scheme ?? Options.DefaultSelector?.Invoke(Context) ?? Options.Default; - - public virtual Task AuthenticateAsync() - => Context.AuthenticateAsync(ResolveTarget(Options.Authenticate)); - - public virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) - => Context.SignInAsync(ResolveTarget(Options.SignIn), user, properties); - - public virtual Task SignOutAsync(AuthenticationProperties properties) - => Context.SignOutAsync(ResolveTarget(Options.SignOut), properties); - - public virtual Task ChallengeAsync(AuthenticationProperties properties) - => Context.ChallengeAsync(ResolveTarget(Options.Challenge), properties); - - public virtual Task ForbidAsync(AuthenticationProperties properties) - => Context.ForbidAsync(ResolveTarget(Options.Forbid), properties); - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs deleted file mode 100644 index 38d819bf59..0000000000 --- a/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Used to redirect authentication methods to another scheme - /// - public class VirtualSchemeOptions - { - public string Default { get; set; } - - public string Authenticate { get; set; } - public string Challenge { get; set; } - public string Forbid { get; set; } - public string SignIn { get; set; } - public string SignOut { get; set; } - - /// - /// Used to select a default scheme to target based on the request. - /// - public Func DefaultSelector { get; set; } - - - /// - /// Check that the options are valid. Should throw an exception if things are not ok. - /// - public virtual void Validate() { } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs similarity index 85% rename from test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs index a43478c949..368026beb8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs @@ -12,26 +12,26 @@ using Xunit; namespace Microsoft.AspNetCore.Authentication { - public class VirtualHandlerTests + public class PolicyTests { [Fact] public async Task CanDispatch() { var server = CreateServer(services => { - services.AddAuthentication(o => + services.AddLogging().AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); o.AddScheme("auth3", "auth3"); }) - .AddVirtualScheme("policy1", "policy1", p => + .AddPolicyScheme("policy1", "policy1", p => { - p.Default = "auth1"; + p.ForwardDefault = "auth1"; }) - .AddVirtualScheme("policy2", "policy2", p => + .AddPolicyScheme("policy2", "policy2", p => { - p.Authenticate = "auth2"; + p.ForwardAuthenticate = "auth2"; }); }); @@ -54,16 +54,15 @@ namespace Microsoft.AspNetCore.Authentication [Fact] public async Task DefaultTargetSelectorWinsOverDefaultTarget() { - var services = new ServiceCollection().AddOptions(); - + var services = new ServiceCollection().AddOptions().AddLogging(); services.AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); }) - .AddVirtualScheme("forward", "forward", p => { - p.Default = "auth2"; - p.DefaultSelector = ctx => "auth1"; + .AddPolicyScheme("forward", "forward", p => { + p.ForwardDefault= "auth2"; + p.ForwardDefaultSelector = ctx => "auth1"; }); var handler1 = new TestHandler(); @@ -110,16 +109,15 @@ namespace Microsoft.AspNetCore.Authentication [Fact] public async Task NullDefaultTargetSelectorFallsBacktoDefaultTarget() { - var services = new ServiceCollection().AddOptions(); - + var services = new ServiceCollection().AddOptions().AddLogging(); services.AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); }) - .AddVirtualScheme("forward", "forward", p => { - p.Default = "auth1"; - p.DefaultSelector = ctx => null; + .AddPolicyScheme("forward", "forward", p => { + p.ForwardDefault= "auth1"; + p.ForwardDefaultSelector = ctx => null; }); var handler1 = new TestHandler(); @@ -166,21 +164,20 @@ namespace Microsoft.AspNetCore.Authentication [Fact] public async Task SpecificTargetAlwaysWinsOverDefaultTarget() { - var services = new ServiceCollection().AddOptions(); - + var services = new ServiceCollection().AddOptions().AddLogging(); services.AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); }) - .AddVirtualScheme("forward", "forward", p => { - p.Default = "auth2"; - p.DefaultSelector = ctx => "auth2"; - p.Authenticate = "auth1"; - p.SignIn = "auth1"; - p.SignOut = "auth1"; - p.Forbid = "auth1"; - p.Challenge = "auth1"; + .AddPolicyScheme("forward", "forward", p => { + p.ForwardDefault= "auth2"; + p.ForwardDefaultSelector = ctx => "auth2"; + p.ForwardAuthenticate = "auth1"; + p.ForwardSignIn = "auth1"; + p.ForwardSignOut = "auth1"; + p.ForwardForbid = "auth1"; + p.ForwardChallenge = "auth1"; }); var handler1 = new TestHandler(); @@ -227,14 +224,13 @@ namespace Microsoft.AspNetCore.Authentication [Fact] public async Task VirtualSchemeTargetsForwardWithDefaultTarget() { - var services = new ServiceCollection().AddOptions(); - + var services = new ServiceCollection().AddOptions().AddLogging(); services.AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); }) - .AddVirtualScheme("forward", "forward", p => p.Default = "auth1"); + .AddPolicyScheme("forward", "forward", p => p.ForwardDefault= "auth1"); var handler1 = new TestHandler(); services.AddSingleton(handler1); @@ -280,18 +276,17 @@ namespace Microsoft.AspNetCore.Authentication [Fact] public async Task VirtualSchemeTargetsOverrideDefaultTarget() { - var services = new ServiceCollection().AddOptions(); - + var services = new ServiceCollection().AddOptions().AddLogging(); services.AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); }) - .AddVirtualScheme("forward", "forward", p => + .AddPolicyScheme("forward", "forward", p => { - p.Default = "auth1"; - p.Challenge = "auth2"; - p.SignIn = "auth2"; + p.ForwardDefault= "auth1"; + p.ForwardChallenge = "auth2"; + p.ForwardSignIn = "auth2"; }); var handler1 = new TestHandler(); @@ -346,9 +341,9 @@ namespace Microsoft.AspNetCore.Authentication o.AddScheme("auth2", "auth2"); o.AddScheme("auth3", "auth3"); }) - .AddVirtualScheme("dynamic", "dynamic", p => + .AddPolicyScheme("dynamic", "dynamic", p => { - p.DefaultSelector = c => c.Request.QueryString.Value.Substring(1); + p.ForwardDefaultSelector = c => c.Request.QueryString.Value.Substring(1); }); }); @@ -360,39 +355,6 @@ namespace Microsoft.AspNetCore.Authentication Assert.Equal("auth3", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth3")); } - [Fact] - public async Task TargetsDefaultSchemeByDefault() - { - var server = CreateServer(services => - { - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.AddScheme("default", "default"); - }) - .AddVirtualScheme("virtual", "virtual", p => { }); - }); - - var transaction = await server.SendAsync("http://example.com/auth/virtual"); - Assert.Equal("default", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "default")); - } - - [Fact] - public async Task TargetsDefaultSchemeThrowsWithNoDefault() - { - var server = CreateServer(services => - { - services.AddAuthentication(o => - { - o.AddScheme("default", "default"); - }) - .AddVirtualScheme("virtual", "virtual", p => { }); - }); - - var error = await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/virtual")); - Assert.Contains("No authenticationScheme was specified", error.Message); - } - private class TestHandler : IAuthenticationSignInHandler { public AuthenticationScheme Scheme { get; set; } From 2fecba74511054290e90b88d1502048fc71fa452 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 11:16:57 -0700 Subject: [PATCH 871/900] Branching for 2.1.0-preview2 --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- build/repo.props | 4 +-- build/sources.props | 2 +- korebuild-lock.txt | 4 +-- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d0cb88aa82..d0dfac301f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15728 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 + 2.1.0-preview2-15742 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview2-26225-03 + 2.1.0-preview2-26314-02 15.6.0 3.0.1 3.0.1 diff --git a/build/repo.props b/build/repo.props index 541470c9f4..2ab5a2ae35 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -7,7 +7,7 @@ Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index 9215df9751..36045f12b5 100644 --- a/build/sources.props +++ b/build/sources.props @@ -6,7 +6,7 @@ $(RestoreSources); https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 138d848db1..e40ef6651b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15728 -commithash:393377068ddcf51dfee0536536d455f57a828b06 +version:2.1.0-preview2-15742 +commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 From 701c9f083f419354953726a0e1affd4eda87b3d5 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 11:28:13 -0700 Subject: [PATCH 872/900] Update version prefix to preview3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index a11ea1ed52..24f2b00a0a 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview2 + preview3 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From be3473914af496764d06069a0e516763cf604335 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 12:33:48 -0700 Subject: [PATCH 873/900] Update KoreBuild channel --- korebuild.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } From 81fb221d9e1d08cdda8d1fabcb43f900848e4bdf Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Tue, 20 Mar 2018 12:42:16 -0700 Subject: [PATCH 874/900] Embed OIDC metadata and mock out the backchannel #1686 --- ...soft.AspNetCore.Authentication.Test.csproj | 7 ++++ .../OpenIdConnect/TestSettings.cs | 40 ++++++++++++++++++- .../OpenIdConnect/wellknownconfig.json | 23 +++++++++++ .../OpenIdConnect/wellknownkeys.json | 31 ++++++++++++++ 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 469726690f..6c8d518ffa 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -5,6 +5,8 @@ + + @@ -22,6 +24,11 @@ + + + + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 509b85e64e..6bb5445dc6 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -4,10 +4,14 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; +using System.Net.Http; using System.Reflection; using System.Text; using System.Text.Encodings.Web; +using System.Threading; +using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.TestHost; @@ -22,6 +26,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect internal class TestSettings { private readonly Action _configureOptions; + private OpenIdConnectOptions _options; public TestSettings() : this(configure: null) { @@ -33,6 +38,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { configure?.Invoke(o); _options = o; + _options.BackchannelHttpHandler = new MockBackchannel(); }; } @@ -206,8 +212,6 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } } - OpenIdConnectOptions _options = null; - private void ValidateExpectedAuthority(string absoluteUri, ICollection errors, OpenIdConnectRequestType requestType) { string expectedAuthority; @@ -305,5 +309,37 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect errors.Add($"Parameter {parameterName} is missing"); } } + + private class MockBackchannel : HttpMessageHandler + { + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + if (request.RequestUri.AbsoluteUri.Equals("https://login.microsoftonline.com/common/.well-known/openid-configuration")) + { + return await ReturnResource("wellknownconfig.json"); + } + if (request.RequestUri.AbsoluteUri.Equals("https://login.microsoftonline.com/common/discovery/keys")) + { + return await ReturnResource("wellknownkeys.json"); + } + + throw new NotImplementedException(); + } + + private async Task ReturnResource(string resource) + { + var resourceName = "Microsoft.AspNetCore.Authentication.Test.OpenIdConnect." + resource; + using (var stream = typeof(MockBackchannel).Assembly.GetManifestResourceStream(resourceName)) + using (var reader = new StreamReader(stream)) + { + var body = await reader.ReadToEndAsync(); + var content = new StringContent(body, Encoding.UTF8, "application/json"); + return new HttpResponseMessage() + { + Content = content, + }; + } + } + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json new file mode 100644 index 0000000000..4d46a8cf0a --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json @@ -0,0 +1,23 @@ +{ + "authorization_endpoint": "https://login.microsoftonline.com/common/oauth2/authorize", + "token_endpoint": "https://login.microsoftonline.com/common/oauth2/token", + "token_endpoint_auth_methods_supported": [ "client_secret_post", "private_key_jwt", "client_secret_basic" ], + "jwks_uri": "https://login.microsoftonline.com/common/discovery/keys", + "response_modes_supported": [ "query", "fragment", "form_post" ], + "subject_types_supported": [ "pairwise" ], + "id_token_signing_alg_values_supported": [ "RS256" ], + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/common/oauth2/logout", + "response_types_supported": [ "code", "id_token", "code id_token", "token id_token", "token" ], + "scopes_supported": [ "openid" ], + "issuer": "https://sts.windows.net/{tenantid}/", + "claims_supported": [ "sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "amr", "nonce", "email", "given_name", "family_name", "nickname" ], + "microsoft_multi_refresh_token": true, + "check_session_iframe": "https://login.microsoftonline.com/common/oauth2/checksession", + "userinfo_endpoint": "https://login.microsoftonline.com/common/openid/userinfo", + "tenant_region_scope": null, + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com" +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json new file mode 100644 index 0000000000..77cc5562af --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json @@ -0,0 +1,31 @@ +{ + "keys": [ + { + "kty": "RSA", + "use": "sig", + "kid": "SSQdhI1cKvhQEDSJxE2gGYs40Q0", + "x5t": "SSQdhI1cKvhQEDSJxE2gGYs40Q0", + "n": "pJUB90EMxiNjgkVz5CLLUuG5bYwirL2LXfVsq_nnY686WzbinkvFnNs6LvrJ6DWD5NV1-0Tq2eZj7WU8H9ytmDPsRnJ0b49gRCJYOg6-SdOe9Tl0lB0IBJE1aWh3OdCVrZLE4LH4-LGIDrkwnCV8dKFkO3EIUYPaEysL4g4wLx-TCfpMWE37XC09P-nBRVkRNcihrzY38_MC42NkRdDwByZemXkQKddnn5Y5o4rVzPGqQy3vjmTjKolYEIBYa7n3yF0848MG0k338bjnyceJgmZzjxttkWTVDikQXSldbu3QCrCAlipbWPUAXaZK8buY8LP80G4U_wx4LuZ_Krq5OQ", + "e": "AQAB", + "x5c": [ "MIIDBTCCAe2gAwIBAgIQHJ7yHxNEM7tBeqcRTMBhhTANBgkqhkiG9w0BAQsFADAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MB4XDTE4MDEwODAwMDAwMFoXDTIwMDEwOTAwMDAwMFowLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKSVAfdBDMYjY4JFc+Qiy1LhuW2MIqy9i131bKv552OvOls24p5LxZzbOi76yeg1g+TVdftE6tnmY+1lPB/crZgz7EZydG+PYEQiWDoOvknTnvU5dJQdCASRNWlodznQla2SxOCx+PixiA65MJwlfHShZDtxCFGD2hMrC+IOMC8fkwn6TFhN+1wtPT/pwUVZETXIoa82N/PzAuNjZEXQ8AcmXpl5ECnXZ5+WOaOK1czxqkMt745k4yqJWBCAWGu598hdPOPDBtJN9/G458nHiYJmc48bbZFk1Q4pEF0pXW7t0AqwgJYqW1j1AF2mSvG7mPCz/NBuFP8MeC7mfyq6uTkCAwEAAaMhMB8wHQYDVR0OBBYEFFVWt/4iTcBiWk+EX1dCKZGoAlBQMA0GCSqGSIb3DQEBCwUAA4IBAQCJrLUiCfldfDFhZLG08DpLcwpn8Mvhm61ZpPANyCawRgaoBOsxFJew1qpC2wfXh3yUwJEIkkTGXAsiWENkeqmjd2XXQwZuIHIo5/KyZLfo2m1CmEH/QXL6uRx1f8liPr4efC8H+7/sduf6nPfk0UpNsAHA6RxJFy2jg2wHU+Ux4jK4Gc5d/rJPhJhvyS9Zax1hbTlf+N32ZvS780VMDb/nf2LdtACL0ya/+KSDGVXS3GhS9FLEXrBNjq921ghVIFJhPzm54yfeupIwz+zfISoTHIYw37i7iNUbkvDrm14a27pwLS/tfSuJHKcGPt1sjMu6SS/pf1BlvdoFkKdLLaUb" ] + }, + { + "kty": "RSA", + "use": "sig", + "kid": "FSimuFrFNoC0sJXGmv13nNZceDc", + "x5t": "FSimuFrFNoC0sJXGmv13nNZceDc", + "n": "yCYaJF8uHoV2L31cjZUDdcodK1Y1EsTLkDD-DEXFyGeHaQ92T9t6MU6zazBzHvJRarG6OMI1GwsFxZ9opSVOeuRjuL3H2ehmUyuKOAnL8uT4cfkdfbg9AIN_63COccfFn0br_xUszZ7lkF5mb63sze-G66YQcbdTCWgsXpxR6491b57Gc4HVTV8cEgU4byezhJIiirrPDmt23QJIjr6XtvUMSNW88u0kX7PKOUnVCns2AG8DB2I-JExTiXwhFVu5JUqgpgmjIngvd5eyNzOgFJMnpWNXabKDP3oMLvQxjdq9xwWuTu0IQLpmUxEF9jVc8vKV1Pu2xHcS7ON5xJrUzw", + "e": "AQAB", + "x5c": [ "MIIDBTCCAe2gAwIBAgIQev76BWqjWZxChmKkGqoAfDANBgkqhkiG9w0BAQsFADAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MB4XDTE4MDIxODAwMDAwMFoXDTIwMDIxOTAwMDAwMFowLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMgmGiRfLh6Fdi99XI2VA3XKHStWNRLEy5Aw/gxFxchnh2kPdk/bejFOs2swcx7yUWqxujjCNRsLBcWfaKUlTnrkY7i9x9noZlMrijgJy/Lk+HH5HX24PQCDf+twjnHHxZ9G6/8VLM2e5ZBeZm+t7M3vhuumEHG3UwloLF6cUeuPdW+exnOB1U1fHBIFOG8ns4SSIoq6zw5rdt0CSI6+l7b1DEjVvPLtJF+zyjlJ1Qp7NgBvAwdiPiRMU4l8IRVbuSVKoKYJoyJ4L3eXsjczoBSTJ6VjV2mygz96DC70MY3avccFrk7tCEC6ZlMRBfY1XPLyldT7tsR3EuzjecSa1M8CAwEAAaMhMB8wHQYDVR0OBBYEFIks1srixjpSLXeiR8zES5cTY6fBMA0GCSqGSIb3DQEBCwUAA4IBAQCKthfK4C31DMuDyQZVS3F7+4Evld3hjiwqu2uGDK+qFZas/D/eDunxsFpiwqC01RIMFFN8yvmMjHphLHiBHWxcBTS+tm7AhmAvWMdxO5lzJLS+UWAyPF5ICROe8Mu9iNJiO5JlCo0Wpui9RbB1C81Xhax1gWHK245ESL6k7YWvyMYWrGqr1NuQcNS0B/AIT1Nsj1WY7efMJQOmnMHkPUTWryVZlthijYyd7P2Gz6rY5a81DAFqhDNJl2pGIAE6HWtSzeUEh3jCsHEkoglKfm4VrGJEuXcALmfCMbdfTvtu4rlsaP2hQad+MG/KJFlenoTK34EMHeBPDCpqNDz8UVNk" ] + }, + { + "kty": "RSA", + "use": "sig", + "kid": "2S4SCVGs8Sg9LS6AqLIq6DpW-g8", + "x5t": "2S4SCVGs8Sg9LS6AqLIq6DpW-g8", + "n": "oZ-QQrNuB4ei9ATYrT61ebPtvwwYWnsrTpp4ISSp6niZYb92XM0oUTNgqd_C1vGN8J-y9wCbaJWkpBf46CjdZehrqczPhzhHau8WcRXocSB1u_tuZhv1ooAZ4bAcy79UkeLiG60HkuTNJJC8CfaTp1R97szBhuk0Vz5yt4r5SpfewIlBCnZUYwkDS172H9WapQu-3P2Qjh0l-JLyCkdrhvizZUk0atq5_AIDKRU-A0pRGc-EZhUL0LqUMz6c6M2s_4GnQaScv44A5iZUDD15B6e8Apb2yARohkWmOnmRcTVfes8EkfxjzZEzm3cNkvP0ogILyISHKlkzy2OmlU6iXw", + "e": "AQAB", + "x5c": [ "MIIDKDCCAhCgAwIBAgIQBHJvVNxP1oZO4HYKh+rypDANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDExhsb2dpbi5taWNyb3NvZnRvbmxpbmUudXMwHhcNMTYxMTE2MDgwMDAwWhcNMTgxMTE2MDgwMDAwWjAjMSEwHwYDVQQDExhsb2dpbi5taWNyb3NvZnRvbmxpbmUudXMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQChn5BCs24Hh6L0BNitPrV5s+2/DBhaeytOmnghJKnqeJlhv3ZczShRM2Cp38LW8Y3wn7L3AJtolaSkF/joKN1l6GupzM+HOEdq7xZxFehxIHW7+25mG/WigBnhsBzLv1SR4uIbrQeS5M0kkLwJ9pOnVH3uzMGG6TRXPnK3ivlKl97AiUEKdlRjCQNLXvYf1ZqlC77c/ZCOHSX4kvIKR2uG+LNlSTRq2rn8AgMpFT4DSlEZz4RmFQvQupQzPpzozaz/gadBpJy/jgDmJlQMPXkHp7wClvbIBGiGRaY6eZFxNV96zwSR/GPNkTObdw2S8/SiAgvIhIcqWTPLY6aVTqJfAgMBAAGjWDBWMFQGA1UdAQRNMEuAEDUj0BrjP0RTbmoRPTRMY3WhJTAjMSEwHwYDVQQDExhsb2dpbi5taWNyb3NvZnRvbmxpbmUudXOCEARyb1TcT9aGTuB2Cofq8qQwDQYJKoZIhvcNAQELBQADggEBAGnLhDHVz2gLDiu9L34V3ro/6xZDiSWhGyHcGqky7UlzQH3pT5so8iF5P0WzYqVtogPsyC2LPJYSTt2vmQugD4xlu/wbvMFLcV0hmNoTKCF1QTVtEQiAiy0Aq+eoF7Al5fV1S3Sune0uQHimuUFHCmUuF190MLcHcdWnPAmzIc8fv7quRUUsExXmxSX2ktUYQXzqFyIOSnDCuWFm6tpfK5JXS8fW5bpqTlrysXXz/OW/8NFGq/alfjrya4ojrOYLpunGriEtNPwK7hxj1AlCYEWaRHRXaUIW1ByoSff/6Y6+ZhXPUe0cDlNRt/qIz5aflwO7+W8baTS4O8m/icu7ItE=" ] + } + ] +} \ No newline at end of file From 46e62b2b673a8d11b65b5a443715927097138d4f Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 14 Mar 2018 15:35:22 -0700 Subject: [PATCH 875/900] Set 2.0 baselines --- build/dependencies.props | 2 +- korebuild-lock.txt | 4 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 1314 +++++++++++++++++ .../baseline.netcore.json | 47 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netframework.json | 2 +- 16 files changed, 1330 insertions(+), 61 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json diff --git a/build/dependencies.props b/build/dependencies.props index d0dfac301f..d80ecef5ae 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,7 +3,7 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15742 + 2.1.0-preview2-15744 2.1.0-preview2-30355 2.1.0-preview2-30355 2.1.0-preview2-30355 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e40ef6651b..f531e7b0f7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15742 -commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 +version:2.1.0-preview2-15744 +commithash:9e15cb6062ab5b9790d3fa699e018543a6950713 diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json index 1f1115460b..52fa29be91 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.CookieExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json index 82a48a6bf4..2500e5fb5e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json index 61aae649d3..edaade3267 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.GoogleExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json index 997cf7bdf1..44fc928cac 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.JwtBearerExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json index 5791297b27..966f7e1b1f 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json index ffda3cbafe..142e37c6bd 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.OAuthExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json index 9623b214e8..a57e2eb872 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.OpenIdConnectExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json index b577f07eb1..196b85372d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.TwitterExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json new file mode 100644 index 0000000000..5a8110fbce --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json @@ -0,0 +1,1314 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.WsFederation, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.Extensions.DependencyInjection.WsFederationExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddWsFederation", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddWsFederation", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddWsFederation", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddWsFederation", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.AuthenticationFailedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Exception", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Exception", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.MessageReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.RedirectContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Handled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.RemoteSignOutContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + }, + { + "Name": "message", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.SecurityTokenReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.SecurityTokenValidatedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SecurityToken", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.SecurityToken", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SecurityToken", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.SecurityToken" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnAuthenticationFailed", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnAuthenticationFailed", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnMessageReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnMessageReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToIdentityProvider", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToIdentityProvider", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRemoteSignOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRemoteSignOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSecurityTokenReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSecurityTokenReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSecurityTokenValidated", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSecurityTokenValidated", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthenticationFailed", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.AuthenticationFailedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToIdentityProvider", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoteSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SecurityTokenReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.SecurityTokenReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SecurityTokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.SecurityTokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "UserstatePropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"WsFederation\"" + }, + { + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"WsFederation\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteSignOutAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationConfiguration", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationConfiguration" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_MetadataAddress", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MetadataAddress", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ConfigurationManager", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.IConfigurationManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConfigurationManager", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.IConfigurationManager" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshOnIssuerKeyNotFound", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RefreshOnIssuerKeyNotFound", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SkipUnrecognizedRequests", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SkipUnrecognizedRequests", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SecurityTokenHandlers", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SecurityTokenHandlers", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.ICollection" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StateDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenValidationParameters", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.TokenValidationParameters", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenValidationParameters", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.TokenValidationParameters" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Wreply", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Wreply", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignOutWreply", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignOutWreply", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Wtrealm", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Wtrealm", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UseTokenLifetime", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UseTokenLifetime", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RequireHttpsMetadata", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RequireHttpsMetadata", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowUnsolicitedLogins", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AllowUnsolicitedLogins", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RemoteSignOutPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RemoteSignOutPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignOutScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignOutScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationPostConfigureOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json index 6db7d2c81d..a6082e8c46 100644 --- a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", @@ -2508,51 +2508,6 @@ ], "GenericParameters": [] }, - { - "Name": "Microsoft.AspNetCore.Authentication.Internal.RequestPathBaseCookieBuilder", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Http.CookieBuilder", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AdditionalPath", - "Parameters": [], - "ReturnType": "System.String", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Build", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "expiresFrom", - "Type": "System.DateTimeOffset" - } - ], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, { "Name": "Microsoft.AspNetCore.Builder.AuthAppBuilderExtensions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json index 0bad3ed62c..a2a971f826 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", diff --git a/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json index 6108db6d29..9910c93f6a 100644 --- a/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.AuthorizationServiceCollectionExtensions", diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json index 97da7ea5c6..050546810f 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json index a55bf8f339..65256bed6f 100644 --- a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json +++ b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", From 90064ce9dfc79d13058fbd6ec9092bf0f6124449 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 2 Feb 2018 10:53:51 -0800 Subject: [PATCH 876/900] Add ClaimActions for bulk add and remove. #1609 --- samples/OpenIdConnectSample/Startup.cs | 7 +++ .../ClaimActionCollectionMapExtensions.cs | 39 +++++++++++++ .../Claims/MapAllClaimsAction.cs | 42 ++++++++++++++ .../ClaimActionTests.cs | 57 +++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index c05bc8b522..82bfdf54f1 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Net.Http; using System.Text.Encodings.Web; @@ -44,6 +45,8 @@ namespace OpenIdConnectSample public void ConfigureServices(IServiceCollection services) { + JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); + services.AddAuthentication(sharedOptions => { sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; @@ -56,9 +59,13 @@ namespace OpenIdConnectSample o.ClientId = Configuration["oidc:clientid"]; o.ClientSecret = Configuration["oidc:clientsecret"]; // for code flow o.Authority = Configuration["oidc:authority"]; + o.ResponseType = OpenIdConnectResponseType.CodeIdToken; o.SaveTokens = true; o.GetClaimsFromUserInfoEndpoint = true; + + o.ClaimActions.MapAllExcept("aud", "iss", "iat", "nbf", "exp", "aio", "c_hash", "uti", "nonce"); + o.Events = new OpenIdConnectEvents() { OnAuthenticationFailed = c => diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs index f3fee6a229..5a178957a0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs @@ -87,6 +87,27 @@ namespace Microsoft.AspNetCore.Authentication collection.Add(new CustomJsonClaimAction(claimType, valueType, resolver)); } + /// + /// Clears any current ClaimsActions and maps all values from the json user data as claims, excluding duplicates. + /// + /// + public static void MapAll(this ClaimActionCollection collection) + { + collection.Clear(); + collection.Add(new MapAllClaimsAction()); + } + + /// + /// Clears any current ClaimsActions and maps all values from the json user data as claims, excluding the specified types. + /// + /// + /// + public static void MapAllExcept(this ClaimActionCollection collection, params string[] exclusions) + { + collection.MapAll(); + collection.DeleteClaims(exclusions); + } + /// /// Delete all claims from the given ClaimsIdentity with the given ClaimType. /// @@ -96,5 +117,23 @@ namespace Microsoft.AspNetCore.Authentication { collection.Add(new DeleteClaimAction(claimType)); } + + /// + /// Delete all claims from the ClaimsIdentity with the given claimTypes. + /// + /// + /// + public static void DeleteClaims(this ClaimActionCollection collection, params string[] claimTypes) + { + if (claimTypes == null) + { + throw new ArgumentNullException(nameof(claimTypes)); + } + + foreach (var claimType in claimTypes) + { + collection.Add(new DeleteClaimAction(claimType)); + } + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs new file mode 100644 index 0000000000..b3bf5d99f1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs @@ -0,0 +1,42 @@ +// 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.Security.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication.OAuth.Claims +{ + /// + /// A ClaimAction that selects all top level values from the json user data and adds them as Claims. + /// This excludes duplicate sets of names and values. + /// + public class MapAllClaimsAction : ClaimAction + { + public MapAllClaimsAction() : base("All", ClaimValueTypes.String) + { + } + + public override void Run(JObject userData, ClaimsIdentity identity, string issuer) + { + if (userData == null) + { + return; + } + foreach (var pair in userData) + { + var claimValue = userData.TryGetValue(pair.Key, out var value) ? value.ToString() : null; + + // Avoid adding a claim if there's a duplicate name and value. This often happens in OIDC when claims are + // retrieved both from the id_token and from the user-info endpoint. + var duplicate = identity.FindFirst(c => string.Equals(c.Type, pair.Key, StringComparison.OrdinalIgnoreCase) + && string.Equals(c.Value, claimValue, StringComparison.Ordinal)) != null; + + if (!duplicate) + { + identity.AddClaim(new Claim(pair.Key, claimValue, ClaimValueTypes.String, issuer)); + } + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs index 541e1edf28..b083e9d76d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs @@ -51,5 +51,62 @@ namespace Microsoft.AspNetCore.Authentication Assert.Equal("role", roleClaims[1].Type); Assert.Equal("role2", roleClaims[1].Value); } + + [Fact] + public void MapAllSucceeds() + { + var userData = new JObject + { + ["name0"] = "value0", + ["name1"] = "value1", + }; + + var identity = new ClaimsIdentity(); + var action = new MapAllClaimsAction(); + action.Run(userData, identity, "iss"); + + Assert.Equal("name0", identity.FindFirst("name0").Type); + Assert.Equal("value0", identity.FindFirst("name0").Value); + Assert.Equal("name1", identity.FindFirst("name1").Type); + Assert.Equal("value1", identity.FindFirst("name1").Value); + } + + [Fact] + public void MapAllAllowesDulicateKeysWithUniqueValues() + { + var userData = new JObject + { + ["name0"] = "value0", + ["name1"] = "value1", + }; + + var identity = new ClaimsIdentity(); + identity.AddClaim(new Claim("name0", "value2")); + identity.AddClaim(new Claim("name1", "value3")); + var action = new MapAllClaimsAction(); + action.Run(userData, identity, "iss"); + + Assert.Equal(2, identity.FindAll("name0").Count()); + Assert.Equal(2, identity.FindAll("name1").Count()); + } + + [Fact] + public void MapAllSkipsDuplicateValues() + { + var userData = new JObject + { + ["name0"] = "value0", + ["name1"] = "value1", + }; + + var identity = new ClaimsIdentity(); + identity.AddClaim(new Claim("name0", "value0")); + identity.AddClaim(new Claim("name1", "value1")); + var action = new MapAllClaimsAction(); + action.Run(userData, identity, "iss"); + + Assert.Single(identity.FindAll("name0")); + Assert.Single(identity.FindAll("name1")); + } } } From d24fddcf596a705f480a6ca6e43446838a4af2fe Mon Sep 17 00:00:00 2001 From: Patrick Westerhoff Date: Mon, 19 Mar 2018 22:19:57 +0100 Subject: [PATCH 877/900] Clean up tests - Make Facebook test server asynchronous to avoid having to block for the result. - Clean up some formatting. --- .../FacebookTests.cs | 52 +++++++++---------- .../GoogleTests.cs | 34 ++++++------ 2 files changed, 40 insertions(+), 46 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 99177d66bb..4ee9117f95 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -426,15 +426,15 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { var server = CreateServer( app => { }, - services => services.AddAuthentication().AddFacebook(o => { + services => services.AddAuthentication().AddFacebook(o => + { o.AppId = "whatever"; o.AppSecret = "whatever"; o.SignInScheme = FacebookDefaults.AuthenticationScheme; }), - context => + async context => { - // Gross - context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + await context.ChallengeAsync("Facebook"); return true; }); var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); @@ -446,14 +446,14 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { var server = CreateServer( app => { }, - services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => { + services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => + { o.AppId = "whatever"; o.AppSecret = "whatever"; }), - context => + async context => { - // Gross - context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + await context.ChallengeAsync("Facebook"); return true; }); var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); @@ -465,14 +465,14 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { var server = CreateServer( app => { }, - services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => { + services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => + { o.AppId = "whatever"; o.AppSecret = "whatever"; }), - context => + async context => { - // Gross - context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + await context.ChallengeAsync("Facebook"); return true; }); var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); @@ -498,10 +498,9 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var server = CreateServer( app => { }, services => services.AddAuthentication().AddFacebook(o => o.SignInScheme = "Whatever"), - context => + async context => { - // REVIEW: Gross. - Assert.Throws("AppId", () => context.ChallengeAsync("Facebook").GetAwaiter().GetResult()); + await Assert.ThrowsAsync("AppId", () => context.ChallengeAsync("Facebook")); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -514,10 +513,9 @@ namespace Microsoft.AspNetCore.Authentication.Facebook var server = CreateServer( app => { }, services => services.AddAuthentication().AddFacebook(o => o.AppId = "Whatever"), - context => + async context => { - // REVIEW: Gross. - Assert.Throws("AppSecret", () => context.ChallengeAsync("Facebook").GetAwaiter().GetResult()); + await Assert.ThrowsAsync("AppSecret", () => context.ChallengeAsync("Facebook")); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -550,10 +548,9 @@ namespace Microsoft.AspNetCore.Authentication.Facebook }; }); }, - context => + async context => { - // REVIEW: Gross. - context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + await context.ChallengeAsync("Facebook"); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -620,7 +617,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); - Assert.Contains("redirect_uri="+ UrlEncoder.Default.Encode("http://example.com/signin-facebook"), location); + Assert.Contains("redirect_uri=" + UrlEncoder.Default.Encode("http://example.com/signin-facebook"), location); Assert.Contains("scope=", location); Assert.Contains("state=", location); } @@ -643,10 +640,9 @@ namespace Microsoft.AspNetCore.Authentication.Facebook o.AppSecret = "Test App Secret"; }); }, - context => + async context => { - // REVIEW: gross - context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + await context.ChallengeAsync("Facebook"); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -672,7 +668,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie() - .AddFacebook(o => + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; @@ -728,7 +724,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook Assert.Contains("&access_token=", finalUserInfoEndpoint); } - private static TestServer CreateServer(Action configure, Action configureServices, Func handler) + private static TestServer CreateServer(Action configure, Action configureServices, Func> handler) { var builder = new WebHostBuilder() .Configure(app => @@ -736,7 +732,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook configure?.Invoke(app); app.Use(async (context, next) => { - if (handler == null || !handler(context)) + if (handler == null || !await handler(context)) { await next(); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index c3e80ef71a..d9af959360 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -551,28 +551,26 @@ namespace Microsoft.AspNetCore.Authentication.Google { o.ClientId = "Test Id"; o.ClientSecret = "Test Secret"; - //AutomaticChallenge = true }, context => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/challenge2")) { - var req = context.Request; - var res = context.Response; - if (req.Path == new PathString("/challenge2")) + return context.ChallengeAsync("Google", new AuthenticationProperties(new Dictionary() { - return context.ChallengeAsync("Google", new AuthenticationProperties( - new Dictionary() - { - { "scope", "https://www.googleapis.com/auth/plus.login" }, - { "access_type", "offline" }, - { "approval_prompt", "force" }, - { "prompt", "consent" }, - { "login_hint", "test@example.com" }, - { "include_granted_scopes", "false" } - })); - } + { "scope", "https://www.googleapis.com/auth/plus.login" }, + { "access_type", "offline" }, + { "approval_prompt", "force" }, + { "prompt", "consent" }, + { "login_hint", "test@example.com" }, + { "include_granted_scopes", "false" } + })); + } - return Task.FromResult(null); - }); + return Task.FromResult(null); + }); var transaction = await server.SendAsync("https://example.com/challenge2"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var query = transaction.Response.Headers.Location.Query; @@ -1501,4 +1499,4 @@ namespace Microsoft.AspNetCore.Authentication.Google } } } -} +} \ No newline at end of file From 06c93669d617fec50bf411c0c53d672019adf9df Mon Sep 17 00:00:00 2001 From: Patrick Westerhoff Date: Fri, 23 Mar 2018 02:09:05 +0100 Subject: [PATCH 878/900] Allow overwriting parameters on challenge requests Add a way to overwrite query arguments that are passed as part of the challenge request to the external authentication provider in OAuth-based authentication providers, including OpenID Connect. This uses the new `AuthenticationProperties.Parameters` collection to pass parameters to the authentication handler which will then look for special items within that property bag, overwriting previously configured values within the authentication options. This can be used for example to overwrite the OAuth scopes that are requested from an authentication provider, or to explicitly trigger a reauthentication by requiring a login prompt with OpenID Connect. By being able to specify this on individual challenge requests (using `HttpContext.ChallengeAsync`), this is independent from the global scheme configuration. Custom ~ChallengeProperties types, e.g. `OAuthChallengeProperties` for OAuth-based authentication providers, provide assistance in setting the challenge request parameters but are not required to make the handlers use the overwritten values. - Adjust authentication handlers to respect the custom parameters, and add ~ChallengeProperties types. - Introduce `OAuthHandler.FormatScope(IEnumerable)` to format a custom set of scopes. Subclasses requiring a different scope format should override this method instead of the parameterless overload. Overriding just `FormatScope()` will prevent handlers from supporting overwriting the OAuth `scope` in a challenge request. - Refactor GoogleHandler to support parameterization through both the `Parameters` and the `Items` collection (former is preferred) to keep compatibility with the old behavior. - Add an OpenIdConnect sample to overwrite the prompt argument in a challenge request. - Add extensive tests. --- samples/OpenIdConnectSample/Startup.cs | 17 ++ .../FacebookHandler.cs | 8 +- .../GoogleChallengeProperties.cs | 89 ++++++++++ .../GoogleHandler.cs | 61 ++++--- .../OAuthChallengeProperties.cs | 41 +++++ .../OAuthHandler.cs | 23 ++- .../OpenIdConnectChallengeProperties.cs | 49 ++++++ .../OpenIdConnectHandler.cs | 11 +- .../FacebookTests.cs | 91 ++++++++++ .../GoogleTests.cs | 138 ++++++++++++++- .../MicrosoftAccountTests.cs | 63 +++++++ .../OAuthChallengePropertiesTest.cs | 149 ++++++++++++++++ .../OAuthTests.cs | 82 +++++++++ .../OpenIdConnectChallengeTests.cs | 166 +++++++++++++++++- .../OpenIdConnect/TestSettings.cs | 6 + 15 files changed, 944 insertions(+), 50 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 82bfdf54f1..1aa7625cb0 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -225,11 +225,28 @@ namespace OpenIdConnectSample return; } + if (context.Request.Path.Equals("/login-challenge")) + { + // Challenge the user authentication, and force a login prompt by overwriting the + // "prompt". This could be used for example to require the user to re-enter their + // credentials at the authentication provider, to add an extra confirmation layer. + await context.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new OpenIdConnectChallengeProperties() + { + Prompt = "login", + + // it is also possible to specify different scopes, e.g. + // Scope = new string[] { "openid", "profile", "other" } + }); + + return; + } + await WriteHtmlAsync(response, async res => { await res.WriteAsync($"

Hello Authenticated User {HtmlEncode(user.Identity.Name)}

"); await res.WriteAsync("Refresh tokens"); await res.WriteAsync("Restricted"); + await res.WriteAsync("Login challenge"); await res.WriteAsync("Sign Out"); await res.WriteAsync("Sign Out Remote"); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 0f83c17196..eb42511431 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.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.Collections.Generic; using System.Globalization; using System.Net.Http; using System.Security.Claims; @@ -65,12 +66,15 @@ namespace Microsoft.AspNetCore.Authentication.Facebook } } - protected override string FormatScope() + protected override string FormatScope(IEnumerable scopes) { // Facebook deviates from the OAuth spec here. They require comma separated instead of space separated. // https://developers.facebook.com/docs/reference/dialogs/oauth // http://tools.ietf.org/html/rfc6749#section-3.3 - return string.Join(",", Options.Scope); + return string.Join(",", scopes); } + + protected override string FormatScope() + => base.FormatScope(); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs new file mode 100644 index 0000000000..714df45655 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Authentication.OAuth; + +namespace Microsoft.AspNetCore.Authentication.Google +{ + public class GoogleChallengeProperties : OAuthChallengeProperties + { + /// + /// The parameter key for the "access_type" argument being used for a challenge request. + /// + public static readonly string AccessTypeKey = "access_type"; + + /// + /// The parameter key for the "approval_prompt" argument being used for a challenge request. + /// + public static readonly string ApprovalPromptKey = "approval_prompt"; + + /// + /// The parameter key for the "include_granted_scopes" argument being used for a challenge request. + /// + public static readonly string IncludeGrantedScopesKey = "include_granted_scopes"; + + /// + /// The parameter key for the "login_hint" argument being used for a challenge request. + /// + public static readonly string LoginHintKey = "login_hint"; + + /// + /// The parameter key for the "prompt" argument being used for a challenge request. + /// + public static readonly string PromptParameterKey = "prompt"; + + public GoogleChallengeProperties() + { } + + public GoogleChallengeProperties(IDictionary items) + : base(items) + { } + + public GoogleChallengeProperties(IDictionary items, IDictionary parameters) + : base(items, parameters) + { } + + /// + /// The "access_type" parameter value being used for a challenge request. + /// + public string AccessType + { + get => GetParameter(AccessTypeKey); + set => SetParameter(AccessTypeKey, value); + } + + /// + /// The "approval_prompt" parameter value being used for a challenge request. + /// + public string ApprovalPrompt + { + get => GetParameter(ApprovalPromptKey); + set => SetParameter(ApprovalPromptKey, value); + } + + /// + /// The "include_granted_scopes" parameter value being used for a challenge request. + /// + public bool? IncludeGrantedScopes + { + get => GetParameter(IncludeGrantedScopesKey); + set => SetParameter(IncludeGrantedScopesKey, value); + } + + /// + /// The "login_hint" parameter value being used for a challenge request. + /// + public string LoginHint + { + get => GetParameter(LoginHintKey); + set => SetParameter(LoginHintKey, value); + } + + /// + /// The "prompt" parameter value being used for a challenge request. + /// + public string Prompt + { + get => GetParameter(PromptParameterKey); + set => SetParameter(PromptParameterKey, value); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 091896f7cf..88d48d4467 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -57,12 +57,12 @@ namespace Microsoft.AspNetCore.Authentication.Google queryStrings.Add("client_id", Options.ClientId); queryStrings.Add("redirect_uri", redirectUri); - AddQueryString(queryStrings, properties, "scope", FormatScope()); - AddQueryString(queryStrings, properties, "access_type", Options.AccessType); - AddQueryString(queryStrings, properties, "approval_prompt"); - AddQueryString(queryStrings, properties, "prompt"); - AddQueryString(queryStrings, properties, "login_hint"); - AddQueryString(queryStrings, properties, "include_granted_scopes"); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.ScopeKey, FormatScope, Options.Scope); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.AccessTypeKey, Options.AccessType); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.ApprovalPromptKey); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.PromptParameterKey); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.LoginHintKey); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.IncludeGrantedScopesKey, v => v?.ToString().ToLower(), (bool?)null); var state = Options.StateDataFormat.Protect(properties); queryStrings.Add("state", state); @@ -71,29 +71,38 @@ namespace Microsoft.AspNetCore.Authentication.Google return authorizationEndpoint; } - private static void AddQueryString( + private void AddQueryString( + IDictionary queryStrings, + AuthenticationProperties properties, + string name, + Func formatter, + T defaultValue) + { + string value = null; + var parameterValue = properties.GetParameter(name); + if (parameterValue != null) + { + value = formatter(parameterValue); + } + else if (!properties.Items.TryGetValue(name, out value)) + { + value = formatter(defaultValue); + } + + // Remove the parameter from AuthenticationProperties so it won't be serialized into the state + properties.Items.Remove(name); + + if (value != null) + { + queryStrings[name] = value; + } + } + + private void AddQueryString( IDictionary queryStrings, AuthenticationProperties properties, string name, string defaultValue = null) - { - string value; - if (!properties.Items.TryGetValue(name, out value)) - { - value = defaultValue; - } - else - { - // Remove the parameter from AuthenticationProperties so it won't be serialized to state parameter - properties.Items.Remove(name); - } - - if (value == null) - { - return; - } - - queryStrings[name] = value; - } + => AddQueryString(queryStrings, properties, name, x => x, defaultValue); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs new file mode 100644 index 0000000000..fc768a8ac8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; + +namespace Microsoft.AspNetCore.Authentication.OAuth +{ + public class OAuthChallengeProperties : AuthenticationProperties + { + /// + /// The parameter key for the "scope" argument being used for a challenge request. + /// + public static readonly string ScopeKey = "scope"; + + public OAuthChallengeProperties() + { } + + public OAuthChallengeProperties(IDictionary items) + : base(items) + { } + + public OAuthChallengeProperties(IDictionary items, IDictionary parameters) + : base(items, parameters) + { } + + /// + /// The "scope" parameter value being used for a challenge request. + /// + public ICollection Scope + { + get => GetParameter>(ScopeKey); + set => SetParameter(ScopeKey, value); + } + + /// + /// Set the "scope" parameter value. + /// + /// List of scopes. + public virtual void SetScope(params string[] scopes) + { + Scope = scopes; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 80680a7cf8..808e0f9039 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -209,7 +209,8 @@ namespace Microsoft.AspNetCore.Authentication.OAuth protected virtual string BuildChallengeUrl(AuthenticationProperties properties, string redirectUri) { - var scope = FormatScope(); + var scopeParameter = properties.GetParameter>(OAuthChallengeProperties.ScopeKey); + var scope = scopeParameter != null ? FormatScope(scopeParameter) : FormatScope(); var state = Options.StateDataFormat.Protect(properties); var parameters = new Dictionary @@ -223,10 +224,20 @@ namespace Microsoft.AspNetCore.Authentication.OAuth return QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, parameters); } + /// + /// Format a list of OAuth scopes. + /// + /// List of scopes. + /// Formatted scopes. + protected virtual string FormatScope(IEnumerable scopes) + => string.Join(" ", scopes); // OAuth2 3.3 space separated + + /// + /// Format the property. + /// + /// Formatted scopes. + /// Subclasses should rather override . protected virtual string FormatScope() - { - // OAuth2 3.3 space separated - return string.Join(" ", Options.Scope); - } + => FormatScope(Options.Scope); } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs new file mode 100644 index 0000000000..0ced488deb --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; + +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect +{ + public class OpenIdConnectChallengeProperties : OAuthChallengeProperties + { + /// + /// The parameter key for the "max_age" argument being used for a challenge request. + /// + public static readonly string MaxAgeKey = OpenIdConnectParameterNames.MaxAge; + + /// + /// The parameter key for the "prompt" argument being used for a challenge request. + /// + public static readonly string PromptKey = OpenIdConnectParameterNames.Prompt; + + public OpenIdConnectChallengeProperties() + { } + + public OpenIdConnectChallengeProperties(IDictionary items) + : base(items) + { } + + public OpenIdConnectChallengeProperties(IDictionary items, IDictionary parameters) + : base(items, parameters) + { } + + /// + /// The "max_age" parameter value being used for a challenge request. + /// + public TimeSpan? MaxAge + { + get => GetParameter(MaxAgeKey); + set => SetParameter(MaxAgeKey, value); + } + + /// + /// The "prompt" parameter value being used for a challenge request. + /// + public string Prompt + { + get => GetParameter(PromptKey); + set => SetParameter(PromptKey, value); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index ce7494fb4a..029cf541b7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -329,15 +329,16 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect RedirectUri = BuildRedirectUri(Options.CallbackPath), Resource = Options.Resource, ResponseType = Options.ResponseType, - Prompt = Options.Prompt, - Scope = string.Join(" ", Options.Scope) + Prompt = properties.GetParameter(OpenIdConnectParameterNames.Prompt) ?? Options.Prompt, + Scope = string.Join(" ", properties.GetParameter>(OpenIdConnectParameterNames.Scope) ?? Options.Scope), }; // Add the 'max_age' parameter to the authentication request if MaxAge is not null. // See http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest - if (Options.MaxAge.HasValue) + var maxAge = properties.GetParameter(OpenIdConnectParameterNames.MaxAge) ?? Options.MaxAge; + if (maxAge.HasValue) { - message.MaxAge = Convert.ToInt64(Math.Floor((Options.MaxAge.Value).TotalSeconds)) + message.MaxAge = Convert.ToInt64(Math.Floor((maxAge.Value).TotalSeconds)) .ToString(CultureInfo.InvariantCulture); } @@ -783,7 +784,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// The authentication properties. /// which is used to determine if the remote authentication was successful. protected virtual async Task GetUserInformationAsync( - OpenIdConnectMessage message, JwtSecurityToken jwt, + OpenIdConnectMessage message, JwtSecurityToken jwt, ClaimsPrincipal principal, AuthenticationProperties properties) { var userInfoEndpoint = _configuration?.UserInfoEndpoint; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 4ee9117f95..b909be9fdc 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -559,6 +559,97 @@ namespace Microsoft.AspNetCore.Authentication.Facebook Assert.Contains("custom=test", query); } + [Fact] + public async Task ChallengeWillIncludeScopeAsConfigured() + { + var server = CreateServer( + app => app.UseAuthentication(), + services => + { + services.AddAuthentication().AddFacebook(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + }, + async context => + { + await context.ChallengeAsync(FacebookDefaults.AuthenticationScheme); + return true; + }); + + var transaction = await server.SendAsync("http://example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=foo,bar", res.Headers.Location.Query); + } + + [Fact] + public async Task ChallengeWillIncludeScopeAsOverwritten() + { + var server = CreateServer( + app => app.UseAuthentication(), + services => + { + services.AddAuthentication().AddFacebook(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + }, + async context => + { + var properties = new OAuthChallengeProperties(); + properties.SetScope("baz", "qux"); + await context.ChallengeAsync(FacebookDefaults.AuthenticationScheme, properties); + return true; + }); + + var transaction = await server.SendAsync("http://example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz,qux", res.Headers.Location.Query); + } + + [Fact] + public async Task ChallengeWillIncludeScopeAsOverwrittenWithBaseAuthenticationProperties() + { + var server = CreateServer( + app => app.UseAuthentication(), + services => + { + services.AddAuthentication().AddFacebook(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + }, + async context => + { + var properties = new AuthenticationProperties(); + properties.SetParameter(OAuthChallengeProperties.ScopeKey, new string[] { "baz", "qux" }); + await context.ChallengeAsync(FacebookDefaults.AuthenticationScheme, properties); + return true; + }); + + var transaction = await server.SendAsync("http://example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz,qux", res.Headers.Location.Query); + } + [Fact] public async Task NestedMapWillNotAffectRedirect() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index d9af959360..511a658ff4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -16,6 +16,7 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; +using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; @@ -545,12 +546,65 @@ namespace Microsoft.AspNetCore.Authentication.Google } [Fact] - public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() + public async Task ChallengeWillUseAuthenticationPropertiesParametersAsQueryArguments() { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(o => { o.ClientId = "Test Id"; o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + }, + context => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/challenge2")) + { + return context.ChallengeAsync("Google", new GoogleChallengeProperties + { + Scope = new string[] { "openid", "https://www.googleapis.com/auth/plus.login" }, + AccessType = "offline", + ApprovalPrompt = "force", + Prompt = "consent", + LoginHint = "test@example.com", + IncludeGrantedScopes = false, + }); + } + + return Task.FromResult(null); + }); + var transaction = await server.SendAsync("https://example.com/challenge2"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + + // verify query arguments + var query = QueryHelpers.ParseQuery(transaction.Response.Headers.Location.Query); + Assert.Equal("openid https://www.googleapis.com/auth/plus.login", query["scope"]); + Assert.Equal("offline", query["access_type"]); + Assert.Equal("force", query["approval_prompt"]); + Assert.Equal("consent", query["prompt"]); + Assert.Equal("false", query["include_granted_scopes"]); + Assert.Equal("test@example.com", query["login_hint"]); + + // verify that the passed items were not serialized + var stateProperties = stateFormat.Unprotect(query["state"]); + Assert.DoesNotContain("scope", stateProperties.Items.Keys); + Assert.DoesNotContain("access_type", stateProperties.Items.Keys); + Assert.DoesNotContain("include_granted_scopes", stateProperties.Items.Keys); + Assert.DoesNotContain("approval_prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("login_hint", stateProperties.Items.Keys); + } + + [Fact] + public async Task ChallengeWillUseAuthenticationPropertiesItemsAsParameters() + { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; }, context => { @@ -573,13 +627,79 @@ namespace Microsoft.AspNetCore.Authentication.Google }); var transaction = await server.SendAsync("https://example.com/challenge2"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - var query = transaction.Response.Headers.Location.Query; - Assert.Contains("scope=" + UrlEncoder.Default.Encode("https://www.googleapis.com/auth/plus.login"), query); - Assert.Contains("access_type=offline", query); - Assert.Contains("approval_prompt=force", query); - Assert.Contains("prompt=consent", query); - Assert.Contains("include_granted_scopes=false", query); - Assert.Contains("login_hint=" + UrlEncoder.Default.Encode("test@example.com"), query); + + // verify query arguments + var query = QueryHelpers.ParseQuery(transaction.Response.Headers.Location.Query); + Assert.Equal("https://www.googleapis.com/auth/plus.login", query["scope"]); + Assert.Equal("offline", query["access_type"]); + Assert.Equal("force", query["approval_prompt"]); + Assert.Equal("consent", query["prompt"]); + Assert.Equal("false", query["include_granted_scopes"]); + Assert.Equal("test@example.com", query["login_hint"]); + + // verify that the passed items were not serialized + var stateProperties = stateFormat.Unprotect(query["state"]); + Assert.DoesNotContain("scope", stateProperties.Items.Keys); + Assert.DoesNotContain("access_type", stateProperties.Items.Keys); + Assert.DoesNotContain("include_granted_scopes", stateProperties.Items.Keys); + Assert.DoesNotContain("approval_prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("login_hint", stateProperties.Items.Keys); + } + + [Fact] + public async Task ChallengeWillUseAuthenticationPropertiesItemsAsQueryArgumentsButParametersWillOverwrite() + { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + }, + context => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/challenge2")) + { + return context.ChallengeAsync("Google", new GoogleChallengeProperties(new Dictionary + { + ["scope"] = "https://www.googleapis.com/auth/plus.login", + ["access_type"] = "offline", + ["include_granted_scopes"] = "false", + ["approval_prompt"] = "force", + ["prompt"] = "login", + ["login_hint"] = "this-will-be-overwritten@example.com", + }) + { + Prompt = "consent", + LoginHint = "test@example.com", + }); + } + + return Task.FromResult(null); + }); + var transaction = await server.SendAsync("https://example.com/challenge2"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + + // verify query arguments + var query = QueryHelpers.ParseQuery(transaction.Response.Headers.Location.Query); + Assert.Equal("https://www.googleapis.com/auth/plus.login", query["scope"]); + Assert.Equal("offline", query["access_type"]); + Assert.Equal("force", query["approval_prompt"]); + Assert.Equal("consent", query["prompt"]); + Assert.Equal("false", query["include_granted_scopes"]); + Assert.Equal("test@example.com", query["login_hint"]); + + // verify that the passed items were not serialized + var stateProperties = stateFormat.Unprotect(query["state"]); + Assert.DoesNotContain("scope", stateProperties.Items.Keys); + Assert.DoesNotContain("access_type", stateProperties.Items.Keys); + Assert.DoesNotContain("include_granted_scopes", stateProperties.Items.Keys); + Assert.DoesNotContain("approval_prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("login_hint", stateProperties.Items.Keys); } [Fact] @@ -1499,4 +1619,4 @@ namespace Microsoft.AspNetCore.Authentication.Google } } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 480241d35b..e2e13f270e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -525,6 +525,57 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount Assert.Contains("state=", location); } + [Fact] + public async Task ChallengeWillIncludeScopeAsConfigured() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=foo%20bar", res.Headers.Location.Query); + } + + [Fact] + public async Task ChallengeWillIncludeScopeAsOverwritten() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + var transaction = await server.SendAsync("http://example.com/challengeWithOtherScope"); + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + + [Fact] + public async Task ChallengeWillIncludeScopeAsOverwrittenWithBaseAuthenticationProperties() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + var transaction = await server.SendAsync("http://example.com/challengeWithOtherScopeWithBaseAuthenticationProperties"); + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + [Fact] public async Task AuthenticatedEventCanGetRefreshToken() { @@ -608,6 +659,18 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { await context.ChallengeAsync("Microsoft"); } + else if (req.Path == new PathString("/challengeWithOtherScope")) + { + var properties = new OAuthChallengeProperties(); + properties.SetScope("baz", "qux"); + await context.ChallengeAsync("Microsoft", properties); + } + else if (req.Path == new PathString("/challengeWithOtherScopeWithBaseAuthenticationProperties")) + { + var properties = new AuthenticationProperties(); + properties.SetParameter(OAuthChallengeProperties.ScopeKey, new string[] { "baz", "qux" }); + await context.ChallengeAsync("Microsoft", properties); + } else if (req.Path == new PathString("/me")) { res.Describe(context.User); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs new file mode 100644 index 0000000000..c359bb0e8c --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs @@ -0,0 +1,149 @@ +using System; +using Microsoft.AspNetCore.Authentication.Google; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.Test +{ + public class OAuthChallengePropertiesTest + { + [Fact] + public void ScopeProperty() + { + var properties = new OAuthChallengeProperties + { + Scope = new string[] { "foo", "bar" } + }; + Assert.Equal(new string[] { "foo", "bar" }, properties.Scope); + Assert.Equal(new string[] { "foo", "bar" }, properties.Parameters["scope"]); + } + + [Fact] + public void ScopeProperty_NullValue() + { + var properties = new OAuthChallengeProperties(); + properties.Parameters["scope"] = new string[] { "foo", "bar" }; + Assert.Equal(new string[] { "foo", "bar" }, properties.Scope); + + properties.Scope = null; + Assert.Null(properties.Scope); + } + + [Fact] + public void SetScope() + { + var properties = new OAuthChallengeProperties(); + properties.SetScope("foo", "bar"); + Assert.Equal(new string[] { "foo", "bar" }, properties.Scope); + Assert.Equal(new string[] { "foo", "bar" }, properties.Parameters["scope"]); + } + + [Fact] + public void OidcMaxAge() + { + var properties = new OpenIdConnectChallengeProperties() + { + MaxAge = TimeSpan.FromSeconds(200) + }; + Assert.Equal(TimeSpan.FromSeconds(200), properties.MaxAge); + } + + [Fact] + public void OidcMaxAge_NullValue() + { + var properties = new OpenIdConnectChallengeProperties(); + properties.Parameters["max_age"] = TimeSpan.FromSeconds(500); + Assert.Equal(TimeSpan.FromSeconds(500), properties.MaxAge); + + properties.MaxAge = null; + Assert.Null(properties.MaxAge); + } + + [Fact] + public void OidcPrompt() + { + var properties = new OpenIdConnectChallengeProperties() + { + Prompt = "login" + }; + Assert.Equal("login", properties.Prompt); + Assert.Equal("login", properties.Parameters["prompt"]); + } + + [Fact] + public void OidcPrompt_NullValue() + { + var properties = new OpenIdConnectChallengeProperties(); + properties.Parameters["prompt"] = "consent"; + Assert.Equal("consent", properties.Prompt); + + properties.Prompt = null; + Assert.Null(properties.Prompt); + } + + [Fact] + public void GoogleProperties() + { + var properties = new GoogleChallengeProperties() + { + AccessType = "offline", + ApprovalPrompt = "force", + LoginHint = "test@example.com", + Prompt = "login", + }; + Assert.Equal("offline", properties.AccessType); + Assert.Equal("offline", properties.Parameters["access_type"]); + Assert.Equal("force", properties.ApprovalPrompt); + Assert.Equal("force", properties.Parameters["approval_prompt"]); + Assert.Equal("test@example.com", properties.LoginHint); + Assert.Equal("test@example.com", properties.Parameters["login_hint"]); + Assert.Equal("login", properties.Prompt); + Assert.Equal("login", properties.Parameters["prompt"]); + } + + [Fact] + public void GoogleProperties_NullValues() + { + var properties = new GoogleChallengeProperties(); + properties.Parameters["access_type"] = "offline"; + properties.Parameters["approval_prompt"] = "force"; + properties.Parameters["login_hint"] = "test@example.com"; + properties.Parameters["prompt"] = "login"; + Assert.Equal("offline", properties.AccessType); + Assert.Equal("force", properties.ApprovalPrompt); + Assert.Equal("test@example.com", properties.LoginHint); + Assert.Equal("login", properties.Prompt); + + properties.AccessType = null; + Assert.Null(properties.AccessType); + + properties.ApprovalPrompt = null; + Assert.Null(properties.ApprovalPrompt); + + properties.LoginHint = null; + Assert.Null(properties.LoginHint); + + properties.Prompt = null; + Assert.Null(properties.Prompt); + } + + [Fact] + public void GoogleIncludeGrantedScopes() + { + var properties = new GoogleChallengeProperties() + { + IncludeGrantedScopes = true + }; + Assert.True(properties.IncludeGrantedScopes); + Assert.Equal(true, properties.Parameters["include_granted_scopes"]); + + properties.IncludeGrantedScopes = false; + Assert.False(properties.IncludeGrantedScopes); + Assert.Equal(false, properties.Parameters["include_granted_scopes"]); + + properties.IncludeGrantedScopes = null; + Assert.Null(properties.IncludeGrantedScopes); + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 9279f145b9..4b822b611f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -572,6 +572,88 @@ namespace Microsoft.AspNetCore.Authentication.OAuth Assert.Contains("path=/", correlation); } + [Fact] + public async Task RedirectToAuthorizeEndpoint_HasScopeAsConfigured() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + ConfigureDefaults(opt); + opt.Scope.Clear(); + opt.Scope.Add("foo"); + opt.Scope.Add("bar"); + }), + async ctx => + { + await ctx.ChallengeAsync("Weblie"); + return true; + }); + + var transaction = await server.SendAsync("https://www.example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=foo%20bar", res.Headers.Location.Query); + } + + [Fact] + public async Task RedirectToAuthorizeEndpoint_HasScopeAsOverwritten() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + ConfigureDefaults(opt); + opt.Scope.Clear(); + opt.Scope.Add("foo"); + opt.Scope.Add("bar"); + }), + async ctx => + { + var properties = new OAuthChallengeProperties(); + properties.SetScope("baz", "qux"); + await ctx.ChallengeAsync("Weblie", properties); + return true; + }); + + var transaction = await server.SendAsync("https://www.example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + + [Fact] + public async Task RedirectToAuthorizeEndpoint_HasScopeAsOverwrittenWithBaseAuthenticationProperties() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + ConfigureDefaults(opt); + opt.Scope.Clear(); + opt.Scope.Add("foo"); + opt.Scope.Add("bar"); + }), + async ctx => + { + var properties = new AuthenticationProperties(); + properties.SetParameter(OAuthChallengeProperties.ScopeKey, new string[] { "baz", "qux" }); + await ctx.ChallengeAsync("Weblie", properties); + return true; + }); + + var transaction = await server.SendAsync("https://www.example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + private void ConfigureDefaults(OAuthOptions o) { o.ClientId = "Test Id"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index 7ab81c9dd4..cbafc46223 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -51,14 +51,14 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect [Fact] public async Task AuthorizationRequestDoesNotIncludeTelemetryParametersWhenDisabled() { - var setting = new TestSettings(opt => + var settings = new TestSettings(opt => { opt.ClientId = "Test Id"; opt.Authority = TestServerBuilder.DefaultAuthority; opt.DisableTelemetry = true; }); - var server = setting.CreateTestServer(); + var server = settings.CreateTestServer(); var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; @@ -425,6 +425,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); settings.ValidateChallengeRedirect( res.Headers.Location, OpenIdConnectParameterNames.MaxAge); @@ -446,9 +447,170 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); settings.ValidateChallengeRedirect( res.Headers.Location, OpenIdConnectParameterNames.MaxAge); } + + [Fact] + public async Task Challenge_HasExpectedPromptParam() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.Prompt = "consent"; + }); + + var server = settings.CreateTestServer(); + var transaction = await server.SendAsync(ChallengeEndpoint); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location, OpenIdConnectParameterNames.Prompt); + Assert.Contains("prompt=consent", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenPromptParam() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.Prompt = "consent"; + }); + var properties = new OpenIdConnectChallengeProperties() + { + Prompt = "login", + }; + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("prompt=login", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenPromptParamFromBaseAuthenticationProperties() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.Prompt = "consent"; + }); + var properties = new AuthenticationProperties(); + properties.SetParameter(OpenIdConnectChallengeProperties.PromptKey, "login"); + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("prompt=login", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenScopeParam() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.Scope.Clear(); + opt.Scope.Add("foo"); + opt.Scope.Add("bar"); + }); + var properties = new OpenIdConnectChallengeProperties(); + properties.SetScope("baz", "qux"); + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenScopeParamFromBaseAuthenticationProperties() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.Scope.Clear(); + opt.Scope.Add("foo"); + opt.Scope.Add("bar"); + }); + var properties = new AuthenticationProperties(); + properties.SetParameter(OpenIdConnectChallengeProperties.ScopeKey, new string[] { "baz", "qux" }); + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenMaxAgeParam() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.MaxAge = TimeSpan.FromSeconds(500); + }); + var properties = new OpenIdConnectChallengeProperties() + { + MaxAge = TimeSpan.FromSeconds(1234), + }; + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("max_age=1234", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenMaxAgeParaFromBaseAuthenticationPropertiesm() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.MaxAge = TimeSpan.FromSeconds(500); + }); + var properties = new AuthenticationProperties(); + properties.SetParameter(OpenIdConnectChallengeProperties.MaxAgeKey, TimeSpan.FromSeconds(1234)); + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("max_age=1234", res.Headers.Location.Query); + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 6bb5445dc6..a1e0233f3a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -206,6 +206,9 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect case OpenIdConnectParameterNames.MaxAge: ValidateMaxAge(actualValues, errors, htmlEncoded); break; + case OpenIdConnectParameterNames.Prompt: + ValidatePrompt(actualValues, errors, htmlEncoded); + break; default: throw new InvalidOperationException($"Unknown parameter \"{paramToValidate}\"."); } @@ -284,6 +287,9 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect } } + private void ValidatePrompt(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.Prompt, _options.Prompt, actualParams, errors, htmlEncoded); + private void ValidateParameter( string parameterName, string expectedValue, From 405e7bce54b021ee18070d3cf40b25d4dab27870 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 23 Mar 2018 14:55:41 -0700 Subject: [PATCH 879/900] Update dependencies --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d80ecef5ae..90c4b74144 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,42 +4,42 @@ 2.1.0-preview2-15744 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 3.14.2 5.2.0 5.2.0 2.0.0 2.1.0-preview2-26314-02 - 15.6.0 + 15.6.1 3.0.1 3.0.1 3.0.1 - 10.0.1 + 11.0.1 5.2.0 0.8.0 2.3.1 From bbff105e4dd5105722159fe792c17b2b39baaea3 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 25 Mar 2018 15:54:30 -0700 Subject: [PATCH 880/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 60 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d0cb88aa82..23bd79dbc3 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15728 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 + 2.1.0-preview3-17001 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview2-26225-03 - 15.6.0 + 2.1.0-preview2-26314-02 + 15.6.1 3.0.1 3.0.1 3.0.1 - 10.0.1 + 11.0.1 5.2.0 0.8.0 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 138d848db1..3a326c7d58 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15728 -commithash:393377068ddcf51dfee0536536d455f57a828b06 +version:2.1.0-preview3-17001 +commithash:dda68c56abf0d3b911fe6a2315872c446b314585 From 0d0f703e3e074fe60b8e9fc3846ce03547022305 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Wed, 28 Mar 2018 11:03:00 -0700 Subject: [PATCH 881/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 90c4b74144..303f56bca8 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15744 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 + 2.1.0-preview2-15749 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview2-26314-02 + 2.1.0-preview2-26326-03 15.6.1 3.0.1 3.0.1 3.0.1 - 11.0.1 + 11.0.2 5.2.0 0.8.0 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index f531e7b0f7..b8e036fe2c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15744 -commithash:9e15cb6062ab5b9790d3fa699e018543a6950713 +version:2.1.0-preview2-15749 +commithash:5544c9ab20fa5e24b9e155d8958a3c3b6f5f9df9 From e98a0d243a7a5d8076ab85c3438739118cdd53ff Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 3 Apr 2018 22:41:47 +0000 Subject: [PATCH 882/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 23bd79dbc3..fabe537925 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17001 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 + 2.1.0-preview3-17002 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview2-26314-02 + 2.1.0-preview3-26331-01 15.6.1 3.0.1 3.0.1 3.0.1 - 11.0.1 + 11.0.2 5.2.0 0.8.0 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3a326c7d58..b3af0b8bce 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17001 -commithash:dda68c56abf0d3b911fe6a2315872c446b314585 +version:2.1.0-preview3-17002 +commithash:b8e4e6ab104adc94c0719bb74229870e9b584a7f From ec5d71d2dcd77e969a29f13137f8ce337a3d4b92 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Apr 2018 14:25:39 -0700 Subject: [PATCH 883/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index fabe537925..9f302ba91c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17002 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 + 2.1.0-preview3-17018 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview3-26331-01 + 2.1.0-preview3-26413-05 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b3af0b8bce..b419d767b9 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17002 -commithash:b8e4e6ab104adc94c0719bb74229870e9b584a7f +version:2.1.0-preview3-17018 +commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be From 30493e2fd63907d0484b940c069d681dcb962591 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Apr 2018 17:02:13 -0700 Subject: [PATCH 884/900] Branching for 2.1.0-rc1 --- build/repo.props | 3 ++- korebuild.json | 4 ++-- version.props | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/repo.props b/build/repo.props index 541470c9f4..a4f86fb2f6 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -7,6 +7,7 @@ Internal.AspNetCore.Universe.Lineup + 2.1.0-rc1-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } diff --git a/version.props b/version.props index 24f2b00a0a..e27532787e 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview3 + rc1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 5e8f54a55fcf77fe20f1ca8c466b4cc60f366352 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 19 Apr 2018 16:44:34 -0700 Subject: [PATCH 885/900] Set NETStandardImplicitPackageVersion via dependencies.props --- Directory.Build.targets | 1 + build/dependencies.props | 1 + 2 files changed, 2 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index 894b1d0cf8..53b3f6e1da 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -2,5 +2,6 @@ $(MicrosoftNETCoreApp20PackageVersion) $(MicrosoftNETCoreApp21PackageVersion) + $(NETStandardLibrary20PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index 9f302ba91c..4dc778d54a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -36,6 +36,7 @@ 2.0.0 2.1.0-preview3-26413-05 15.6.1 + 2.0.1 3.0.1 3.0.1 3.0.1 From f3fc9c714829edadd8e7d7b6000fee1c6a5b5ef1 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 19 Apr 2018 22:35:33 -0700 Subject: [PATCH 886/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4dc778d54a..2cb9387b7a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17018 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 + 2.1.0-rc1-15774 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview3-26413-05 + 2.1.0-rc1-26419-02 15.6.1 - 2.0.1 3.0.1 3.0.1 3.0.1 + 2.0.1 11.0.2 5.2.0 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b419d767b9..9d4ef8c888 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17018 -commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be +version:2.1.0-rc1-15774 +commithash:ed5ca9de3c652347dbb0158a9a65eff3471d2114 From 3cc514c875512c1426f7ae07d4a8e36ffcbbfb30 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Mon, 30 Apr 2018 14:51:45 -0700 Subject: [PATCH 887/900] Bump version to 2.1.0-rtm --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index e27532787e..b9552451d8 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - rc1 + rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 4dbcfa5e508221b3d71a2ff7d66979282dacee33 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 4 May 2018 07:50:04 -0700 Subject: [PATCH 888/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 2cb9387b7a..d55f378cce 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rc1-15774 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 + 2.1.0-rtm-15783 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-rc1-26419-02 + 2.1.0-rtm-26502-02 15.6.1 3.0.1 3.0.1 3.0.1 - 2.0.1 + 2.0.3 11.0.2 5.2.0 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 9d4ef8c888..3673744db9 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-rc1-15774 -commithash:ed5ca9de3c652347dbb0158a9a65eff3471d2114 +version:2.1.0-rtm-15783 +commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774 From 9ee5ed4bf908bf09fce2d4d4797a908cc927b72c Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 23 May 2018 15:35:23 -0700 Subject: [PATCH 889/900] Bumping version from 2.1.0 to 2.1.1 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index b9552451d8..669c874829 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@ - + - 2.1.0 + 2.1.1 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From e538375c443a11d96370eb767fce7bb559e00dc9 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 29 May 2018 09:52:21 -0700 Subject: [PATCH 890/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d55f378cce..7d3788a5bc 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rtm-15783 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 + 2.1.1-rtm-15790 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-rtm-26502-02 + 2.1.0 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3673744db9..cd5b409a1e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-rtm-15783 -commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774 +version:2.1.1-rtm-15790 +commithash:274c65868e735f29f4078c1884c61c4371ee1fc0 From ac1a9ef6d183a94646a4b5e57b7be1c6e53b5605 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 12 Jun 2018 19:33:42 +0000 Subject: [PATCH 891/900] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7d3788a5bc..6fd8fd0995 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.1-rtm-15790 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 + 2.1.1-rtm-15793 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0 + 2.1.1 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index cd5b409a1e..bc84e0cd53 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.1-rtm-15790 -commithash:274c65868e735f29f4078c1884c61c4371ee1fc0 +version:2.1.1-rtm-15793 +commithash:988313f4b064d6c69fc6f7b845b6384a6af3447a From aa24887d4371660fdf1e2100a0c1d9957d42fb63 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 14 Jun 2018 10:30:43 -0700 Subject: [PATCH 892/900] Set 2.1 baselines --- .../baseline.netcore.json | 20 +- .../breakingchanges.netcore.json | 6 - .../baseline.netcore.json | 84 ++- .../baseline.netcore.json | 278 ++++++- .../baseline.netcore.json | 96 ++- .../baseline.netcore.json | 59 +- .../baseline.netcore.json | 202 +++++- .../baseline.netcore.json | 208 +++++- .../baseline.netcore.json | 128 +++- .../baseline.netcore.json | 24 +- .../baseline.netcore.json | 682 ++++++++++++++++-- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 138 +++- .../baseline.netframework.json | 2 +- 14 files changed, 1815 insertions(+), 114 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json index 52fa29be91..b218669b76 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.CookieExtensions", @@ -239,10 +239,8 @@ "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler" - ], + "BaseType": "Microsoft.AspNetCore.Authentication.SignInAuthenticationHandler", + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", @@ -306,7 +304,7 @@ }, { "Kind": "Method", - "Name": "SignInAsync", + "Name": "HandleSignInAsync", "Parameters": [ { "Name": "user", @@ -319,13 +317,13 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", - "Visibility": "Public", + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SignOutAsync", + "Name": "HandleSignOutAsync", "Parameters": [ { "Name": "properties", @@ -334,8 +332,8 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", - "Visibility": "Public", + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json deleted file mode 100644 index 7673fc1a0e..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json +++ /dev/null @@ -1,6 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler, Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json index 2500e5fb5e..5d95efca6f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions", @@ -160,6 +160,88 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [ + { + "Name": "scopes", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json index edaade3267..0a623b3b85 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.GoogleExtensions", @@ -97,6 +97,206 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleChallengeProperties", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthChallengeProperties", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AccessType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AccessType", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ApprovalPrompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ApprovalPrompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IncludeGrantedScopes", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IncludeGrantedScopes", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_LoginHint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_LoginHint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Prompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Prompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + }, + { + "Name": "parameters", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessTypeKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "ApprovalPromptKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "IncludeGrantedScopesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "LoginHintKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "PromptParameterKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", "Visibility": "Public", @@ -160,6 +360,82 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "BuildChallengeUrl", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHelper", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json index 44fc928cac..d3839022b5 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.JwtBearerExtensions", @@ -609,6 +609,100 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json index 966f7e1b1f..877e9035ac 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions", @@ -160,6 +160,63 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json index 142e37c6bd..9c23947049 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.OAuthExtensions", @@ -417,6 +417,41 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "MapAll", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapAllExcept", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "exclusions", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "DeleteClaim", @@ -435,6 +470,26 @@ "Extension": true, "Visibility": "Public", "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteClaims", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimTypes", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] } ], "GenericParameters": [] @@ -697,6 +752,97 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthChallengeProperties", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Scope", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Scope", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.ICollection" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SetScope", + "Parameters": [ + { + "Name": "scopes", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + }, + { + "Name": "parameters", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "ScopeKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthDefaults", "Visibility": "Public", @@ -848,6 +994,20 @@ "Visibility": "Protected", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [ + { + "Name": "scopes", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "FormatScope", @@ -1605,6 +1765,46 @@ } ], "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.MapAllClaimsAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Run", + "Parameters": [ + { + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] } ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json index a57e2eb872..d5c10d18db 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.OpenIdConnectExtensions", @@ -637,6 +637,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_OnSignedOutCallbackRedirect", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSignedOutCallbackRedirect", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_OnRemoteSignOut", @@ -791,6 +812,20 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "SignedOutCallbackRedirect", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "RemoteSignOut", @@ -1265,6 +1300,113 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectChallengeProperties", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthChallengeProperties", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_MaxAge", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MaxAge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Prompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Prompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + }, + { + "Name": "parameters", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "MaxAgeKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "PromptKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", "Visibility": "Public", @@ -1347,6 +1489,17 @@ "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" ], "Members": [ + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Backchannel", @@ -1394,17 +1547,6 @@ "Visibility": "Protected", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "HandleRemoteSignOutAsync", @@ -1748,6 +1890,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_MaxAge", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MaxAge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_ProtocolValidator", @@ -1916,6 +2079,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_Prompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Prompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Scope", diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json index 196b85372d..03ee645623 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.TwitterExtensions", @@ -600,6 +600,122 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "token", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.AccessToken" + }, + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions", "Visibility": "Public", @@ -741,6 +857,16 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json index 5a8110fbce..41150cbc09 100644 --- a/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.WsFederation, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.WsFederation, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.WsFederationExtensions", @@ -765,6 +765,17 @@ "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" ], "Members": [ + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Events", @@ -796,17 +807,6 @@ "Visibility": "Protected", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "HandleChallengeAsync", diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json index a6082e8c46..08eeb5e7b2 100644 --- a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", @@ -126,6 +126,28 @@ } ] }, + { + "Kind": "Method", + "Name": "AddPolicyScheme", + "Parameters": [ + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -338,6 +360,20 @@ "Visibility": "Protected", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "ResolveTarget", + "Parameters": [ + { + "Name": "scheme", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "AuthenticateAsync", @@ -545,6 +581,20 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [ + { + "Name": "scheme", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_ClaimsIssuer", @@ -608,6 +658,153 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ForwardDefault", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardDefault", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardAuthenticate", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardAuthenticate", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardChallenge", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardChallenge", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardForbid", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardForbid", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardSignIn", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardSignIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardSignOut", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardSignOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardDefaultSelector", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardDefaultSelector", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -1752,6 +1949,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -1965,6 +2183,135 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Handled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Skipped", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Success", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failure", + "Type": "System.Exception" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failure", + "Type": "System.Exception" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Handle", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", "Visibility": "Public", @@ -1982,6 +2329,131 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.PolicySchemeHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.SignInAuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleForbiddenAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignInAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PolicySchemeOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", "Visibility": "Public", @@ -2156,6 +2628,21 @@ "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [ + { + "Name": "scheme", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "Validate", @@ -2387,97 +2874,164 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Name": "Microsoft.AspNetCore.Authentication.SignInAuthenticationHandler", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "ImplementedInterfaces": [], + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.SignOutAuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler" + ], "Members": [ { "Kind": "Method", - "Name": "get_Handled", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Success", + "Name": "SignInAsync", "Parameters": [ { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Fail", + "Name": "HandleSignInAsync", "Parameters": [ { - "Name": "failure", - "Type": "System.Exception" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Fail", - "Parameters": [ + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, { - "Name": "failureMessage", - "Type": "System.String" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Handle", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SkipHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], "Visibility": "Public", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SignOutAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "SignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] }, { "Name": "Microsoft.AspNetCore.Authentication.SystemClock", diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json index a2a971f826..e8708538d3 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json index 050546810f..01a16c57a9 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", @@ -116,6 +116,48 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ConsentCookie", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConsentCookie", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CheckConsentNeeded", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CheckConsentNeeded", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_OnAppendCookie", @@ -232,6 +274,43 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_IsConsentNeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HasConsent", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IssueCookie", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IssueCookie", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -299,6 +378,26 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "factory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -361,6 +460,43 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_IsConsentNeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HasConsent", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IssueCookie", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IssueCookie", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json index 65256bed6f..bfc0c0076d 100644 --- a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json +++ b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", From 26fbad061475e4cf8d27d0e364048a924ead953b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 27 Jun 2018 13:39:51 -0700 Subject: [PATCH 893/900] Bumping version from 2.1.1 to 2.1.2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 669c874829..478dfd16ed 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.1 + 2.1.2 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From d2a8d3a61c4f393170be4f6e49b287d0f3a4d96d Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 11 Jul 2018 13:14:51 -0700 Subject: [PATCH 894/900] Fix cookie regression (#1811) --- .../CookieAuthenticationHandler.cs | 11 +-- .../CookieTests.cs | 84 +++++++++++++++++++ 2 files changed, 90 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 343cf1b3a7..b77a51ef4f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -85,7 +85,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } } - private void RequestRefresh(AuthenticationTicket ticket) + private void RequestRefresh(AuthenticationTicket ticket, ClaimsPrincipal replacedPrincipal = null) { var issuedUtc = ticket.Properties.IssuedUtc; var expiresUtc = ticket.Properties.ExpiresUtc; @@ -97,14 +97,15 @@ namespace Microsoft.AspNetCore.Authentication.Cookies _refreshIssuedUtc = currentUtc; var timeSpan = expiresUtc.Value.Subtract(issuedUtc.Value); _refreshExpiresUtc = currentUtc.Add(timeSpan); - _refreshTicket = CloneTicket(ticket); + _refreshTicket = CloneTicket(ticket, replacedPrincipal); } } - private AuthenticationTicket CloneTicket(AuthenticationTicket ticket) + private AuthenticationTicket CloneTicket(AuthenticationTicket ticket, ClaimsPrincipal replacedPrincipal) { + var principal = replacedPrincipal ?? ticket.Principal; var newPrincipal = new ClaimsPrincipal(); - foreach (var identity in ticket.Principal.Identities) + foreach (var identity in principal.Identities) { newPrincipal.AddIdentity(identity.Clone()); } @@ -183,7 +184,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (context.ShouldRenew) { - RequestRefresh(result.Ticket); + RequestRefresh(result.Ticket, context.Principal); } return AuthenticateResult.Success(new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name)); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 945ec82ee6..766d1e2e53 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -900,6 +900,80 @@ namespace Microsoft.AspNetCore.Authentication.Cookies Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); } + [Fact] + public async Task CookieCanBeReplacedByValidator() + { + var server = CreateServer(o => + { + o.Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = ctx => + { + ctx.ShouldRenew = true; + ctx.ReplacePrincipal(new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice2", "Cookies2")))); + return Task.FromResult(0); + } + }; + }, + context => + context.SignInAsync("Cookies", + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction2.SetCookie); + Assert.Equal("Alice2", FindClaimValue(transaction2, ClaimTypes.Name)); + } + + [Fact] + public async Task CookieCanBeUpdatedByValidatorDuringRefresh() + { + var replace = false; + var server = CreateServer(o => + { + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = ctx => + { + if (replace) + { + ctx.ShouldRenew = true; + ctx.ReplacePrincipal(new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice2", "Cookies2")))); + ctx.Properties.Items["updated"] = "yes"; + } + return Task.FromResult(0); + } + }; + }, + context => + context.SignInAsync("Cookies", + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + + var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + Assert.Null(FindPropertiesValue(transaction3, "updated")); + + replace = true; + + var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction4.SetCookie); + Assert.Equal("Alice2", FindClaimValue(transaction4, ClaimTypes.Name)); + Assert.Equal("yes", FindPropertiesValue(transaction4, "updated")); + + replace = false; + + var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction4.CookieNameValue); + Assert.Equal("Alice2", FindClaimValue(transaction5, ClaimTypes.Name)); + Assert.Equal("yes", FindPropertiesValue(transaction4, "updated")); + } + [Fact] public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() { @@ -1730,6 +1804,16 @@ namespace Microsoft.AspNetCore.Authentication.Cookies return claim.Attribute("value").Value; } + private static string FindPropertiesValue(Transaction transaction, string key) + { + var property = transaction.ResponseElement.Elements("extra").SingleOrDefault(elt => elt.Attribute("type").Value == key); + if (property == null) + { + return null; + } + return property.Attribute("value").Value; + } + private static async Task GetAuthData(TestServer server, string url, string cookie) { var request = new HttpRequestMessage(HttpMethod.Get, url); From c9122a842847974fb58eebf13acc88c2d090c6e1 Mon Sep 17 00:00:00 2001 From: Tim Hess Date: Wed, 23 May 2018 10:25:19 -0500 Subject: [PATCH 895/900] Include AuthenticationTicket.Properties in AuthenticationTicket success result handling #1765 (#1767) --- src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs index 3f6c2d9177..da9b6ea01c 100644 --- a/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs @@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Authentication { throw new ArgumentNullException(nameof(ticket)); } - return new HandleRequestResult() { Ticket = ticket }; + return new HandleRequestResult() { Ticket = ticket, Properties = ticket.Properties }; } /// From 47caa67a65b1f3f4f48607c39ff1caa2676cfe01 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 16 May 2018 15:41:01 -0700 Subject: [PATCH 896/900] Rewrite JwtBearer token test #640 --- .../JwtBearerTests.cs | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index b472a4162d..20d625d314 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Net; using System.Net.Http; @@ -432,19 +433,37 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Null(scheme.DisplayName); } - [ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/179 + [Fact] public async Task BearerTokenValidation() { + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); + var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + + var claims = new[] + { + new Claim(ClaimTypes.NameIdentifier, "Bob") + }; + + var token = new JwtSecurityToken( + issuer: "issuer.contoso.com", + audience: "audience.contoso.com", + claims: claims, + expires: DateTime.Now.AddMinutes(30), + signingCredentials: creds); + + var tokenText = new JwtSecurityTokenHandler().WriteToken(token); + var server = CreateServer(o => { - o.Authority = "https://login.windows.net/tushartest.onmicrosoft.com"; - o.Audience = "https://TusharTest.onmicrosoft.com/TodoListService-ManualJwt"; - o.TokenValidationParameters.ValidateLifetime = false; + o.TokenValidationParameters = new TokenValidationParameters() + { + ValidIssuer = "issuer.contoso.com", + ValidAudience = "audience.contoso.com", + IssuerSigningKey = key, + }; }); - var newBearerToken = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtyaU1QZG1Cdng2OHNrVDgtbVBBQjNCc2VlQSJ9.eyJhdWQiOiJodHRwczovL1R1c2hhclRlc3Qub25taWNyb3NvZnQuY29tL1RvZG9MaXN0U2VydmljZS1NYW51YWxKd3QiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9hZmJlY2UwMy1hZWFhLTRmM2YtODVlNy1jZTA4ZGQyMGNlNTAvIiwiaWF0IjoxNDE4MzMwNjE0LCJuYmYiOjE0MTgzMzA2MTQsImV4cCI6MTQxODMzNDUxNCwidmVyIjoiMS4wIiwidGlkIjoiYWZiZWNlMDMtYWVhYS00ZjNmLTg1ZTctY2UwOGRkMjBjZTUwIiwiYW1yIjpbInB3ZCJdLCJvaWQiOiI1Mzk3OTdjMi00MDE5LTQ2NTktOWRiNS03MmM0Yzc3NzhhMzMiLCJ1cG4iOiJWaWN0b3JAVHVzaGFyVGVzdC5vbm1pY3Jvc29mdC5jb20iLCJ1bmlxdWVfbmFtZSI6IlZpY3RvckBUdXNoYXJUZXN0Lm9ubWljcm9zb2Z0LmNvbSIsInN1YiI6IkQyMm9aMW9VTzEzTUFiQXZrdnFyd2REVE80WXZJdjlzMV9GNWlVOVUwYnciLCJmYW1pbHlfbmFtZSI6Ikd1cHRhIiwiZ2l2ZW5fbmFtZSI6IlZpY3RvciIsImFwcGlkIjoiNjEzYjVhZjgtZjJjMy00MWI2LWExZGMtNDE2Yzk3ODAzMGI3IiwiYXBwaWRhY3IiOiIwIiwic2NwIjoidXNlcl9pbXBlcnNvbmF0aW9uIiwiYWNyIjoiMSJ9.N_Kw1EhoVGrHbE6hOcm7ERdZ7paBQiNdObvp2c6T6n5CE8p0fZqmUd-ya_EqwElcD6SiKSiP7gj0gpNUnOJcBl_H2X8GseaeeMxBrZdsnDL8qecc6_ygHruwlPltnLTdka67s1Ow4fDSHaqhVTEk6lzGmNEcbNAyb0CxQxU6o7Fh0yHRiWoLsT8yqYk8nKzsHXfZBNby4aRo3_hXaa4i0SZLYfDGGYPdttG4vT_u54QGGd4Wzbonv2gjDlllOVGOwoJS6kfl1h8mk0qxdiIaT_ChbDWgkWvTB7bTvBE-EgHgV0XmAo0WtJeSxgjsG3KhhEPsONmqrSjhIUV4IVnF2w"; + var newBearerToken = "Bearer " + tokenText; var response = await SendAsync(server, "http://example.com/oauth", newBearerToken); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); } From aef7ff7959817fcc7bbd440dbc5eb1c7f7d98af0 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 12 Jul 2018 14:13:25 -0700 Subject: [PATCH 897/900] Add JwtBearer test for SaveToken #1768 --- .../JwtBearerTests.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 20d625d314..d7fcdb4cad 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -468,6 +468,43 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); } + [Fact] + public async Task SaveBearerToken() + { + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); + var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + + var claims = new[] + { + new Claim(ClaimTypes.NameIdentifier, "Bob") + }; + + var token = new JwtSecurityToken( + issuer: "issuer.contoso.com", + audience: "audience.contoso.com", + claims: claims, + expires: DateTime.Now.AddMinutes(30), + signingCredentials: creds); + + var tokenText = new JwtSecurityTokenHandler().WriteToken(token); + + var server = CreateServer(o => + { + o.SaveToken = true; + o.TokenValidationParameters = new TokenValidationParameters() + { + ValidIssuer = "issuer.contoso.com", + ValidAudience = "audience.contoso.com", + IssuerSigningKey = key, + }; + }); + + var newBearerToken = "Bearer " + tokenText; + var response = await SendAsync(server, "http://example.com/token", newBearerToken); + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); + Assert.Equal(tokenText, await response.Response.Content.ReadAsStringAsync()); + } + [Fact] public async Task SignInThrows() { @@ -1140,6 +1177,11 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer await context.Response.WriteAsync(identifier.Value); } + else if (context.Request.Path == new PathString("/token")) + { + var token = await context.GetTokenAsync("access_token"); + await context.Response.WriteAsync(token); + } else if (context.Request.Path == new PathString("/unauthorized")) { // Simulate Authorization failure From d8e10d087040adeadc677528eaeb0c04b76ee506 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 11 Jul 2018 18:49:48 -0700 Subject: [PATCH 898/900] Updating dependencies to 2.1.2 and adding a section for pinned variable versions --- build/dependencies.props | 17 ++++++++++++----- korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 6fd8fd0995..5e6f87963d 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,8 +2,10 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - 2.1.1-rtm-15793 + + + + 2.1.3-rtm-15802 2.1.1 2.1.1 2.1.1 @@ -13,8 +15,8 @@ 2.1.1 2.1.1 2.1.1 - 2.1.1 - 2.1.1 + 2.1.2 + 2.1.2 2.1.1 2.1.1 2.1.0 @@ -34,7 +36,7 @@ 5.2.0 5.2.0 2.0.0 - 2.1.1 + 2.1.2 15.6.1 3.0.1 3.0.1 @@ -46,5 +48,10 @@ 2.3.1 2.4.0-beta.1.build3945 + + + + + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index bc84e0cd53..251c227c83 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.1-rtm-15793 -commithash:988313f4b064d6c69fc6f7b845b6384a6af3447a +version:2.1.3-rtm-15802 +commithash:a7c08b45b440a7d2058a0aa1eaa3eb6ba811976a From 930ed239e41d7547edf06f31efa3461d1a2c6bad Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 12 Jul 2018 11:58:34 -0700 Subject: [PATCH 899/900] Pin version variables to the ASP.NET Core 2.1.2 baseline This reverts our previous policy of cascading versions on all servicing updates. This moves variables into the 'pinned' section, and points them to the latest stable release (versions that were used at the time of the 2.1.2 release). --- build/dependencies.props | 47 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5e6f87963d..828f9c7ab2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,8 +4,30 @@ - + 2.1.3-rtm-15802 + 3.14.2 + 5.2.0 + 5.2.0 + 2.0.0 + 2.1.2 + 15.6.1 + 3.0.1 + 3.0.1 + 3.0.1 + 2.0.3 + 11.0.2 + 5.2.0 + 0.8.0 + 2.3.1 + 2.4.0-beta.1.build3945 + + + + + + + 2.1.1 2.1.1 2.1.1 @@ -32,26 +54,5 @@ 2.1.1 2.1.1 2.1.1 - 3.14.2 - 5.2.0 - 5.2.0 - 2.0.0 - 2.1.2 - 15.6.1 - 3.0.1 - 3.0.1 - 3.0.1 - 2.0.3 - 11.0.2 - 5.2.0 - 0.8.0 - 2.3.1 - 2.4.0-beta.1.build3945 - - - - - - - + \ No newline at end of file From f7b51eeddaadd67296edcdb64470ad162401bf16 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 21 Nov 2018 15:12:11 -0800 Subject: [PATCH 900/900] Reorganize source code in preparation to move into aspnet/AspNetCore Prior to reorganization, this source code was found in https://github.com/aspnet/Security/tree/930ed239e41d7547edf06f31efa3461d1a2c6bad --- .appveyor.yml | 17 -- .gitattributes | 51 ---- .travis.yml | 27 -- CONTRIBUTING.md | 4 - LICENSE.txt | 14 -- NuGet.config | 7 - build.cmd | 2 - build.sh | 8 - korebuild-lock.txt | 2 - korebuild.json | 4 - run.cmd | 2 - run.ps1 | 196 --------------- run.sh | 231 ------------------ .gitignore => src/Security/.gitignore | 0 .../Security/Directory.Build.props | 0 .../Security/Directory.Build.targets | 0 .../Security/NuGetPackageVerifier.json | 0 README.md => src/Security/README.md | 0 Security.sln => src/Security/Security.sln | 0 {build => src/Security/build}/Key.snk | Bin .../Security/build}/dependencies.props | 0 {build => src/Security/build}/repo.props | 0 {build => src/Security/build}/sources.props | 0 .../CookiePolicySample.csproj | 0 .../samples}/CookiePolicySample/Program.cs | 0 .../Properties/launchSettings.json | 0 .../samples}/CookiePolicySample/Startup.cs | 0 .../samples}/CookieSample/CookieSample.csproj | 0 .../Security/samples}/CookieSample/Program.cs | 0 .../Properties/launchSettings.json | 0 .../Security/samples}/CookieSample/Startup.cs | 0 .../CookieSessionSample.csproj | 0 .../MemoryCacheTicketStore.cs | 0 .../samples}/CookieSessionSample/Program.cs | 0 .../Properties/launchSettings.json | 0 .../samples}/CookieSessionSample/Startup.cs | 0 .../JwtBearerSample/JwtBearerSample.csproj | 0 .../samples}/JwtBearerSample/Program.cs | 0 .../Properties/launchSettings.json | 0 .../samples}/JwtBearerSample/Startup.cs | 0 .../Security/samples}/JwtBearerSample/Todo.cs | 0 .../wwwroot/App/Scripts/app.js | 0 .../wwwroot/App/Scripts/homeCtrl.js | 0 .../wwwroot/App/Scripts/indexCtrl.js | 0 .../wwwroot/App/Scripts/todoListCtrl.js | 0 .../wwwroot/App/Scripts/todoListSvc.js | 0 .../wwwroot/App/Scripts/userDataCtrl.js | 0 .../wwwroot/App/Views/Home.html | 0 .../wwwroot/App/Views/TodoList.html | 0 .../wwwroot/App/Views/UserData.html | 0 .../JwtBearerSample/wwwroot/index.html | 0 .../AuthPropertiesTokenCache.cs | 0 .../OpenIdConnect.AzureAdSample.csproj | 0 .../OpenIdConnect.AzureAdSample/Program.cs | 0 .../Properties/launchSettings.json | 0 .../OpenIdConnect.AzureAdSample/Readme.md | 0 .../OpenIdConnect.AzureAdSample/Startup.cs | 0 .../OpenIdConnectSample.csproj | 0 .../samples}/OpenIdConnectSample/Program.cs | 0 .../Properties/launchSettings.json | 0 .../samples}/OpenIdConnectSample/Readme.md | 0 .../samples}/OpenIdConnectSample/Startup.cs | 0 .../compiler/resources/cert.pfx | Bin .../Security/samples}/SocialSample/Program.cs | 0 .../Properties/launchSettings.json | 0 .../samples}/SocialSample/SocialSample.csproj | 0 .../Security/samples}/SocialSample/Startup.cs | 0 .../SocialSample/compiler/resources/cert.pfx | Bin .../Security/samples}/SocialSample/web.config | 0 .../Security/samples}/WsFedSample/Program.cs | 0 .../Properties/launchSettings.json | 0 .../Security/samples}/WsFedSample/Startup.cs | 0 .../samples}/WsFedSample/WsFedSample.csproj | 0 .../WsFedSample/compiler/resources/cert.pfx | Bin .../ChunkingCookieManager.cs | 0 src/{ => Security/src}/Directory.Build.props | 0 .../Constants.cs | 0 .../CookieAppBuilderExtensions.cs | 0 .../CookieAuthenticationDefaults.cs | 0 .../CookieAuthenticationHandler.cs | 0 .../CookieAuthenticationOptions.cs | 0 .../CookieExtensions.cs | 0 .../Events/CookieAuthenticationEvents.cs | 0 .../Events/CookieSignedInContext.cs | 0 .../Events/CookieSigningInContext.cs | 0 .../Events/CookieSigningOutContext.cs | 0 .../Events/CookieValidatePrincipalContext.cs | 0 .../ICookieManager.cs | 0 .../ITicketStore.cs | 0 .../LoggingExtensions.cs | 0 ...t.AspNetCore.Authentication.Cookies.csproj | 0 ...ostConfigureCookieAuthenticationOptions.cs | 0 .../baseline.netcore.json | 0 .../FacebookAppBuilderExtensions.cs | 0 .../FacebookDefaults.cs | 0 .../FacebookExtensions.cs | 0 .../FacebookHandler.cs | 0 .../FacebookOptions.cs | 0 ....AspNetCore.Authentication.Facebook.csproj | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../baseline.netcore.json | 0 .../GoogleAppBuilderExtensions.cs | 0 .../GoogleChallengeProperties.cs | 0 .../GoogleDefaults.cs | 0 .../GoogleExtensions.cs | 0 .../GoogleHandler.cs | 0 .../GoogleHelper.cs | 0 .../GoogleOptions.cs | 0 ...ft.AspNetCore.Authentication.Google.csproj | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../baseline.netcore.json | 0 .../Events/AuthenticationFailedContext.cs | 0 .../Events/JwtBearerChallengeContext.cs | 0 .../Events/JwtBearerEvents.cs | 0 .../Events/MessageReceivedContext.cs | 0 .../Events/TokenValidatedContext.cs | 0 .../JwtBearerAppBuilderExtensions.cs | 0 .../JwtBearerDefaults.cs | 0 .../JwtBearerExtensions.cs | 0 .../JwtBearerHandler.cs | 0 .../JwtBearerOptions.cs | 0 .../JwtBearerPostConfigureOptions.cs | 0 .../LoggingExtensions.cs | 0 ...AspNetCore.Authentication.JwtBearer.csproj | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../baseline.netcore.json | 0 ...ore.Authentication.MicrosoftAccount.csproj | 0 .../MicrosoftAccountAppBuilderExtensions.cs | 0 .../MicrosoftAccountDefaults.cs | 0 .../MicrosoftAccountExtensions.cs | 0 .../MicrosoftAccountHandler.cs | 0 .../MicrosoftAccountOptions.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../baseline.netcore.json | 0 .../Claims/ClaimAction.cs | 0 .../Claims/ClaimActionCollection.cs | 0 .../ClaimActionCollectionMapExtensions.cs | 0 .../Claims/CustomJsonClaimAction.cs | 0 .../Claims/DeleteClaimAction.cs | 0 .../Claims/JsonKeyClaimAction.cs | 0 .../Claims/JsonSubKeyClaimAction.cs | 0 .../Claims/MapAllClaimsAction.cs | 0 .../Events/OAuthCreatingTicketContext.cs | 0 .../Events/OAuthEvents.cs | 0 ...oft.AspNetCore.Authentication.OAuth.csproj | 0 .../OAuthAppBuilderExtensions.cs | 0 .../OAuthChallengeProperties.cs | 0 .../OAuthDefaults.cs | 0 .../OAuthExtensions.cs | 0 .../OAuthHandler.cs | 0 .../OAuthOptions.cs | 0 .../OAuthPostConfigureOptions.cs | 0 .../OAuthTokenResponse.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../baseline.netcore.json | 0 .../ClaimActionCollectionUniqueExtensions.cs | 0 .../Claims/UniqueJsonKeyClaimAction.cs | 0 .../Events/AuthenticationFailedContext.cs | 0 .../AuthorizationCodeReceivedContext.cs | 0 .../Events/MessageReceivedContext.cs | 0 .../Events/OpenIdConnectEvents.cs | 0 .../Events/RedirectContext.cs | 0 .../Events/RemoteSignoutContext.cs | 0 .../Events/TokenResponseReceivedContext.cs | 0 .../Events/TokenValidatedContext.cs | 0 .../Events/UserInformationReceivedContext.cs | 0 .../LoggingExtensions.cs | 0 ...etCore.Authentication.OpenIdConnect.csproj | 0 .../OpenIdConnectAppBuilderExtensions.cs | 0 .../OpenIdConnectChallengeProperties.cs | 0 .../OpenIdConnectDefaults.cs | 0 .../OpenIdConnectExtensions.cs | 0 .../OpenIdConnectHandler.cs | 0 .../OpenIdConnectOptions.cs | 0 .../OpenIdConnectPostConfigureOptions.cs | 0 .../OpenIdConnectRedirectBehavior.cs | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../baseline.netcore.json | 0 .../Events/TwitterCreatingTicketContext.cs | 0 .../Events/TwitterEvents.cs | 0 .../LoggingExtensions.cs | 0 .../Messages/AccessToken.cs | 0 .../Messages/RequestToken.cs | 0 .../Messages/RequestTokenSerializer.cs | 0 ...t.AspNetCore.Authentication.Twitter.csproj | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../TwitterAppBuilderExtensions.cs | 0 .../TwitterDefaults.cs | 0 .../TwitterExtensions.cs | 0 .../TwitterHandler.cs | 0 .../TwitterOptions.cs | 0 .../TwitterPostConfigureOptions.cs | 0 .../baseline.netcore.json | 0 .../Events/AuthenticationFailedContext.cs | 0 .../Events/MessageReceivedContext.cs | 0 .../Events/RedirectContext.cs | 0 .../Events/RemoteSignoutContext.cs | 0 .../Events/SecurityTokenReceivedContext.cs | 0 .../Events/SecurityTokenValidatedContext.cs | 0 .../Events/WsFederationEvents.cs | 0 .../LoggingExtensions.cs | 0 ...NetCore.Authentication.WsFederation.csproj | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../WsFederationDefaults.cs | 0 .../WsFederationExtensions.cs | 0 .../WsFederationHandler.cs | 0 .../WsFederationOptions.cs | 0 .../WsFederationPostConfigureOptions.cs | 0 .../baseline.netcore.json | 0 .../AuthAppBuilderExtensions.cs | 0 .../AuthenticationBuilder.cs | 0 .../AuthenticationHandler.cs | 0 .../AuthenticationMiddleware.cs | 0 .../AuthenticationSchemeOptions.cs | 0 ...thenticationServiceCollectionExtensions.cs | 0 .../Data/IDataSerializer.cs | 0 .../Data/ISecureDataFormat.cs | 0 .../Data/PropertiesDataFormat.cs | 0 .../Data/PropertiesSerializer.cs | 0 .../Data/SecureDataFormat.cs | 0 .../Data/TextEncoder.cs | 0 .../Data/TicketDataFormat.cs | 0 .../Data/TicketSerializer.cs | 0 .../Events/BaseContext.cs | 0 .../Events/HandleRequestContext.cs | 0 .../Events/PrincipalContext.cs | 0 .../Events/PropertiesContext.cs | 0 .../Events/RedirectContext.cs | 0 .../Events/RemoteAuthenticationContext.cs | 0 .../Events/RemoteAuthenticationEvents.cs | 0 .../Events/RemoteFailureContext.cs | 0 .../Events/ResultContext.cs | 0 .../Events/TicketReceivedContext.cs | 0 .../HandleRequestResult.cs | 0 .../ISystemClock.cs | 0 .../Internal/RequestPathBaseCookieBuilder.cs | 0 .../LoggingExtensions.cs | 0 ...Microsoft.AspNetCore.Authentication.csproj | 0 .../PolicySchemeHandler.cs | 0 .../PolicySchemeOptions.cs | 0 .../Properties/Resources.Designer.cs | 0 .../RemoteAuthenticationHandler.cs | 0 .../RemoteAuthenticationOptions.cs | 0 .../Resources.resx | 0 .../SignInAuthenticationHandler.cs | 0 .../SignOutAuthenticationHandler.cs | 0 .../SystemClock.cs | 0 .../baseline.netcore.json | 0 .../IPolicyEvaluator.cs | 0 ...oft.AspNetCore.Authorization.Policy.csproj | 0 .../PolicyAuthorizationResult.cs | 0 .../PolicyEvaluator.cs | 0 .../PolicyServiceCollectionExtensions.cs | 0 .../baseline.netcore.json | 0 .../AllowAnonymousAttribute.cs | 0 .../AuthorizationFailure.cs | 0 .../AuthorizationHandler.cs | 0 .../AuthorizationHandlerContext.cs | 0 .../AuthorizationOptions.cs | 0 .../AuthorizationPolicy.cs | 0 .../AuthorizationPolicyBuilder.cs | 0 .../AuthorizationResult.cs | 0 ...uthorizationServiceCollectionExtensions.cs | 0 .../AuthorizationServiceExtensions.cs | 0 .../AuthorizeAttribute.cs | 0 .../DefaultAuthorizationEvaluator.cs | 0 ...faultAuthorizationHandlerContextFactory.cs | 0 .../DefaultAuthorizationHandlerProvider.cs | 0 .../DefaultAuthorizationPolicyProvider.cs | 0 .../DefaultAuthorizationService.cs | 0 .../IAllowAnonymous.cs | 0 .../IAuthorizationEvaluator.cs | 0 .../IAuthorizationHandler.cs | 0 .../IAuthorizationHandlerContextFactory.cs | 0 .../IAuthorizationHandlerProvider.cs | 0 .../IAuthorizationPolicyProvider.cs | 0 .../IAuthorizationRequirement.cs | 0 .../IAuthorizationService.cs | 0 .../IAuthorizeData.cs | 0 .../Infrastructure/AssertionRequirement.cs | 0 .../ClaimsAuthorizationRequirement.cs | 0 .../DenyAnonymousAuthorizationRequirement.cs | 0 .../NameAuthorizationRequirement.cs | 0 .../OperationAuthorizationRequirement.cs | 0 .../PassThroughAuthorizationHandler.cs | 0 .../RolesAuthorizationRequirement.cs | 0 .../LoggingExtensions.cs | 0 .../Microsoft.AspNetCore.Authorization.csproj | 0 .../Properties/Resources.Designer.cs | 0 .../Resources.resx | 0 .../baseline.netcore.json | 0 .../AppendCookieContext.cs | 0 .../CookiePolicyAppBuilderExtensions.cs | 0 .../CookiePolicyMiddleware.cs | 0 .../CookiePolicyOptions.cs | 0 .../DeleteCookieContext.cs | 0 .../HttpOnlyPolicy.cs | 0 .../LoggingExtensions.cs | 0 .../Microsoft.AspNetCore.CookiePolicy.csproj | 0 .../ResponseCookiesWrapper.cs | 0 .../baseline.netcore.json | 0 .../AspNetTicketDataFormat.cs | 0 .../AspNetTicketSerializer.cs | 0 .../ChunkingCookieManager.cs | 0 .../Constants.cs | 0 .../DataProtectorShim.cs | 0 .../Microsoft.Owin.Security.Interop.csproj | 0 .../Properties/AssemblyInfo.cs | 0 .../baseline.netframework.json | 0 .../Security/test}/Directory.Build.props | 0 .../AuthenticationMiddlewareTests.cs | 0 .../Base64UrlTextEncoderTests.cs | 0 .../ClaimActionTests.cs | 0 .../CookieTests.cs | 0 .../DynamicSchemeTests.cs | 0 .../FacebookTests.cs | 0 .../GoogleTests.cs | 0 .../JwtBearerTests.cs | 0 ...soft.AspNetCore.Authentication.Test.csproj | 0 .../MicrosoftAccountTests.cs | 0 .../OAuthChallengePropertiesTest.cs | 0 .../OAuthTests.cs | 0 .../OpenIdConnect/MockOpenIdConnectMessage.cs | 0 .../OpenIdConnectChallengeTests.cs | 0 .../OpenIdConnectConfigurationTests.cs | 0 .../OpenIdConnect/OpenIdConnectEventTests.cs | 0 .../OpenIdConnect/OpenIdConnectTests.cs | 0 .../OpenIdConnect/TestServerBuilder.cs | 0 .../OpenIdConnect/TestServerExtensions.cs | 0 .../OpenIdConnect/TestSettings.cs | 0 .../OpenIdConnect/TestTransaction.cs | 0 .../OpenIdConnect/wellknownconfig.json | 0 .../OpenIdConnect/wellknownkeys.json | 0 .../PolicyTests.cs | 0 .../SecureDataFormatTests.cs | 0 .../TestClock.cs | 0 .../TestExtensions.cs | 0 .../TestHandlers.cs | 0 .../TestHttpMessageHandler.cs | 0 .../TicketSerializerTests.cs | 0 .../TokenExtensionTests.cs | 0 .../Transaction.cs | 0 .../TwitterTests.cs | 0 .../WsFederation/CustomStateDataFormat.cs | 0 .../WsFederation/InvalidToken.xml | 0 .../WsFederation/TestSecurityToken.cs | 0 .../TestSecurityTokenValidator.cs | 0 .../WsFederation/ValidToken.xml | 0 .../WsFederation/WsFederationTest.cs | 0 .../WsFederation/federationmetadata.xml | 0 .../katanatest.redmond.corp.microsoft.com.cer | Bin .../selfSigned.cer | Bin .../AuthorizationPolicyFacts.cs | 0 .../DefaultAuthorizationServiceTests.cs | 0 ...osoft.AspNetCore.Authorization.Test.csproj | 0 .../PolicyEvaluatorTests.cs | 0 .../CookieChunkingTests.cs | 0 ....ChunkingCookieManager.Sources.Test.csproj | 0 .../CookieConsentTests.cs | 0 .../CookiePolicyTests.cs | 0 ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 0 .../TestExtensions.cs | 0 .../Transaction.cs | 0 .../CookieInteropTests.cs | 0 ...icrosoft.Owin.Security.Interop.Test.csproj | 0 .../TicketInteropTests.cs | 0 version.props => src/Security/version.props | 0 375 files changed, 565 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .gitattributes delete mode 100644 .travis.yml delete mode 100644 CONTRIBUTING.md delete mode 100644 LICENSE.txt delete mode 100644 NuGet.config delete mode 100644 build.cmd delete mode 100755 build.sh delete mode 100644 korebuild-lock.txt delete mode 100644 korebuild.json delete mode 100644 run.cmd delete mode 100644 run.ps1 delete mode 100755 run.sh rename .gitignore => src/Security/.gitignore (100%) rename Directory.Build.props => src/Security/Directory.Build.props (100%) rename Directory.Build.targets => src/Security/Directory.Build.targets (100%) rename NuGetPackageVerifier.json => src/Security/NuGetPackageVerifier.json (100%) rename README.md => src/Security/README.md (100%) rename Security.sln => src/Security/Security.sln (100%) rename {build => src/Security/build}/Key.snk (100%) rename {build => src/Security/build}/dependencies.props (100%) rename {build => src/Security/build}/repo.props (100%) rename {build => src/Security/build}/sources.props (100%) rename {samples => src/Security/samples}/CookiePolicySample/CookiePolicySample.csproj (100%) rename {samples => src/Security/samples}/CookiePolicySample/Program.cs (100%) rename {samples => src/Security/samples}/CookiePolicySample/Properties/launchSettings.json (100%) rename {samples => src/Security/samples}/CookiePolicySample/Startup.cs (100%) rename {samples => src/Security/samples}/CookieSample/CookieSample.csproj (100%) rename {samples => src/Security/samples}/CookieSample/Program.cs (100%) rename {samples => src/Security/samples}/CookieSample/Properties/launchSettings.json (100%) rename {samples => src/Security/samples}/CookieSample/Startup.cs (100%) rename {samples => src/Security/samples}/CookieSessionSample/CookieSessionSample.csproj (100%) rename {samples => src/Security/samples}/CookieSessionSample/MemoryCacheTicketStore.cs (100%) rename {samples => src/Security/samples}/CookieSessionSample/Program.cs (100%) rename {samples => src/Security/samples}/CookieSessionSample/Properties/launchSettings.json (100%) rename {samples => src/Security/samples}/CookieSessionSample/Startup.cs (100%) rename {samples => src/Security/samples}/JwtBearerSample/JwtBearerSample.csproj (100%) rename {samples => src/Security/samples}/JwtBearerSample/Program.cs (100%) rename {samples => src/Security/samples}/JwtBearerSample/Properties/launchSettings.json (100%) rename {samples => src/Security/samples}/JwtBearerSample/Startup.cs (100%) rename {samples => src/Security/samples}/JwtBearerSample/Todo.cs (100%) rename {samples => src/Security/samples}/JwtBearerSample/wwwroot/App/Scripts/app.js (100%) rename {samples => src/Security/samples}/JwtBearerSample/wwwroot/App/Scripts/homeCtrl.js (100%) rename {samples => src/Security/samples}/JwtBearerSample/wwwroot/App/Scripts/indexCtrl.js (100%) rename {samples => src/Security/samples}/JwtBearerSample/wwwroot/App/Scripts/todoListCtrl.js (100%) rename {samples => src/Security/samples}/JwtBearerSample/wwwroot/App/Scripts/todoListSvc.js (100%) rename {samples => src/Security/samples}/JwtBearerSample/wwwroot/App/Scripts/userDataCtrl.js (100%) rename {samples => src/Security/samples}/JwtBearerSample/wwwroot/App/Views/Home.html (100%) rename {samples => src/Security/samples}/JwtBearerSample/wwwroot/App/Views/TodoList.html (100%) rename {samples => src/Security/samples}/JwtBearerSample/wwwroot/App/Views/UserData.html (100%) rename {samples => src/Security/samples}/JwtBearerSample/wwwroot/index.html (100%) rename {samples => src/Security/samples}/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs (100%) rename {samples => src/Security/samples}/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj (100%) rename {samples => src/Security/samples}/OpenIdConnect.AzureAdSample/Program.cs (100%) rename {samples => src/Security/samples}/OpenIdConnect.AzureAdSample/Properties/launchSettings.json (100%) rename {samples => src/Security/samples}/OpenIdConnect.AzureAdSample/Readme.md (100%) rename {samples => src/Security/samples}/OpenIdConnect.AzureAdSample/Startup.cs (100%) rename {samples => src/Security/samples}/OpenIdConnectSample/OpenIdConnectSample.csproj (100%) rename {samples => src/Security/samples}/OpenIdConnectSample/Program.cs (100%) rename {samples => src/Security/samples}/OpenIdConnectSample/Properties/launchSettings.json (100%) rename {samples => src/Security/samples}/OpenIdConnectSample/Readme.md (100%) rename {samples => src/Security/samples}/OpenIdConnectSample/Startup.cs (100%) rename {samples => src/Security/samples}/OpenIdConnectSample/compiler/resources/cert.pfx (100%) rename {samples => src/Security/samples}/SocialSample/Program.cs (100%) rename {samples => src/Security/samples}/SocialSample/Properties/launchSettings.json (100%) rename {samples => src/Security/samples}/SocialSample/SocialSample.csproj (100%) rename {samples => src/Security/samples}/SocialSample/Startup.cs (100%) rename {samples => src/Security/samples}/SocialSample/compiler/resources/cert.pfx (100%) rename {samples => src/Security/samples}/SocialSample/web.config (100%) rename {samples => src/Security/samples}/WsFedSample/Program.cs (100%) rename {samples => src/Security/samples}/WsFedSample/Properties/launchSettings.json (100%) rename {samples => src/Security/samples}/WsFedSample/Startup.cs (100%) rename {samples => src/Security/samples}/WsFedSample/WsFedSample.csproj (100%) rename {samples => src/Security/samples}/WsFedSample/compiler/resources/cert.pfx (100%) rename {shared => src/Security/shared}/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs (100%) rename src/{ => Security/src}/Directory.Build.props (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Facebook/Resources.resx (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/Resources.resx (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/Resources.resx (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Resources.resx (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollection.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Claims/CustomJsonClaimAction.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Claims/DeleteClaimAction.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonSubKeyClaimAction.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/Resources.resx (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/ClaimActionCollectionUniqueExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/UniqueJsonKeyClaimAction.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/Resources.resx (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/Resources.resx (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/AuthAppBuilderExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Data/IDataSerializer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Data/ISecureDataFormat.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Data/PropertiesDataFormat.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Data/PropertiesSerializer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Data/SecureDataFormat.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Data/TicketDataFormat.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Data/TicketSerializer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/ISystemClock.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/Resources.resx (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/SystemClock.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authentication/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerContextFactory.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerContextFactory.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/Resources.resx (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.Authorization/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs (100%) rename src/{ => Security/src}/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json (100%) rename src/{ => Security/src}/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs (100%) rename src/{ => Security/src}/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs (100%) rename src/{ => Security/src}/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs (100%) rename src/{ => Security/src}/Microsoft.Owin.Security.Interop/Constants.cs (100%) rename src/{ => Security/src}/Microsoft.Owin.Security.Interop/DataProtectorShim.cs (100%) rename src/{ => Security/src}/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj (100%) rename src/{ => Security/src}/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs (100%) rename src/{ => Security/src}/Microsoft.Owin.Security.Interop/baseline.netframework.json (100%) rename {test => src/Security/test}/Directory.Build.props (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/Base64UrlTextEncoderTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/SecureDataFormatTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/TestClock.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/Transaction.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/katanatest.redmond.corp.microsoft.com.cer (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authentication.Test/selfSigned.cer (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs (100%) rename {test => src/Security/test}/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs (100%) rename {test => src/Security/test}/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs (100%) rename {test => src/Security/test}/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj (100%) rename {test => src/Security/test}/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs (100%) rename version.props => src/Security/version.props (100%) diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 4eea96ab69..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -init: -- git config --global core.autocrlf true -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -build_script: -- ps: .\run.ps1 default-build -clone_depth: 1 -environment: - global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: 'off' -deploy: 'off' -os: Visual Studio 2017 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 97b827b758..0000000000 --- a/.gitattributes +++ /dev/null @@ -1,51 +0,0 @@ -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain - -*.jpg binary -*.png binary -*.gif binary - -*.cs text=auto diff=csharp -*.vb text=auto -*.resx text=auto -*.c text=auto -*.cpp text=auto -*.cxx text=auto -*.h text=auto -*.hxx text=auto -*.py text=auto -*.rb text=auto -*.java text=auto -*.html text=auto -*.htm text=auto -*.css text=auto -*.scss text=auto -*.sass text=auto -*.less text=auto -*.js text=auto -*.lisp text=auto -*.clj text=auto -*.sql text=auto -*.php text=auto -*.lua text=auto -*.m text=auto -*.asm text=auto -*.erl text=auto -*.fs text=auto -*.fsx text=auto -*.hs text=auto - -*.csproj text=auto -*.vbproj text=auto -*.fsproj text=auto -*.dbproj text=auto -*.sln text=auto eol=crlf -*.sh eol=lf diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 64bdbb4441..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: csharp -sudo: false -dist: trusty -env: - global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -mono: none -os: -- linux -- osx -osx_image: xcode8.2 -addons: - apt: - packages: - - libunwind8 -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -before_install: -- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s - /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib - /usr/local/lib/; fi -script: -- ./build.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 64ff041d5c..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,4 +0,0 @@ -Contributing -====== - -Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 7b2956ecee..0000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) .NET Foundation and Contributors - -All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. diff --git a/NuGet.config b/NuGet.config deleted file mode 100644 index e32bddfd51..0000000000 --- a/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/build.cmd b/build.cmd deleted file mode 100644 index c0050bda12..0000000000 --- a/build.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh deleted file mode 100755 index 98a4b22765..0000000000 --- a/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) -chmod +x "$DIR/run.sh"; sync -"$DIR/run.sh" default-build "$@" diff --git a/korebuild-lock.txt b/korebuild-lock.txt deleted file mode 100644 index 251c227c83..0000000000 --- a/korebuild-lock.txt +++ /dev/null @@ -1,2 +0,0 @@ -version:2.1.3-rtm-15802 -commithash:a7c08b45b440a7d2058a0aa1eaa3eb6ba811976a diff --git a/korebuild.json b/korebuild.json deleted file mode 100644 index 678d8bb948..0000000000 --- a/korebuild.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", - "channel": "release/2.1" -} diff --git a/run.cmd b/run.cmd deleted file mode 100644 index d52d5c7e68..0000000000 --- a/run.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/run.ps1 b/run.ps1 deleted file mode 100644 index 27dcf848f8..0000000000 --- a/run.ps1 +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env powershell -#requires -version 4 - -<# -.SYNOPSIS -Executes KoreBuild commands. - -.DESCRIPTION -Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. - -.PARAMETER Command -The KoreBuild command to run. - -.PARAMETER Path -The folder to build. Defaults to the folder containing this script. - -.PARAMETER Channel -The channel of KoreBuild to download. Overrides the value from the config file. - -.PARAMETER DotNetHome -The directory where .NET Core tools will be stored. - -.PARAMETER ToolsSource -The base url where build tools can be downloaded. Overrides the value from the config file. - -.PARAMETER Update -Updates KoreBuild to the latest version even if a lock file is present. - -.PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to korebuild.json. - -.PARAMETER ToolsSourceSuffix -The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. - -.PARAMETER Arguments -Arguments to be passed to the command - -.NOTES -This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. -When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. - -The $ConfigFile is expected to be an JSON file. It is optional, and the configuration values in it are optional as well. Any options set -in the file are overridden by command line parameters. - -.EXAMPLE -Example config file: -```json -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev", - "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" -} -``` -#> -[CmdletBinding(PositionalBinding = $false)] -param( - [Parameter(Mandatory = $true, Position = 0)] - [string]$Command, - [string]$Path = $PSScriptRoot, - [Alias('c')] - [string]$Channel, - [Alias('d')] - [string]$DotNetHome, - [Alias('s')] - [string]$ToolsSource, - [Alias('u')] - [switch]$Update, - [string]$ConfigFile, - [string]$ToolsSourceSuffix, - [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$Arguments -) - -Set-StrictMode -Version 2 -$ErrorActionPreference = 'Stop' - -# -# Functions -# - -function Get-KoreBuild { - - $lockFile = Join-Path $Path 'korebuild-lock.txt' - - if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix - } - - $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 - if (!$version) { - Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" - } - $version = $version.TrimStart('version:').Trim() - $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) - - if (!(Test-Path $korebuildPath)) { - Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" - New-Item -ItemType Directory -Path $korebuildPath | Out-Null - $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" - - try { - $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix - if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { - # Use built-in commands where possible as they are cross-plat compatible - Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath - } - else { - # Fallback to old approach for old installations of PowerShell - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) - } - } - catch { - Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore - throw - } - finally { - Remove-Item $tmpfile -ErrorAction Ignore - } - } - - return $korebuildPath -} - -function Join-Paths([string]$path, [string[]]$childPaths) { - $childPaths | ForEach-Object { $path = Join-Path $path $_ } - return $path -} - -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { - if ($RemotePath -notlike 'http*') { - Copy-Item $RemotePath $LocalPath - return - } - - $retries = 10 - while ($retries -gt 0) { - $retries -= 1 - try { - Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath - return - } - catch { - Write-Verbose "Request failed. $retries retries remaining" - } - } - - Write-Error "Download failed: '$RemotePath'." -} - -# -# Main -# - -# Load configuration or set defaults - -$Path = Resolve-Path $Path -if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } - -if (Test-Path $ConfigFile) { - try { - $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json - if ($config) { - if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } - if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} - } - } - catch { - Write-Warning "$ConfigFile could not be read. Its settings will be ignored." - Write-Warning $Error[0] - } -} - -if (!$DotNetHome) { - $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` - elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` - elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` - else { Join-Path $PSScriptRoot '.dotnet'} -} - -if (!$Channel) { $Channel = 'dev' } -if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } - -# Execute - -$korebuildPath = Get-KoreBuild -Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') - -try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile - Invoke-KoreBuildCommand $Command @Arguments -} -finally { - Remove-Module 'KoreBuild' -ErrorAction Ignore -} diff --git a/run.sh b/run.sh deleted file mode 100755 index 834961fc3a..0000000000 --- a/run.sh +++ /dev/null @@ -1,231 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -YELLOW="\033[0;33m" -MAGENTA="\033[0;95m" -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -verbose=false -update=false -repo_path="$DIR" -channel='' -tools_source='' -tools_source_suffix='' - -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " command The command to be run." - echo " ... Arguments passed to the command. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo "" - echo "Description:" - echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}error: $*${RESET}" 1>&2 -} - -__warn() { - echo -e "${YELLOW}warning: $*${RESET}" -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - local remote_path_suffix=$3 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -# -# main -# - -command="${1:-}" -shift - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - if [ ! -f "$config_file" ]; then - __error "Invalid value for --config-file. $config_file does not exist." - exit 1 - fi - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - --tools-source-suffix|-ToolsSourceSuffix) - shift - tools_source_suffix="${1:-}" - [ -z "$tools_source_suffix" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" -if [ -f "$config_file" ]; then - if __machine_has jq ; then - if jq '.' "$config_file" >/dev/null ; then - config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" - config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" - else - __warn "$config_file is invalid JSON. Its settings will be ignored." - fi - elif __machine_has python ; then - if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then - config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" - config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" - else - __warn "$config_file is invalid JSON. Its settings will be ignored." - fi - else - __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' - fi - - [ ! -z "${config_channel:-}" ] && channel="$config_channel" - [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" -fi - -[ -z "$channel" ] && channel='dev' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' - -get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" -invoke_korebuild_command "$command" "$@" diff --git a/.gitignore b/src/Security/.gitignore similarity index 100% rename from .gitignore rename to src/Security/.gitignore diff --git a/Directory.Build.props b/src/Security/Directory.Build.props similarity index 100% rename from Directory.Build.props rename to src/Security/Directory.Build.props diff --git a/Directory.Build.targets b/src/Security/Directory.Build.targets similarity index 100% rename from Directory.Build.targets rename to src/Security/Directory.Build.targets diff --git a/NuGetPackageVerifier.json b/src/Security/NuGetPackageVerifier.json similarity index 100% rename from NuGetPackageVerifier.json rename to src/Security/NuGetPackageVerifier.json diff --git a/README.md b/src/Security/README.md similarity index 100% rename from README.md rename to src/Security/README.md diff --git a/Security.sln b/src/Security/Security.sln similarity index 100% rename from Security.sln rename to src/Security/Security.sln diff --git a/build/Key.snk b/src/Security/build/Key.snk similarity index 100% rename from build/Key.snk rename to src/Security/build/Key.snk diff --git a/build/dependencies.props b/src/Security/build/dependencies.props similarity index 100% rename from build/dependencies.props rename to src/Security/build/dependencies.props diff --git a/build/repo.props b/src/Security/build/repo.props similarity index 100% rename from build/repo.props rename to src/Security/build/repo.props diff --git a/build/sources.props b/src/Security/build/sources.props similarity index 100% rename from build/sources.props rename to src/Security/build/sources.props diff --git a/samples/CookiePolicySample/CookiePolicySample.csproj b/src/Security/samples/CookiePolicySample/CookiePolicySample.csproj similarity index 100% rename from samples/CookiePolicySample/CookiePolicySample.csproj rename to src/Security/samples/CookiePolicySample/CookiePolicySample.csproj diff --git a/samples/CookiePolicySample/Program.cs b/src/Security/samples/CookiePolicySample/Program.cs similarity index 100% rename from samples/CookiePolicySample/Program.cs rename to src/Security/samples/CookiePolicySample/Program.cs diff --git a/samples/CookiePolicySample/Properties/launchSettings.json b/src/Security/samples/CookiePolicySample/Properties/launchSettings.json similarity index 100% rename from samples/CookiePolicySample/Properties/launchSettings.json rename to src/Security/samples/CookiePolicySample/Properties/launchSettings.json diff --git a/samples/CookiePolicySample/Startup.cs b/src/Security/samples/CookiePolicySample/Startup.cs similarity index 100% rename from samples/CookiePolicySample/Startup.cs rename to src/Security/samples/CookiePolicySample/Startup.cs diff --git a/samples/CookieSample/CookieSample.csproj b/src/Security/samples/CookieSample/CookieSample.csproj similarity index 100% rename from samples/CookieSample/CookieSample.csproj rename to src/Security/samples/CookieSample/CookieSample.csproj diff --git a/samples/CookieSample/Program.cs b/src/Security/samples/CookieSample/Program.cs similarity index 100% rename from samples/CookieSample/Program.cs rename to src/Security/samples/CookieSample/Program.cs diff --git a/samples/CookieSample/Properties/launchSettings.json b/src/Security/samples/CookieSample/Properties/launchSettings.json similarity index 100% rename from samples/CookieSample/Properties/launchSettings.json rename to src/Security/samples/CookieSample/Properties/launchSettings.json diff --git a/samples/CookieSample/Startup.cs b/src/Security/samples/CookieSample/Startup.cs similarity index 100% rename from samples/CookieSample/Startup.cs rename to src/Security/samples/CookieSample/Startup.cs diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/src/Security/samples/CookieSessionSample/CookieSessionSample.csproj similarity index 100% rename from samples/CookieSessionSample/CookieSessionSample.csproj rename to src/Security/samples/CookieSessionSample/CookieSessionSample.csproj diff --git a/samples/CookieSessionSample/MemoryCacheTicketStore.cs b/src/Security/samples/CookieSessionSample/MemoryCacheTicketStore.cs similarity index 100% rename from samples/CookieSessionSample/MemoryCacheTicketStore.cs rename to src/Security/samples/CookieSessionSample/MemoryCacheTicketStore.cs diff --git a/samples/CookieSessionSample/Program.cs b/src/Security/samples/CookieSessionSample/Program.cs similarity index 100% rename from samples/CookieSessionSample/Program.cs rename to src/Security/samples/CookieSessionSample/Program.cs diff --git a/samples/CookieSessionSample/Properties/launchSettings.json b/src/Security/samples/CookieSessionSample/Properties/launchSettings.json similarity index 100% rename from samples/CookieSessionSample/Properties/launchSettings.json rename to src/Security/samples/CookieSessionSample/Properties/launchSettings.json diff --git a/samples/CookieSessionSample/Startup.cs b/src/Security/samples/CookieSessionSample/Startup.cs similarity index 100% rename from samples/CookieSessionSample/Startup.cs rename to src/Security/samples/CookieSessionSample/Startup.cs diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/src/Security/samples/JwtBearerSample/JwtBearerSample.csproj similarity index 100% rename from samples/JwtBearerSample/JwtBearerSample.csproj rename to src/Security/samples/JwtBearerSample/JwtBearerSample.csproj diff --git a/samples/JwtBearerSample/Program.cs b/src/Security/samples/JwtBearerSample/Program.cs similarity index 100% rename from samples/JwtBearerSample/Program.cs rename to src/Security/samples/JwtBearerSample/Program.cs diff --git a/samples/JwtBearerSample/Properties/launchSettings.json b/src/Security/samples/JwtBearerSample/Properties/launchSettings.json similarity index 100% rename from samples/JwtBearerSample/Properties/launchSettings.json rename to src/Security/samples/JwtBearerSample/Properties/launchSettings.json diff --git a/samples/JwtBearerSample/Startup.cs b/src/Security/samples/JwtBearerSample/Startup.cs similarity index 100% rename from samples/JwtBearerSample/Startup.cs rename to src/Security/samples/JwtBearerSample/Startup.cs diff --git a/samples/JwtBearerSample/Todo.cs b/src/Security/samples/JwtBearerSample/Todo.cs similarity index 100% rename from samples/JwtBearerSample/Todo.cs rename to src/Security/samples/JwtBearerSample/Todo.cs diff --git a/samples/JwtBearerSample/wwwroot/App/Scripts/app.js b/src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/app.js similarity index 100% rename from samples/JwtBearerSample/wwwroot/App/Scripts/app.js rename to src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/app.js diff --git a/samples/JwtBearerSample/wwwroot/App/Scripts/homeCtrl.js b/src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/homeCtrl.js similarity index 100% rename from samples/JwtBearerSample/wwwroot/App/Scripts/homeCtrl.js rename to src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/homeCtrl.js diff --git a/samples/JwtBearerSample/wwwroot/App/Scripts/indexCtrl.js b/src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/indexCtrl.js similarity index 100% rename from samples/JwtBearerSample/wwwroot/App/Scripts/indexCtrl.js rename to src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/indexCtrl.js diff --git a/samples/JwtBearerSample/wwwroot/App/Scripts/todoListCtrl.js b/src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/todoListCtrl.js similarity index 100% rename from samples/JwtBearerSample/wwwroot/App/Scripts/todoListCtrl.js rename to src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/todoListCtrl.js diff --git a/samples/JwtBearerSample/wwwroot/App/Scripts/todoListSvc.js b/src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/todoListSvc.js similarity index 100% rename from samples/JwtBearerSample/wwwroot/App/Scripts/todoListSvc.js rename to src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/todoListSvc.js diff --git a/samples/JwtBearerSample/wwwroot/App/Scripts/userDataCtrl.js b/src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/userDataCtrl.js similarity index 100% rename from samples/JwtBearerSample/wwwroot/App/Scripts/userDataCtrl.js rename to src/Security/samples/JwtBearerSample/wwwroot/App/Scripts/userDataCtrl.js diff --git a/samples/JwtBearerSample/wwwroot/App/Views/Home.html b/src/Security/samples/JwtBearerSample/wwwroot/App/Views/Home.html similarity index 100% rename from samples/JwtBearerSample/wwwroot/App/Views/Home.html rename to src/Security/samples/JwtBearerSample/wwwroot/App/Views/Home.html diff --git a/samples/JwtBearerSample/wwwroot/App/Views/TodoList.html b/src/Security/samples/JwtBearerSample/wwwroot/App/Views/TodoList.html similarity index 100% rename from samples/JwtBearerSample/wwwroot/App/Views/TodoList.html rename to src/Security/samples/JwtBearerSample/wwwroot/App/Views/TodoList.html diff --git a/samples/JwtBearerSample/wwwroot/App/Views/UserData.html b/src/Security/samples/JwtBearerSample/wwwroot/App/Views/UserData.html similarity index 100% rename from samples/JwtBearerSample/wwwroot/App/Views/UserData.html rename to src/Security/samples/JwtBearerSample/wwwroot/App/Views/UserData.html diff --git a/samples/JwtBearerSample/wwwroot/index.html b/src/Security/samples/JwtBearerSample/wwwroot/index.html similarity index 100% rename from samples/JwtBearerSample/wwwroot/index.html rename to src/Security/samples/JwtBearerSample/wwwroot/index.html diff --git a/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs b/src/Security/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs similarity index 100% rename from samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs rename to src/Security/samples/OpenIdConnect.AzureAdSample/AuthPropertiesTokenCache.cs diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/src/Security/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj similarity index 100% rename from samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj rename to src/Security/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj diff --git a/samples/OpenIdConnect.AzureAdSample/Program.cs b/src/Security/samples/OpenIdConnect.AzureAdSample/Program.cs similarity index 100% rename from samples/OpenIdConnect.AzureAdSample/Program.cs rename to src/Security/samples/OpenIdConnect.AzureAdSample/Program.cs diff --git a/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json b/src/Security/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json similarity index 100% rename from samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json rename to src/Security/samples/OpenIdConnect.AzureAdSample/Properties/launchSettings.json diff --git a/samples/OpenIdConnect.AzureAdSample/Readme.md b/src/Security/samples/OpenIdConnect.AzureAdSample/Readme.md similarity index 100% rename from samples/OpenIdConnect.AzureAdSample/Readme.md rename to src/Security/samples/OpenIdConnect.AzureAdSample/Readme.md diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/src/Security/samples/OpenIdConnect.AzureAdSample/Startup.cs similarity index 100% rename from samples/OpenIdConnect.AzureAdSample/Startup.cs rename to src/Security/samples/OpenIdConnect.AzureAdSample/Startup.cs diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/src/Security/samples/OpenIdConnectSample/OpenIdConnectSample.csproj similarity index 100% rename from samples/OpenIdConnectSample/OpenIdConnectSample.csproj rename to src/Security/samples/OpenIdConnectSample/OpenIdConnectSample.csproj diff --git a/samples/OpenIdConnectSample/Program.cs b/src/Security/samples/OpenIdConnectSample/Program.cs similarity index 100% rename from samples/OpenIdConnectSample/Program.cs rename to src/Security/samples/OpenIdConnectSample/Program.cs diff --git a/samples/OpenIdConnectSample/Properties/launchSettings.json b/src/Security/samples/OpenIdConnectSample/Properties/launchSettings.json similarity index 100% rename from samples/OpenIdConnectSample/Properties/launchSettings.json rename to src/Security/samples/OpenIdConnectSample/Properties/launchSettings.json diff --git a/samples/OpenIdConnectSample/Readme.md b/src/Security/samples/OpenIdConnectSample/Readme.md similarity index 100% rename from samples/OpenIdConnectSample/Readme.md rename to src/Security/samples/OpenIdConnectSample/Readme.md diff --git a/samples/OpenIdConnectSample/Startup.cs b/src/Security/samples/OpenIdConnectSample/Startup.cs similarity index 100% rename from samples/OpenIdConnectSample/Startup.cs rename to src/Security/samples/OpenIdConnectSample/Startup.cs diff --git a/samples/OpenIdConnectSample/compiler/resources/cert.pfx b/src/Security/samples/OpenIdConnectSample/compiler/resources/cert.pfx similarity index 100% rename from samples/OpenIdConnectSample/compiler/resources/cert.pfx rename to src/Security/samples/OpenIdConnectSample/compiler/resources/cert.pfx diff --git a/samples/SocialSample/Program.cs b/src/Security/samples/SocialSample/Program.cs similarity index 100% rename from samples/SocialSample/Program.cs rename to src/Security/samples/SocialSample/Program.cs diff --git a/samples/SocialSample/Properties/launchSettings.json b/src/Security/samples/SocialSample/Properties/launchSettings.json similarity index 100% rename from samples/SocialSample/Properties/launchSettings.json rename to src/Security/samples/SocialSample/Properties/launchSettings.json diff --git a/samples/SocialSample/SocialSample.csproj b/src/Security/samples/SocialSample/SocialSample.csproj similarity index 100% rename from samples/SocialSample/SocialSample.csproj rename to src/Security/samples/SocialSample/SocialSample.csproj diff --git a/samples/SocialSample/Startup.cs b/src/Security/samples/SocialSample/Startup.cs similarity index 100% rename from samples/SocialSample/Startup.cs rename to src/Security/samples/SocialSample/Startup.cs diff --git a/samples/SocialSample/compiler/resources/cert.pfx b/src/Security/samples/SocialSample/compiler/resources/cert.pfx similarity index 100% rename from samples/SocialSample/compiler/resources/cert.pfx rename to src/Security/samples/SocialSample/compiler/resources/cert.pfx diff --git a/samples/SocialSample/web.config b/src/Security/samples/SocialSample/web.config similarity index 100% rename from samples/SocialSample/web.config rename to src/Security/samples/SocialSample/web.config diff --git a/samples/WsFedSample/Program.cs b/src/Security/samples/WsFedSample/Program.cs similarity index 100% rename from samples/WsFedSample/Program.cs rename to src/Security/samples/WsFedSample/Program.cs diff --git a/samples/WsFedSample/Properties/launchSettings.json b/src/Security/samples/WsFedSample/Properties/launchSettings.json similarity index 100% rename from samples/WsFedSample/Properties/launchSettings.json rename to src/Security/samples/WsFedSample/Properties/launchSettings.json diff --git a/samples/WsFedSample/Startup.cs b/src/Security/samples/WsFedSample/Startup.cs similarity index 100% rename from samples/WsFedSample/Startup.cs rename to src/Security/samples/WsFedSample/Startup.cs diff --git a/samples/WsFedSample/WsFedSample.csproj b/src/Security/samples/WsFedSample/WsFedSample.csproj similarity index 100% rename from samples/WsFedSample/WsFedSample.csproj rename to src/Security/samples/WsFedSample/WsFedSample.csproj diff --git a/samples/WsFedSample/compiler/resources/cert.pfx b/src/Security/samples/WsFedSample/compiler/resources/cert.pfx similarity index 100% rename from samples/WsFedSample/compiler/resources/cert.pfx rename to src/Security/samples/WsFedSample/compiler/resources/cert.pfx diff --git a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs b/src/Security/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs similarity index 100% rename from shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs rename to src/Security/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs diff --git a/src/Directory.Build.props b/src/Security/src/Directory.Build.props similarity index 100% rename from src/Directory.Build.props rename to src/Security/src/Directory.Build.props diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Constants.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationDefaults.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/ICookieManager.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/ITicketStore.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj rename to src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Resources.resx b/src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Facebook/Resources.resx rename to src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/Resources.resx diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleHelper.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/GoogleOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Resources.resx b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/Resources.resx rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/Resources.resx diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerDefaults.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Resources.resx b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/Resources.resx rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/Resources.resx diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj rename to src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Resources.resx b/src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Resources.resx rename to src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Resources.resx diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollection.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollection.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollection.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollection.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/CustomJsonClaimAction.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/CustomJsonClaimAction.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Claims/CustomJsonClaimAction.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/CustomJsonClaimAction.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/DeleteClaimAction.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/DeleteClaimAction.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Claims/DeleteClaimAction.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/DeleteClaimAction.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonSubKeyClaimAction.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonSubKeyClaimAction.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonSubKeyClaimAction.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonSubKeyClaimAction.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthTokenResponse.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Resources.resx b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/Resources.resx rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/Resources.resx diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/ClaimActionCollectionUniqueExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/ClaimActionCollectionUniqueExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/ClaimActionCollectionUniqueExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/ClaimActionCollectionUniqueExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/UniqueJsonKeyClaimAction.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/UniqueJsonKeyClaimAction.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/UniqueJsonKeyClaimAction.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Claims/UniqueJsonKeyClaimAction.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectRedirectBehavior.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Resources.resx b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Resources.resx rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Resources.resx diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/LoggingExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/AccessToken.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestToken.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Messages/RequestTokenSerializer.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Resources.resx b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/Resources.resx rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/Resources.resx diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication/AuthAppBuilderExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/AuthAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/AuthAppBuilderExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/AuthAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Data/IDataSerializer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Data/IDataSerializer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Data/IDataSerializer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Data/IDataSerializer.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Data/ISecureDataFormat.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Data/ISecureDataFormat.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Data/ISecureDataFormat.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Data/ISecureDataFormat.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Data/PropertiesDataFormat.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Data/PropertiesDataFormat.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Data/PropertiesDataFormat.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Data/PropertiesDataFormat.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Data/PropertiesSerializer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Data/PropertiesSerializer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Data/PropertiesSerializer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Data/PropertiesSerializer.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Data/SecureDataFormat.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Data/SecureDataFormat.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Data/SecureDataFormat.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Data/SecureDataFormat.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Data/TicketDataFormat.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Data/TicketDataFormat.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Data/TicketDataFormat.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Data/TicketDataFormat.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Data/TicketSerializer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Data/TicketSerializer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Data/TicketSerializer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Data/TicketSerializer.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs diff --git a/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs diff --git a/src/Microsoft.AspNetCore.Authentication/ISystemClock.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/ISystemClock.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/ISystemClock.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/ISystemClock.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs diff --git a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Security/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj rename to src/Security/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj diff --git a/src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication/Resources.resx b/src/Security/src/Microsoft.AspNetCore.Authentication/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/Resources.resx rename to src/Security/src/Microsoft.AspNetCore.Authentication/Resources.resx diff --git a/src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs diff --git a/src/Microsoft.AspNetCore.Authentication/SystemClock.cs b/src/Security/src/Microsoft.AspNetCore.Authentication/SystemClock.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/SystemClock.cs rename to src/Security/src/Microsoft.AspNetCore.Authentication/SystemClock.cs diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authentication/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs b/src/Security/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Security/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj rename to src/Security/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs b/src/Security/src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs b/src/Security/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AllowAnonymousAttribute.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationHandler.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationHandlerContext.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerContextFactory.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerContextFactory.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerContextFactory.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerContextFactory.cs diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs diff --git a/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/IAllowAnonymous.cs diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandler.cs diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerContextFactory.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerContextFactory.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerContextFactory.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerContextFactory.cs diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/AssertionRequirement.cs diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/OperationAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs diff --git a/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Security/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj rename to src/Security/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj diff --git a/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs b/src/Security/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs rename to src/Security/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Authorization/Resources.resx b/src/Security/src/Microsoft.AspNetCore.Authorization/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/Resources.resx rename to src/Security/src/Microsoft.AspNetCore.Authorization/Resources.resx diff --git a/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Authorization/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs b/src/Security/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs rename to src/Security/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs b/src/Security/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyAppBuilderExtensions.cs diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Security/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs similarity index 100% rename from src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs rename to src/Security/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Security/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs rename to src/Security/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs diff --git a/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs b/src/Security/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs similarity index 100% rename from src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs rename to src/Security/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs diff --git a/src/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs b/src/Security/src/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs similarity index 100% rename from src/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs rename to src/Security/src/Microsoft.AspNetCore.CookiePolicy/HttpOnlyPolicy.cs diff --git a/src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs b/src/Security/src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs rename to src/Security/src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Security/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj similarity index 100% rename from src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj rename to src/Security/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj diff --git a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs b/src/Security/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs similarity index 100% rename from src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs rename to src/Security/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json b/src/Security/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json rename to src/Security/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs b/src/Security/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs similarity index 100% rename from src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs rename to src/Security/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs b/src/Security/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs similarity index 100% rename from src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs rename to src/Security/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs diff --git a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs b/src/Security/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs similarity index 100% rename from src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs rename to src/Security/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs diff --git a/src/Microsoft.Owin.Security.Interop/Constants.cs b/src/Security/src/Microsoft.Owin.Security.Interop/Constants.cs similarity index 100% rename from src/Microsoft.Owin.Security.Interop/Constants.cs rename to src/Security/src/Microsoft.Owin.Security.Interop/Constants.cs diff --git a/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs b/src/Security/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs similarity index 100% rename from src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs rename to src/Security/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Security/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj similarity index 100% rename from src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj rename to src/Security/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj diff --git a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs b/src/Security/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs rename to src/Security/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Security/src/Microsoft.Owin.Security.Interop/baseline.netframework.json similarity index 100% rename from src/Microsoft.Owin.Security.Interop/baseline.netframework.json rename to src/Security/src/Microsoft.Owin.Security.Interop/baseline.netframework.json diff --git a/test/Directory.Build.props b/src/Security/test/Directory.Build.props similarity index 100% rename from test/Directory.Build.props rename to src/Security/test/Directory.Build.props diff --git a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Base64UrlTextEncoderTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/Base64UrlTextEncoderTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/Base64UrlTextEncoderTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/Base64UrlTextEncoderTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/MockOpenIdConnectMessage.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerExtensions.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestTransaction.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json diff --git a/test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/SecureDataFormatTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/SecureDataFormatTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/SecureDataFormatTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/SecureDataFormatTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TestClock.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/TestClock.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/TestClock.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/TestClock.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/TestExtensions.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/TestHttpMessageHandler.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml diff --git a/test/Microsoft.AspNetCore.Authentication.Test/katanatest.redmond.corp.microsoft.com.cer b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/katanatest.redmond.corp.microsoft.com.cer similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/katanatest.redmond.corp.microsoft.com.cer rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/katanatest.redmond.corp.microsoft.com.cer diff --git a/test/Microsoft.AspNetCore.Authentication.Test/selfSigned.cer b/src/Security/test/Microsoft.AspNetCore.Authentication.Test/selfSigned.cer similarity index 100% rename from test/Microsoft.AspNetCore.Authentication.Test/selfSigned.cer rename to src/Security/test/Microsoft.AspNetCore.Authentication.Test/selfSigned.cer diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs b/src/Security/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs rename to src/Security/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/src/Security/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/src/Security/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj similarity index 100% rename from test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj rename to src/Security/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj diff --git a/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs b/src/Security/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs rename to src/Security/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs b/src/Security/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs rename to src/Security/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/src/Security/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj similarity index 100% rename from test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj rename to src/Security/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs b/src/Security/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs rename to src/Security/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/src/Security/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs rename to src/Security/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/src/Security/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj similarity index 100% rename from test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj rename to src/Security/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs b/src/Security/test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs similarity index 100% rename from test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs rename to src/Security/test/Microsoft.AspNetCore.CookiePolicy.Test/TestExtensions.cs diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs b/src/Security/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs similarity index 100% rename from test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs rename to src/Security/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/src/Security/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs similarity index 100% rename from test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs rename to src/Security/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/src/Security/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj similarity index 100% rename from test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj rename to src/Security/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/src/Security/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs similarity index 100% rename from test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs rename to src/Security/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs diff --git a/version.props b/src/Security/version.props similarity index 100% rename from version.props rename to src/Security/version.props